Author: vrubezhny
Date: 2009-06-11 14:36:44 -0400 (Thu, 11 Jun 2009)
New Revision: 15893
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
A number of methods are fixed: a number of NullPointerException-s are fixed.
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java 2009-06-11
18:24:05 UTC (rev 15892)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java 2009-06-11
18:36:44 UTC (rev 15893)
@@ -125,7 +125,13 @@
return false;
String objClassName = obj.getClass().getName();
+ if (objClassName == null)
+ return false;
+
for (Object o : collection) {
+ if (o == null || o.getClass() == null)
+ continue;
+
if (objClassName.equals(o.getClass().getName()))
return true;
}
@@ -234,12 +240,13 @@
protected Sorter createSorter() {
return new Sorter() {
public boolean compare(Object proposal1, Object proposal2) {
- ICompletionProposal p1 = (ICompletionProposal)proposal1;
- ICompletionProposal p2 = (ICompletionProposal)proposal2;
int pr1 = Integer.MIN_VALUE;
int pr2 = Integer.MIN_VALUE;
+ ICompletionProposal p1 = (ICompletionProposal)proposal1;
+ ICompletionProposal p2 = (ICompletionProposal)proposal2;
+
if (p1 instanceof IRelevanceCompletionProposal)
pr1 = ((IRelevanceCompletionProposal)p1).getRelevance();
@@ -248,8 +255,8 @@
if (pr1 == pr2) {
- String str1 = p1.getDisplayString(); //$NON-NLS-1$
- String str2 = p2.getDisplayString(); //$NON-NLS-1$
+ String str1 = (p1.getDisplayString() == null ? "" :
p1.getDisplayString()); //$NON-NLS-1$
+ String str2 = (p2.getDisplayString() == null ? "" :
p2.getDisplayString()); //$NON-NLS-1$
return str2.compareTo(str1) > 0;
}
Show replies by date