Author: dgolovin
Date: 2012-08-21 20:49:07 -0400 (Tue, 21 Aug 2012)
New Revision: 43143
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/RelevanceCheckTest.java
Log:
asserts related to JavaCore were removed
code clean up, excessive null checks were removed
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-22
00:40:41 UTC (rev 43142)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java 2012-08-22
00:49:07 UTC (rev 43143)
@@ -22,30 +22,27 @@
boolean isIType = false;
public DefaultJavaRelevanceCheck(IJavaElement element) {
- if(element == null) return;
test1 = element.getElementName();
- if(element instanceof IMethod) {
- if((test1.startsWith("get") || test1.startsWith("set")) &&
test1.length() > 3) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (element instanceof IMethod) {
+ if(test1.length() > 3 && (test1.startsWith("get") ||
test1.startsWith("set"))) { //$NON-NLS-1$ //$NON-NLS-2$
test2 = test1.substring(3, 4).toLowerCase() + test1.substring(4);
test3 = test1.substring(3);
- } else if(test1.startsWith("is") && test1.length() > 2) {
//$NON-NLS-1$
+ } else if(test1.length() > 2 && test1.startsWith("is")) {
//$NON-NLS-1$
test2 = test1.substring(2, 3).toLowerCase() + test1.substring(3);
test3 = test1.substring(2);
}
- if(test3 != null && test3.equals(test2)) test3 = null;
- }else if(element instanceof IType){
+ if(test3.equals(test2)) {
+ test3 = null;
+ }
+ } else if (element instanceof IType){
isIType = true;
}
}
public boolean isRelevant(String content) {
- 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;
+ return isIType
+ || content.contains(test1)
+ || test2 != null && content.contains(test2)
+ || test3 != null && content.contains(test3);
}
-
}
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/RelevanceCheckTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/RelevanceCheckTest.java 2012-08-22
00:40:41 UTC (rev 43142)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/RelevanceCheckTest.java 2012-08-22
00:49:07 UTC (rev 43143)
@@ -50,7 +50,6 @@
IType bean = jp.findType("test.Bean");
IField f = bean.getField("myField");
- assertTrue("Field myField is not found", f != null && f.exists());
DefaultJavaRelevanceCheck check = new DefaultJavaRelevanceCheck(f);
assertTrue("'myField' should be relevant",
check.isRelevant("myField"));
@@ -58,7 +57,6 @@
assertFalse("'myFiel' should not be relevant",
check.isRelevant("myFiel"));
IMethod m = bean.getMethod("getProp1", new String[0]);
- assertTrue("Method getProp1 is not found", m != null && m.exists());
check = new DefaultJavaRelevanceCheck(m);
assertTrue("'prop1' should be relevant",
check.isRelevant("prop1"));
@@ -66,7 +64,6 @@
assertFalse("'getProp2' should not be relevant",
check.isRelevant("getProp2"));
m = bean.getMethod("isProp2", new String[0]);
- assertTrue("Method isProp2 is not found", m != null && m.exists());
check = new DefaultJavaRelevanceCheck(m);
assertTrue("'prop1' should be relevant",
check.isRelevant("prop2"));
@@ -74,7 +71,6 @@
assertFalse("'getProp3' should not be relevant",
check.isRelevant("isProp3"));
m = bean.getMethod("setProp3", new String[]{"QString;"});
- assertTrue("Method setProp3 is not found", m != null && m.exists());
check = new DefaultJavaRelevanceCheck(m);
assertTrue("'prop1' should be relevant",
check.isRelevant("prop3"));
Show replies by date