Skip to content

Commit

Permalink
Bug 582486 Improve help for queries
Browse files Browse the repository at this point in the history
Add help to more queries.

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=582486
Change-Id: I260db5c306fa31dd02392406cb25bb2ba1a424ea
  • Loading branch information
ajohnson1 committed Sep 29, 2023
1 parent 5bae292 commit fbdc046
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 SAP AG.
* Copyright (c) 2008, 2023 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -23,6 +23,7 @@
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.snapshot.ISnapshot;
import org.eclipse.mat.snapshot.extension.Subject;
Expand All @@ -33,6 +34,7 @@
import org.eclipse.mat.util.IProgressListener;

@CommandName("find_strings")
@HelpUrl("/org.eclipse.mat.ui.help/reference/inspections/find_strings.html")
@Icon("/META-INF/icons/find_strings.gif")
@Subject("java.lang.String")
public class FindStringsQuery implements IQuery
Expand Down Expand Up @@ -64,6 +66,7 @@ public String getLabel()

public IResult execute(IProgressListener listener) throws Exception
{
boolean onlyStrings = false;
ArrayInt result = new ArrayInt();

Collection<IClass> classes = snapshot.getClassesByName("java.lang.String", false); //$NON-NLS-1$
Expand Down Expand Up @@ -117,7 +120,7 @@ public IResult execute(IProgressListener listener) throws Exception

IObject instance = snapshot.getObject(id);
// if (!classes.contains(instance.getClazz()))
if (!javaLangString.equals(instance.getClazz()))
if (onlyStrings && !javaLangString.equals(instance.getClazz()))
{
listener.worked(hot.work());
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 IBM Corporation and others.
* Copyright (c) 2009, 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -18,13 +18,15 @@
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.snapshot.ISnapshot;
import org.eclipse.mat.snapshot.extension.Subject;
import org.eclipse.mat.util.IProgressListener;

@CommandName("phantom_references_statistics")
@Icon("/META-INF/icons/phantom_reference.gif")
@HelpUrl("/org.eclipse.mat.ui.help/reference/inspections/reference_leak.html")
@Subject("java.lang.ref.PhantomReference")
public class PhantomReferenceStatQuery implements IQuery
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.query.results.CompositeResult;
import org.eclipse.mat.snapshot.Histogram;
Expand All @@ -45,6 +46,7 @@
*/
@CommandName("references_statistics")
@Icon("/META-INF/icons/reference.gif")
@HelpUrl("/org.eclipse.mat.ui.help/reference/inspections/reference_leak.html")
@Subject("java.lang.ref.Reference")
public class ReferenceQuery implements IQuery
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2019 SAP AG and IBM Corporation.
* Copyright (c) 2008, 2023 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -18,13 +18,15 @@
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.snapshot.ISnapshot;
import org.eclipse.mat.snapshot.extension.Subject;
import org.eclipse.mat.util.IProgressListener;

@CommandName("soft_references_statistics")
@Icon("/META-INF/icons/soft_reference.gif")
@HelpUrl("/org.eclipse.mat.ui.help/reference/inspections/reference_leak.html")
@Subject("java.lang.ref.SoftReference")
public class SoftReferenceStatQuery implements IQuery
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 SAP AG and others.
* Copyright (c) 2008, 2023 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API and implementation
* IBM Corporation - help url
*******************************************************************************/
package org.eclipse.mat.inspections;

Expand All @@ -18,6 +19,7 @@
import org.eclipse.mat.query.IQuery;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.snapshot.ISnapshot;
import org.eclipse.mat.snapshot.extension.Subject;
Expand All @@ -28,6 +30,7 @@

@Subject("java.lang.System")
@CommandName("system_properties")
@HelpUrl("/org.eclipse.mat.ui.help/reference/inspections/system_properties.html")
@Icon("/META-INF/icons/osgi/property.gif")
public class SystemPropertiesQuery implements IQuery
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 IBM Corporation.
* Copyright (c) 2009, 2023 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -17,13 +17,15 @@
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.snapshot.ISnapshot;
import org.eclipse.mat.snapshot.extension.Subject;
import org.eclipse.mat.util.IProgressListener;

@CommandName("weak_references_statistics")
@Icon("/META-INF/icons/weak_reference.gif")
@HelpUrl("/org.eclipse.mat.ui.help/reference/inspections/reference_leak.html")
@Subject("java.lang.ref.WeakReference")
public class WeakReferenceStatQuery implements IQuery
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2021 SAP AG, IBM Corporation and others.
* Copyright (c) 2008, 2023 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -28,6 +28,7 @@
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.report.Params;
import org.eclipse.mat.report.QuerySpec;
Expand All @@ -41,6 +42,7 @@
import org.eclipse.mat.util.SimpleMonitor;

@CommandName("component_report_top")
@HelpUrl("/org.eclipse.mat.ui.help/reference/inspections/component_report.html")
@Icon("/META-INF/icons/top_components_report.gif")
public class TopComponentsReportQuery implements IQuery
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void testHelpUrl() throws MalformedURLException, IOException
String encoding = StandardCharsets.UTF_8.name();
String s;
try (InputStream is = url2.openStream();
InputStreamReader isr = new InputStreamReader(is);
InputStreamReader isr = new InputStreamReader(is, encoding);
BufferedReader br = new BufferedReader(isr))
{
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 IBM Corporation.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
IBM Corporation - initial implementation
-->
<!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd" >
<reference id="ref_system_properties" xml:lang="en-us">
<title>System Properties</title>
<shortdesc>Find strings which match a regular expression.
</shortdesc>
<prolog>
<copyright>
<copyryear year=""></copyryear>
<copyrholder>
Copyright (c) 2023 IBM Corporation.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
</copyrholder>
</copyright>
</prolog>

<refbody>
<section>
<title>Motivation</title>
Sometimes it is useful to see find strings which match a regular expression.
For example, to see where there is a string which matches a desired file name.
There may then be references to that string by objects of interest.
</section>
<section>
<title>Arguments</title>
<simpletable>
<sthead>
<stentry>Argument</stentry>
<stentry>Description</stentry>
</sthead>
<strow>
<stentry>objects</stentry>
<stentry>Optionally limit the search to Strings in this object set.
Note that this query does not have to operate on Strings; it will operate on an object
which for which Eclipse Memory Analyzer can resolve a class specific name, for example
StringBuilder, Integer, URL, etc.
</stentry>
</strow>
<strow>
<stentry>pattern</stentry>
<stentry>A regular expression defining which strings match and should be returned by this query.</stentry>
</strow>
</simpletable>
</section>
<section id="result">
<title>Result</title>
<p>A table showing the strings that match the regular expression.
</p>
</section>
</refbody>
</reference>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta name="generator" content="DITA-OT" /><meta name="DC.type" content="reference" />
<meta name="DC.title" content="System Properties" />
<meta name="abstract" content="Find strings which match a regular expression." />
<meta name="description" content="Find strings which match a regular expression." />
<meta name="copyright" content="Copyright (c) 2023 IBM Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ " type="primary" />
<meta name="DC.rights.owner" content="Copyright (c) 2023 IBM Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ " type="primary" />
<meta name="DC.format" content="XHTML" />
<meta name="DC.identifier" content="ref_system_properties" />
<meta name="DC.language" content="en-us" />
<link rel="stylesheet" type="text/css" href="../../styles/commonltr.css" />
<title>System Properties</title>
</head>
<body id="ref_system_properties">

<h1 class="title topictitle1" id="ariaid-title1">System Properties</h1>




<div class="body refbody"><p class="shortdesc">Find strings which match a regular expression.
</p>

<div class="section"><h2 class="title sectiontitle">Motivation</h2>

Sometimes it is useful to see find strings which match a regular expression.
For example, to see where there is a string which matches a desired file name.
There may then be references to that string by objects of interest.
</div>

<div class="section"><h2 class="title sectiontitle">Arguments</h2>

<table cellpadding="4" cellspacing="0" summary="" border="1" class="simpletable"><col style="width:50%" /><col style="width:50%" /><thead><tr class="sthead">
<th style="vertical-align:bottom;text-align:left;" id="d17036e44" class="stentry">Argument</th>

<th style="vertical-align:bottom;text-align:left;" id="d17036e47" class="stentry">Description</th>

</tr>
</thead><tbody><tr class="strow">
<td style="vertical-align:top;" headers="d17036e44" class="stentry">objects</td>

<td style="vertical-align:top;" headers="d17036e47" class="stentry">Optionally limit the search to Strings in this object set.
Note that this query does not have to operate on Strings; it will operate on an object
which for which Eclipse Memory Analyzer can resolve a class specific name, for example
StringBuilder, Integer, URL, etc.
</td>

</tr>
<tr class="strow">
<td style="vertical-align:top;" headers="d17036e44" class="stentry">pattern</td>

<td style="vertical-align:top;" headers="d17036e47" class="stentry">A regular expression defining which strings match and should be returned by this query.</td>

</tr>
</tbody></table>

</div>

<div class="section" id="ref_system_properties__result"><h2 class="title sectiontitle">Result</h2>

<p class="p">A table showing the strings that match the regular expression.
</p>

</div>

</div>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 IBM Corporation.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
IBM Corporation - initial implementation
-->
<!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd" >
<reference id="ref_system_properties" xml:lang="en-us">
<title>System Properties</title>
<shortdesc>The Java system properties available to the application.
</shortdesc>
<prolog>
<copyright>
<copyryear year=""></copyryear>
<copyrholder>
Copyright (c) 2023 IBM Corporation.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
</copyrholder>
</copyright>
</prolog>

<refbody>
<section>
<title>Motivation</title>
Sometimes it is useful to see the values of system properties which were available to the application.
</section>
<section>
<title>Arguments</title>
<simpletable>
<sthead>
<stentry>Argument</stentry>
<stentry>Description</stentry>
</sthead>
<strow>
<stentry>None</stentry>
<stentry>No arguments are supplied to this query</stentry>
</strow>
</simpletable>
</section>
<section id="result">
<title>Result</title>
<p>A table with three columns, one the Java collection holding the properties,
then the key and value. The key and value are Java Strings, so the resolved
value is shown.
The collection, key and value items are all Java objects, and the investigation can
be continued by using the context menu to select a further query to run on the item.
</p>
</section>
</refbody>
</reference>

0 comments on commit fbdc046

Please sign in to comment.