fix to type inferencing of declared variables for code completion
added test case
revised test cases
minor code fixes
Merge pull request #2912 from aparajit-pratap/codeBlockBugFixes

Fix to type inferring of declared variables for code completion