Commits

Anonymous committed f495c7a

Resolves OGNL-64.

Comments (0)

Files changed (5)

   </component>
   <component name="ChangeListManager">
     <list default="true" name="Default" comment="">
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Model.java" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Copy.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/NullStringCatenationTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/NullStringCatenationTest.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Bean2.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Bean2.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTAdd.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTAdd.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/enhance/ExpressionCompiler.java" afterPath="$PROJECT_DIR$/src/java/ognl/enhance/ExpressionCompiler.java" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/OGNL.iws" afterPath="$PROJECT_DIR$/OGNL.iws" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/TestModel.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTAnd.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTAnd.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/PropertyTest.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/PropertyTest.java" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Entry.java" />
     </list>
   </component>
   <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
           <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
         </PATH_ELEMENT>
       </PATH>
+      <PATH>
+        <PATH_ELEMENT>
+          <option name="myItemId" value="OGNL" />
+          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+        </PATH_ELEMENT>
+        <PATH_ELEMENT>
+          <option name="myItemId" value="OGNL" />
+          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
+        </PATH_ELEMENT>
+        <PATH_ELEMENT>
+          <option name="myItemId" value="PsiDirectory:$PROJECT_DIR$" />
+          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+        </PATH_ELEMENT>
+      </PATH>
     </subPane>
   </component>
   <component name="ProjectReloadState">
     <option name="showLabels" value="true" />
   </component>
   <component name="RestoreUpdateTree" />
-  <component name="RunManager" selected="JUnit.PropertyTest">
-    <tempConfiguration default="false" name="PropertyTest" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
+  <component name="RunManager" selected="JUnit.NullStringCatenationTest">
+    <tempConfiguration default="false" name="NullStringCatenationTest" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
       <pattern value="org.ognl.test.*" />
       <module name="OGNL" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
       <option name="ALTERNATIVE_JRE_PATH" value="/usr/local/jdk1.6.0_02" />
       <option name="PACKAGE_NAME" value="org.ognl.test" />
-      <option name="MAIN_CLASS_NAME" value="org.ognl.test.PropertyTest" />
+      <option name="MAIN_CLASS_NAME" value="org.ognl.test.NullStringCatenationTest" />
       <option name="METHOD_NAME" value="" />
       <option name="TEST_OBJECT" value="class" />
       <option name="VM_PARAMETERS" value="" />
     <option name="PERFORM_EDIT_IN_BACKGROUND" value="true" />
     <option name="PERFORM_ADD_REMOVE_IN_BACKGROUND" value="true" />
     <option name="FORCE_NON_EMPTY_COMMENT" value="false" />
-    <option name="LAST_COMMIT_MESSAGE" value="Fixes OGNL-65. &amp;&amp; expressions needed () ." />
+    <option name="LAST_COMMIT_MESSAGE" value="Resolves OGNL-64." />
     <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
     <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="false" />
     <option name="REFORMAT_BEFORE_FILE_COMMIT" value="false" />
     <option name="UPDATE_GROUP_BY_PACKAGES" value="false" />
     <option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
     <option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
-    <MESSAGE value="Fixes OGNL-37. OgnlRuntime.getMethod() wasn't properly checking types using the new context.getCurrentType(). (need to kill off that old NodeType interface)" />
     <MESSAGE value="Resolves OGNL-41. Needed to add &quot;(&quot; around !org.ognl.StaticClass.method()&quot; block to make javassist stfu." />
     <MESSAGE value="Resolves OGNL-39. ASTTest wasn't handling the possibility of different object types being on the return stack of a ternary statement." />
     <MESSAGE value="Resolves OGNL-40. ASTAdd was improperly double escaping quoting characters." />
     <MESSAGE value="Added some more tests but unable to re-produce bug." />
     <MESSAGE value="Fixes OGNL-61. ExpressionNode's and string concatenation wasn't working out so well without ()s." />
     <MESSAGE value="Fixes OGNL-65. &amp;&amp; expressions needed () ." />
+    <MESSAGE value="Resolves OGNL-64." />
   </component>
   <component name="XPathView.XPathProjectComponent">
     <history />
     <option name="myLastEditedConfigurable" />
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/ProtectedInnerClassTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="82" column="28" selection-start="3437" selection-end="3437" vertical-scroll-proportion="0.64144737">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Indexed.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="100" column="5" selection-start="3211" selection-end="3211" vertical-scroll-proportion="0.8511513">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/IndexedPropertyTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="37" column="23" selection-start="1902" selection-end="1902" vertical-scroll-proportion="0.08634868">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/ExpressionNode.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="44" column="47" selection-start="2067" selection-end="2067" vertical-scroll-proportion="-0.2533784">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="38" column="6" selection-start="1921" selection-end="1921" vertical-scroll-proportion="0.15202703">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Root.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="222" column="19" selection-start="7159" selection-end="7159" vertical-scroll-proportion="0.4161184">
-          <folding />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Copy.java">
       <provider selected="true" editor-type-id="text-editor">
         <state line="9" column="5" selection-start="97" selection-end="97" vertical-scroll-proportion="0.11101974">
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTAdd.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="115" column="8" selection-start="4606" selection-end="4606" vertical-scroll-proportion="0.41216215">
-          <folding />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTOr.java">
       <provider selected="true" editor-type-id="text-editor">
         <state line="119" column="28" selection-start="4406" selection-end="4406" vertical-scroll-proportion="0.4391892">
         </state>
       </provider>
     </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/SimpleNode.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="43" column="0" selection-start="2008" selection-end="2008" vertical-scroll-proportion="0.18792711">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTProperty.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="44" column="13" selection-start="2095" selection-end="2095" vertical-scroll-proportion="0.15375854">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTAdd.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="262" column="21" selection-start="12097" selection-end="12097" vertical-scroll-proportion="0.6299342">
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
     <entry file="file://$PROJECT_DIR$/src/java/ognl/enhance/ExpressionCompiler.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="470" column="10" selection-start="16708" selection-end="16708" vertical-scroll-proportion="0.26891446">
+        <state line="472" column="10" selection-start="16732" selection-end="16732" vertical-scroll-proportion="0.40131578">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/NullStringCatenationTest.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="43" column="12" selection-start="2068" selection-end="2068" vertical-scroll-proportion="0.08634868">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/ArithmeticAndLogicalOperatorsTest.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="41" column="12" selection-start="1989" selection-end="1989" vertical-scroll-proportion="-0.17269737">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Root.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="270" column="44" selection-start="7854" selection-end="7854" vertical-scroll-proportion="0.4317434">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Bean2.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="42" column="0" selection-start="1957" selection-end="1957" vertical-scroll-proportion="0.16036184">
           <folding />
         </state>
       </provider>

src/java/ognl/ASTAdd.java

 package ognl;
 
 import ognl.enhance.ExpressionCompiler;
-import ognl.enhance.OrderedReturn;
 import ognl.enhance.UnsupportedCompilationException;
 
 import java.math.BigDecimal;
 
                         String rootExpr = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context);
                         //System.out.println("astadd rootExpr " + rootExpr + " and expr: " + expr);
-                        
+
                         if (!ASTProperty.class.isInstance(_children[i].jjtGetChild(0)) && rootExpr.endsWith(")") && expr.startsWith(")"))
                             expr = expr.substring(1, expr.length());
-                        
+
                         expr = rootExpr + expr;
                         context.setCurrentAccessor(context.getRoot().getClass());
                         
                             }
                         }
                     }
+
+                    result += expr;
+
+                    // hanlde addition for numeric types when applicable or just string concatenation
                     
-                    if (!OrderedReturn.class.isInstance(_parent)) {
-                        result += "(";
-                    }
-                    
-                    result += expr;
-                    
-                    if ((lastType == null || !String.class.isAssignableFrom(lastType.getGetterClass()))
-                            && NodeType.class.isInstance(_children[i]) 
+                    if ( (lastType == null || !String.class.isAssignableFrom(lastType.getGetterClass()))
                             && !ASTConst.class.isAssignableFrom(_children[i].getClass())
                             && !NumericExpression.class.isAssignableFrom(_children[i].getClass())) {
-                        
-                        NodeType ctype = (NodeType)_children[i];
-                        if (ctype.getGetterClass() != null 
-                                && Number.class.isAssignableFrom(ctype.getGetterClass())
-                                && !ASTMethod.class.isAssignableFrom(_children[i].getClass())) {
-                            
-                            if (ASTVarRef.class.isAssignableFrom(_children[i].getClass())
-                                    || ASTProperty.class.isInstance(_children[i]))
+
+                        if (context.getCurrentType() != null && Number.class.isAssignableFrom(context.getCurrentType())
+                                && !ASTMethod.class.isInstance(_children[i])) {
+
+                            if (ASTVarRef.class.isInstance(_children[i])
+                                    || ASTProperty.class.isInstance(_children[i])
+                                    || ASTChain.class.isInstance(_children[i]))
                                 result += ".";
-                            
-                            result += OgnlRuntime.getNumericValueGetter(ctype.getGetterClass());
-                            context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(ctype.getGetterClass()));
+
+                            result += OgnlRuntime.getNumericValueGetter(context.getCurrentType());
+                            context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentType()));
                         }
                     }
-                    
+
                     if (lastType != null) {
-                        context.setCurrentAccessor(lastType.getGetterClass());
-                    }
-
-                    if (!OrderedReturn.class.isInstance(_parent)) {
-                        result += ")";
+                        context.setCurrentAccessor(((NodeType)lastType).getGetterClass());
                     }
                 }
             }

src/java/ognl/enhance/ExpressionCompiler.java

         
         String castExpression = (String) context.get(PRE_CAST);
         
-        if (context.getCurrentType() == null || context.getCurrentType().isPrimitive() || Character.class.isAssignableFrom(context.getCurrentType())) {
+        if (context.getCurrentType() == null
+            || context.getCurrentType().isPrimitive() ||
+            Character.class.isAssignableFrom(context.getCurrentType())) {
             pre = pre + " ($w) (";
             post = post + ")";
         }

src/test/java/org/ognl/test/NullStringCatenationTest.java

             {ROOT, "'width:' + width + ';'", "width:238px;" },
             {ROOT, "theLong + '_' + index", "4_1"},
             {ROOT, "'javascript:' + @org.ognl.test.NullStringCatenationTest@MESSAGE", "javascript:blarney" },
-            {ROOT, "printDelivery ? '' : 'javascript:deliverySelected(' + property.carrier + ',' + currentDeliveryId + ')'", "" }
+            {ROOT, "printDelivery ? '' : 'javascript:deliverySelected(' + property.carrier + ',' + currentDeliveryId + ')'", "" },
+            {ROOT, "bean2.id + '_' + theInt", "1_6" }
     };
 
     /*

src/test/java/org/ognl/test/objects/Bean2.java

 
     private boolean _pageBreakAfter = false;
 
+    public Long getId()
+    {
+        return 1l;
+    }
+
     public Bean3 getBean3()
     {
         return bean3;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.