Select statements that contains CASE statements don't execute
authorSubhashini Sooriarachchi <subslk@netbeans.org>
Mon, 20 May 2013 13:13:42 +0530
changeset 405f949ce7a3fb1
parent 404 365292a542a4
child 406 077128e91ca3
Select statements that contains CASE statements don't execute
PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/PlsqlBlockFactory.java
PLSQL/Lexer/test/unit/data/case.upg
PLSQL/Lexer/test/unit/data/expected/case.upg.structure
PLSQL/Lexer/test/unit/src/org/netbeans/modules/plsql/lexer/PlsqlBlockFactoryTest.java
     1.1 --- a/PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/PlsqlBlockFactory.java	Fri May 17 15:31:50 2013 +0200
     1.2 +++ b/PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/PlsqlBlockFactory.java	Mon May 20 13:13:42 2013 +0530
     1.3 @@ -2170,8 +2170,8 @@
     1.4                          PlsqlBlock child = checkStatementBlock(tempToken, ts, immediateBlockHier);
     1.5                          if (child == null) {//If inner check seems to have failed need to continue this one
     1.6  
     1.7 -                            ts.move(offset);
     1.8 -                            ts.moveNext();
     1.9 +//                            ts.move(offset);
    1.10 +//                            ts.moveNext();
    1.11                          } else {
    1.12                              checkAndAddNew(child, parent, immediateBlockHier);
    1.13                          }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/PLSQL/Lexer/test/unit/data/case.upg	Mon May 20 13:13:42 2013 +0530
     2.3 @@ -0,0 +1,20 @@
     2.4 +SELECT
     2.5 +   CASE dummy 
     2.6 +   WHEN 'X' THEN
     2.7 +      'CASE inside SELECT'
     2.8 +   ELSE
     2.9 +      'Y'
    2.10 +   END xyz
    2.11 +FROM dual
    2.12 +/
    2.13 +
    2.14 +SELECT
    2.15 +   CASE dummy 
    2.16 +   WHEN 'A' THEN
    2.17 +      'AAA'
    2.18 +   ELSE
    2.19 +      (SELECT 'SELECT inside CASE' FROM dual)
    2.20 +   END xyz
    2.21 +FROM dual
    2.22 +/
    2.23 +   
    2.24 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/PLSQL/Lexer/test/unit/data/expected/case.upg.structure	Mon May 20 13:13:42 2013 +0530
     3.3 @@ -0,0 +1,6 @@
     3.4 +STATEMENT
     3.5 +CASE
     3.6 +CASE
     3.7 +STATEMENT
     3.8 +CASE
     3.9 +CASE
     4.1 --- a/PLSQL/Lexer/test/unit/src/org/netbeans/modules/plsql/lexer/PlsqlBlockFactoryTest.java	Fri May 17 15:31:50 2013 +0200
     4.2 +++ b/PLSQL/Lexer/test/unit/src/org/netbeans/modules/plsql/lexer/PlsqlBlockFactoryTest.java	Mon May 20 13:13:42 2013 +0530
     4.3 @@ -545,7 +545,30 @@
     4.4              }
     4.5          }
     4.6      }
     4.7 +    
     4.8 +    @Test
     4.9 +    public void testSimpleCaseStatement() throws IOException, BadLocationException {
    4.10 +        System.out.println("testSimpleCaseStatement");
    4.11 +        final String plsqlFileName = "case.upg";
    4.12 +        FileObject fileObject = fs.getRoot().createData(plsqlFileName);
    4.13 +        assertNotNull(fileObject);
    4.14 +        try {
    4.15 +            PlsqlBlockFactory blockFac = loadAsTmpFile(fileObject, plsqlFileName);
    4.16 +            assertNotNull(blockFac);
    4.17  
    4.18 +            List<PlsqlBlock> lstBlockFac = blockFac.getBlockHierarchy();
    4.19 +//         printHierarchy(lstBlockFac, "");
    4.20 + //          generateAssert(lstBlockFac, "lstBlockFac", "false");
    4.21 + //          assertEquals(2, lstBlockFac.size());
    4.22 +            processBlocks(plsqlFileName, lstBlockFac);
    4.23 +        } finally {
    4.24 +            if (fileObject != null) {
    4.25 +                fileObject.delete();
    4.26 +            }
    4.27 +        }
    4.28 +    }
    4.29 +    
    4.30 +   
    4.31      private PlsqlBlockFactory loadAsTmpFile(FileObject fileObj, String fileName) throws IOException, BadLocationException {
    4.32          InputStream inputStream = new FileInputStream(new File(getDataDir(), fileName));
    4.33          InputStreamReader indexReader = new InputStreamReader(inputStream);