Author: dgolovin
Date: 2011-12-19 19:42:06 -0500 (Mon, 19 Dec 2011)
New Revision: 37442
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XPCOM.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeExpressionBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunction.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionAttrPresent.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionTagString.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionTagText.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
Log:
Fix for PMD violations
1. Eception processing
2. Memory consumption and performance
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -535,15 +535,11 @@
}
public void completed(ProgressEvent event) {
- try {
- if (MozillaEditor.this.getXulRunnerEditor().getWebBrowser() != null) {
- //process this code only in case when editor hasn't been disposed,
- //see
https://jira.jboss.org/browse/JBIDE-6373
- MozillaEditor.this.onLoadWindow();
- xulRunnerEditor.getBrowser().removeProgressListener(this);
- }
- } catch (Exception ex) {
- showXulRunnerError(cmpEd, ex);
+ if (MozillaEditor.this.getXulRunnerEditor().getWebBrowser() != null) {
+ //process this code only in case when editor hasn't been disposed,
+ //see
https://jira.jboss.org/browse/JBIDE-6373
+ MozillaEditor.this.onLoadWindow();
+ xulRunnerEditor.getBrowser().removeProgressListener(this);
}
}
});
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeExpressionBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeExpressionBuilder.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeExpressionBuilder.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -218,11 +218,10 @@
function.setParameters(params.toArray(new VpeOperand[params.size()]));
}
String[] signatures = function.getSignatures();
- if (signatures != null) {
- for (int i = 0; i < signatures.length; i++) {
+ for (int i = 0; i < signatures.length; i++) {
dependencySet.add(signatures[i]);
- }
}
+
return function;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunction.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunction.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunction.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -10,11 +10,15 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template.expression;
+import java.util.Arrays;
+
import org.jboss.tools.vpe.messages.VpeUIMessages;
public abstract class VpeFunction extends VpeOperand {
+ private static final String[] EMPTY_SIGNS = new String[0];
private VpeOperand[] paramertes;
+ private String[] signatures = EMPTY_SIGNS;
VpeFunction() {
}
@@ -36,6 +40,6 @@
}
String[] getSignatures() {
- return null;
+ return signatures;
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionAttrPresent.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionAttrPresent.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionAttrPresent.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -29,9 +29,10 @@
}
return new VpeValue(present);
}
-
+
+ public static final String[] SIGNATURE_ANY_ATTR_ARAY = new String[]
{VpeExpressionBuilder.SIGNATURE_ANY_ATTR};
@Override
String[] getSignatures() {
- return new String[] {VpeExpressionBuilder.SIGNATURE_ANY_ATTR};
+ return SIGNATURE_ANY_ATTR_ARAY;
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -29,7 +29,7 @@
@Override
String[] getSignatures() {
- return new String[] {VpeExpressionBuilder.SIGNATURE_ANY_ATTR};
+ return VpeFunctionAttrPresent.SIGNATURE_ANY_ATTR_ARAY;
}
@Override
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionTagString.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionTagString.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionTagString.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -35,6 +35,6 @@
}
String[] getSignatures() {
- return new String[] {VpeExpressionBuilder.SIGNATURE_ANY_ATTR};
+ return VpeFunctionAttrPresent.SIGNATURE_ANY_ATTR_ARAY;
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionTagText.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionTagText.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionTagText.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -47,6 +47,6 @@
}
String[] getSignatures() {
- return new String[] {VpeExpressionBuilder.SIGNATURE_ANY_ATTR};
+ return VpeFunctionAttrPresent.SIGNATURE_ANY_ATTR_ARAY;
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -149,46 +149,42 @@
*/
public static Node getNodeByXPath(Document document, String xPath) {
Node currentNode = document;
- try {
- String[] nodeNames = xPath.split("/"); //$NON-NLS-1$
-
- // begin from 1 to skip the first element which is empty
- for (int i = 1; i < nodeNames.length; i++) {
- String nodeName = nodeNames[i];
- if (nodeName.charAt(0) != '@') {
- currentNode = currentNode.getFirstChild();
- if (nodeName.charAt(nodeName.length() - 1) != ']') {
- while (currentNode.getNodeType() != Node.ELEMENT_NODE
- || !currentNode.getNodeName().equals(nodeName)) {
- currentNode = currentNode.getNextSibling();
- }
- } else {
- int openingBracketIndex = nodeName.lastIndexOf('[');
- String stringPosition = nodeName.substring(
- openingBracketIndex + 1,
- nodeName.length() - 1);
- nodeName = nodeName.substring(0, openingBracketIndex);
-
- int position = Integer.parseInt(stringPosition);
- int curPosition = 0;
- while (true) {
- if (currentNode.getNodeType() == Node.ELEMENT_NODE
- && currentNode.getNodeName().equals(nodeName)) {
- ++curPosition;
- if (curPosition == position) {
- break;
- }
+ String[] nodeNames = xPath.split("/"); //$NON-NLS-1$
+
+ // begin from 1 to skip the first element which is empty
+ for (int i = 1; i < nodeNames.length; i++) {
+ String nodeName = nodeNames[i];
+ if (nodeName.charAt(0) != '@') {
+ currentNode = currentNode.getFirstChild();
+ if (nodeName.charAt(nodeName.length() - 1) != ']') {
+ while (currentNode.getNodeType() != Node.ELEMENT_NODE
+ || !currentNode.getNodeName().equals(nodeName)) {
+ currentNode = currentNode.getNextSibling();
+ }
+ } else {
+ int openingBracketIndex = nodeName.lastIndexOf('[');
+ String stringPosition = nodeName.substring(
+ openingBracketIndex + 1,
+ nodeName.length() - 1);
+ nodeName = nodeName.substring(0, openingBracketIndex);
+
+ int position = Integer.parseInt(stringPosition);
+ int curPosition = 0;
+ while (true) {
+ if (currentNode.getNodeType() == Node.ELEMENT_NODE
+ && currentNode.getNodeName().equals(nodeName)) {
+ ++curPosition;
+ if (curPosition == position) {
+ break;
}
- currentNode = currentNode.getNextSibling();
}
+ currentNode = currentNode.getNextSibling();
}
- } else {
- String attributeName = nodeName.substring(1, nodeName.length());
- currentNode = currentNode.getAttributes().getNamedItem(attributeName);
}
+ } else {
+ String attributeName = nodeName.substring(1, nodeName.length());
+ currentNode = currentNode.getAttributes().getNamedItem(attributeName);
}
- } catch (Exception e) {
- return null;
}
return currentNode;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XPCOM.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XPCOM.java 2011-12-20
00:36:33 UTC (rev 37441)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XPCOM.java 2011-12-20
00:42:06 UTC (rev 37442)
@@ -104,11 +104,13 @@
String interfaceId = interfaceIdByType.get(type);
if (interfaceId == null) {
String interfaceIdFieldName = getInterfaceIdFieldName(type);
- try {
- interfaceId = (String) type.getField(interfaceIdFieldName).get(null);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ try {
+ interfaceId = (String) type.getField(interfaceIdFieldName).get(null);
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
interfaceIdByType.put(type, interfaceId);
}
return interfaceId;