[jbosstools-commits] JBoss Tools SVN: r43226 - trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Aug 24 16:18:22 EDT 2012


Author: akazakov
Date: 2012-08-24 16:18:22 -0400 (Fri, 24 Aug 2012)
New Revision: 43226

Modified:
   trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java
Log:
Fixed NPE problem

Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java	2012-08-24 19:01:19 UTC (rev 43225)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java	2012-08-24 20:18:22 UTC (rev 43226)
@@ -23,26 +23,28 @@
 
 	public DefaultJavaRelevanceCheck(IJavaElement element) {
 		test1 = element.getElementName();
-		if (element instanceof IMethod) {
-			if(test1.length() > 3 && (test1.startsWith("get") || test1.startsWith("set"))) { //$NON-NLS-1$ //$NON-NLS-2$
+		if(element instanceof IMethod) {
+			if((test1.startsWith("get") || test1.startsWith("set")) && test1.length() > 3) { //$NON-NLS-1$ //$NON-NLS-2$
 				test2 = test1.substring(3, 4).toLowerCase() + test1.substring(4);
 				test3 = test1.substring(3);
-			} else if(test1.length() > 2 && test1.startsWith("is")) { //$NON-NLS-1$
+			} else if(test1.startsWith("is") && test1.length() > 2) { //$NON-NLS-1$
 				test2 = test1.substring(2, 3).toLowerCase() + test1.substring(3);
 				test3 = test1.substring(2);
 			}
-			if(test3.equals(test2)) {
-				test3 = null;
-			}
-		} else if (element instanceof IType){
+			if(test3 != null && test3.equals(test2)) test3 = null;
+		}else if(element instanceof IType){
 			isIType = true;
 		}
 	}
 	
 	public boolean isRelevant(String content) {
-		return isIType 
-				|| content.contains(test1) 
-				|| test2 != null && content.contains(test2)
-				|| test3 != null && content.contains(test3);
+		if(isIType)
+			return true;
+		
+		if(test1 != null && content.contains(test1)) return true;
+		if(test2 != null && content.contains(test2)) return true;
+		if(test3 != null && content.contains(test3)) return true;
+		return false;
 	}
+
 }



More information about the jbosstools-commits mailing list