Commits

Jon Akhtar  committed 24bb28a Merge

We are going to release the fixes, since the bug is more annoying

  • Participants
  • Parent commits 1ef189e, 5ebfddd

Comments (0)

Files changed (21)

File .idea/misc.xml

     <file url="file://$PROJECT_DIR$/testdata/editing/EndInnerReturn_after.lua" />
     <file url="file://$PROJECT_DIR$/testdata/editing/EndOuterReturn.lua" />
     <file url="file://$PROJECT_DIR$/testdata/editing/EndOuterReturn_after.lua" />
+    <file url="file://$PROJECT_DIR$/testdata/editing/EnterAfterRightCurly1.lua" />
+    <file url="file://$PROJECT_DIR$/testdata/editing/EnterAfterRightCurly1_after.lua" />
     <file url="file://$PROJECT_DIR$/testdata/editing/FunctionArgInFunctionCall.lua" />
     <file url="file://$PROJECT_DIR$/testdata/editing/FunctionArgInFunctionCall_after.lua" />
     <file url="file://$PROJECT_DIR$/testdata/editing/LeftParenInFunctionDefinition.lua" />

File src/editor/annotator/LuaAnnotator.java

 //         e.getFieldKey().setLuaType(e.getFieldValue().getLuaType());
 //    }
 
-    @Override
-    public void visitDeclarationStatement(LuaDeclarationStatement e) {
-        super.visitDeclarationStatement(e);
-
-        if (e instanceof LuaLocalDefinitionStatement) {
-            LuaIdentifierList left = ((LuaLocalDefinitionStatement) e).getLeftExprs();
-            LuaExpressionList right = ((LuaLocalDefinitionStatement) e).getRightExprs();
-
-            if (right == null || right.count() == 0) return;
-
-            boolean allNil = true;
-            for (LuaExpression expr : right.getLuaExpressions())
-                if (!expr.getText().equals("nil")) {
-                    allNil = false;
-                    break;
-                }
-
-            if (allNil) {
-                int assignment = ((LuaLocalDefinitionStatement) e).getOperatorElement().getTextOffset();
-                final Annotation annotation =
-                        myHolder.createInfoAnnotation(new TextRange(assignment, right.getTextRange().getEndOffset()),
-                                null);
-                annotation.setTextAttributes(SyntaxHighlighterColors.LINE_COMMENT);
-            }
-        }
-    }
+//    @Override
+//    public void visitDeclarationStatement(LuaDeclarationStatement e) {
+//        super.visitDeclarationStatement(e);
+//
+//        if (e instanceof LuaLocalDefinitionStatement) {
+//            LuaIdentifierList left = ((LuaLocalDefinitionStatement) e).getLeftExprs();
+//            LuaExpressionList right = ((LuaLocalDefinitionStatement) e).getRightExprs();
+//
+//            if (right == null || right.count() == 0) return;
+//
+//            boolean allNil = true;
+//            for (LuaExpression expr : right.getLuaExpressions())
+//                if (!expr.getText().equals("nil")) {
+//                    allNil = false;
+//                    break;
+//                }
+//
+//            if (allNil) {
+//                int assignment = ((LuaLocalDefinitionStatement) e).getOperatorElement().getTextOffset();
+//
+//                myHolder.createWeakWarningAnnotation(new TextRange(assignment, right.getTextRange().getEndOffset()),
+//                                null);
+//            }
+//        }
+//    }
 
 
 

File src/editor/inspections/bugs/UnbalancedAssignmentInspection.java

             public void visitAssignment(LuaAssignmentStatement assign) {
                 super.visitAssignment(assign);
                 if (assign instanceof LuaLocalDefinitionStatement) {
-                    LuaIdentifierList left = ((LuaLocalDefinitionStatement) assign).getLeftExprs();
-                    LuaExpressionList right = ((LuaLocalDefinitionStatement) assign).getRightExprs();
+                    LuaIdentifierList left = assign.getLeftExprs();
+                    LuaExpressionList right = assign.getRightExprs();
 
-                    if (right == null)
-                        return;
+                    if (right == null || right.count() == 0) return;
 
                     if (ExpressionUtils.onlyNilExpressions(right))
                         return;
 
             if (tooManyExprs) {
                 for (int i = rightCount - leftCount; i > 0; i--) {
-                    identifierList.addAfter(LuaPsiElementFactory.getInstance(project).createExpressionFromText("_"), lastExpr);
+                    LuaExpression extraExpression = LuaPsiElementFactory.getInstance(project).createExpressionFromText("_");
+                    assert extraExpression != null : "Failed to create extra expression";
+                    identifierList.addAfter(extraExpression, lastExpr);
                 }
             } else {
                 for (int i = leftCount - rightCount; i > 0; i--) {
-                    expressionList.addAfter(LuaPsiElementFactory.getInstance(project).createExpressionFromText("nil"), lastExpr);
+                    LuaExpression nilExpression = LuaPsiElementFactory.getInstance(project).createExpressionFromText("nil");
+                    assert nilExpression != null : "Failed to create nil expression";
+                    expressionList.addAfter(nilExpression, lastExpr);
                 }
             }
         }

File src/editor/inspections/metrics/CyclomaticComplexityVisitor.java

 class CyclomaticComplexityVisitor extends LuaElementVisitor {
   private int complexity = 1;
 
-  public void visitElement(LuaPsiElement GrElement) {
+  public void visitLuaElement(LuaPsiElement GrElement) {
     int oldComplexity = 0;
     if (GrElement instanceof LuaFunctionDefinitionStatement) {
       oldComplexity = complexity;
     }
-    super.visitElement(GrElement);
+    super.visitLuaElement(GrElement);
 
     if (GrElement instanceof LuaFunctionDefinitionStatement) {
       complexity = oldComplexity;

File src/editor/inspections/metrics/StatementCountVisitor.java

 class StatementCountVisitor extends LuaElementVisitor {
   private int statementCount = 0;
 
-//  public void visitElement(LuaPsiElement element) {
+//  public void visitLuaElement(LuaPsiElement element) {
 //    int oldCount = 0;
 //    if (element instanceof LuaFunctionDefinitionStatement) {
 //      oldCount = statementCount;
 //    }
-//    super.visitElement(element);
+//    super.visitLuaElement(element);
 //
 //    if (element instanceof LuaFunctionDefinitionStatement) {
 //      statementCount = oldCount;

File src/editor/inspections/usage/UnusedDefInspection.java

 import com.sylvanaar.idea.Lua.lang.psi.dataFlow.DFAEngine;
 import com.sylvanaar.idea.Lua.lang.psi.dataFlow.reachingDefs.ReachingDefinitionsDfaInstance;
 import com.sylvanaar.idea.Lua.lang.psi.dataFlow.reachingDefs.ReachingDefinitionsSemilattice;
+import com.sylvanaar.idea.Lua.lang.psi.lists.LuaIdentifierList;
 import com.sylvanaar.idea.Lua.lang.psi.statements.LuaAssignmentStatement;
 import com.sylvanaar.idea.Lua.lang.psi.symbols.LuaLocal;
 import com.sylvanaar.idea.Lua.lang.psi.symbols.LuaParameter;
                   PsiElement toHighlight = null;
                   if (element instanceof LuaReferenceElement) {
                       PsiElement parent = element.getParent();
+                      if (parent instanceof LuaIdentifierList)
+                          parent = parent.getParent();
+
                       if (parent instanceof LuaAssignmentStatement) {
-                          toHighlight = ((LuaAssignmentStatement) parent).getLeftExprs();
+                          toHighlight = element;
                       }
                   } else if (element instanceof LuaSymbol) {
                       toHighlight = ((LuaSymbol) element);//.getNamedElement();

File src/lang/parser/kahlua/KahluaParser.java

 
             lookahead();
             boolean def = lookahead != DOT && lookahead != LBRACK;
-            this.primaryexp(nv.v, def?DEC_GL:DEC_REF);
+            this.primaryexp(nv.v, def?DEC_G:DEC_REF);
           
             if (nv.v.k == VLOCAL)
                 this.check_conflict(lh, nv.v);
 
         PsiBuilder.Marker outer = builder.mark();
 
-        this.primaryexp(v.v, (isassign&&!isCompound&&isComplete)?DEC_GL:DEC_REF);
+        this.primaryexp(v.v, (isassign&&!isCompound&&isComplete)?DEC_G:DEC_REF);
 
         if (v.v.k == VCALL) /* stat -> func */ {
             if (isassign)

File src/lang/psi/controlFlow/impl/ControlFlowBuilder.java

 
     @Override
     public void visitBlock(LuaBlock block) {
+        final InstructionImpl instruction = startNode(block);
         super.visitBlock(block);
+        addPendingEdge(block, myHead);
+        finishNode(instruction);
     }
 
     @Override
     public void visitDoStatement(LuaDoStatement e) {
         final LuaBlock body = e.getBlock();
         if (body != null) {
-//            final InstructionImpl instruction = startNode(body);
+
             body.accept(this);
-//            addPendingEdge(body, myHead);
-//            finishNode(instruction);
+
         }
     }
 
     public void visitReturnStatement(LuaReturnStatement returnStatement) {
         boolean isNodeNeeded = myHead == null || myHead.getElement() != returnStatement;
         final LuaExpression value = returnStatement.getReturnValue();
-        if (value != null) {
-            value.accept(this);
-        }
+        acceptExpression(value);
 
         if (isNodeNeeded) {
             InstructionImpl retInsn = startNode(returnStatement);
         finishNode(funcInstruction);
     }
 
+
+    @Override
+    public void visitDeclarationStatement(LuaDeclarationStatement e) {
+        super.visitDeclarationStatement(e);
+    }
+
     @Override
     public void visitAssignment(LuaAssignmentStatement e) {
         LuaExpressionList rValues = e.getRightExprs();
-
-
-        if (rValues != null) {
-            rValues.accept(this);
-        }
+        acceptExpressionList(rValues);
         for (LuaAssignment assignment : e.getAssignments()) {
             assignment.getSymbol().accept(this);
             addNode(new ReadWriteVariableInstructionImpl(assignment.getSymbol(), myInstructionNumber++, true));
     }
 
     @Override
+    public void visitFunctionCall(LuaFunctionCallExpression e) {
+        acceptExpression(e.getFunctionNameElement());
+        acceptExpressionList(e.getArgumentList());
+    }
+
+    @Override
     public void visitParenthesizedExpression(LuaParenthesizedExpression expression) {
-        final LuaExpression operand = expression.getOperand();
-        if (operand != null) {
-            operand.accept(this);
-        }
+        acceptExpression(expression.getOperand());
     }
 
     @Override
         }
     }
 
-//    @Override
+    @Override
+    public void visitBinaryExpression(LuaBinaryExpression e) {
+        acceptExpression(e.getLeftOperand());
+        acceptExpression(e.getRightOperand());
+    }
+
+    private void acceptExpressionList(LuaExpressionList operand) {
+        if (operand != null) {
+            for (LuaExpression expression : operand.getLuaExpressions()) {
+                 expression.accept(this);
+            }
+        }
+    }
+    private void acceptExpression(LuaExpression operand) {
+        if (operand != null) {
+            operand.accept(this);
+        }
+    }
+
+    //    @Override
 //    public void visitCompoundReference(LuaCompoundReferenceElementImpl e) {
 //        su
 //    }
 
         final LuaBlock thenBranch = ifStatement.getIfBlock();
         if (thenBranch != null) {
-            if (condition != null) {
-                condition.accept(this);
-            }
+            acceptExpression((LuaExpression) condition.getFirstChild());
             thenBranch.accept(this);
             addPendingEdge(ifStatement, myHead);
             interruptFlow();
         final LuaBlock body = e.getBlock();
         final InstructionImpl instruction = body != null ? startNode(body) : null;
 
-        if (start != null) {
-            start.accept(this);
-        }
-        if (index != null) {
-            index.accept(this);
-        }
-        if (end != null) {
-            end.accept(this);
-        }
-        if (step != null) {
-            step.accept(this);
-        }
+        acceptExpression(start);
+        acceptExpression(index);
+        acceptExpression(end);
+        acceptExpression(step);
         if (body != null) {
             body.accept(this);
         }
         final LuaBlock body = e.getBlock();
         final InstructionImpl instruction = body != null ? startNode(body) : null;
 
-        if (inclause != null) {
-            inclause.accept(this);
-        }
+        acceptExpression(inclause);
 
         for (LuaExpression variable : indicies) {
             variable.accept(this);
     public void visitWhileStatement(LuaWhileStatement whileStatement) {
         final InstructionImpl instruction = startNode(whileStatement);
         final LuaConditionalExpression condition = whileStatement.getCondition();
-        if (condition != null) {
-            condition.accept(this);
-        }
+        acceptExpression(condition);
         if (!alwaysTrue(condition)) {
             addPendingEdge(whileStatement, myHead); //break
         }

File src/lang/psi/controlFlow/impl/ReadWriteVariableInstructionImpl.java

   public String myName;
   LuaSymbol mySymbol;
 
-  ReadWriteVariableInstructionImpl(String varName, LuaSymbol element, int num, boolean isWrite) {
-    super(element, num);
-
-    myName = varName;
-    myIsWrite = isWrite;
-  }
+//  ReadWriteVariableInstructionImpl(String varName, LuaSymbol element, int num, boolean isWrite) {
+//    super(element, num);
+//
+//    myName = varName;
+//    myIsWrite = isWrite;
+//  }
 
   ReadWriteVariableInstructionImpl(LuaSymbol variable, int num, boolean isWrite) {
     super(variable, num);
     super(refExpr, num);
     myName = refExpr.getName();
     myIsWrite = isWrite;
-    mySymbol = (LuaSymbol) refExpr.getElement();
+    mySymbol = (LuaSymbol) refExpr.resolve();
   }
 
   public String getVariableName() {
+
     return myName;
   }
 
         }
 
 
-    return String.format("%s %s %s", isWrite() ? "WRITE" : "READ", kind, myName);
+    return String.format("%s %s %s", isWrite() ? "WRITE" : "READ", kind, getVariableName());
   }
 }

File src/lang/psi/expressions/LuaConditionalExpression.java

  * Time: 3:44:02 AM
  */
 public interface LuaConditionalExpression extends LuaExpression {
+    LuaExpression getOperand();
 }

File src/lang/psi/impl/LuaPsiElementImpl.java

 
     @Override
     public void accept(LuaElementVisitor visitor) {
-        visitor.visitElement(this);
+        visitor.visitLuaElement(this);
     }
 
     @Override
     @Override
     public void accept(@NotNull PsiElementVisitor visitor) {
         if (visitor instanceof LuaElementVisitor) {
-            ((LuaElementVisitor) visitor).visitElement(this);
+            ((LuaElementVisitor) visitor).visitLuaElement(this);
         } else {
             visitor.visitElement(this);
         }

File src/lang/psi/impl/LuaPsiFileImpl.java

     }
 
     public void accept(LuaElementVisitor visitor) {
-        visitor.visitFile(this);
+        visitor.visitLuaFile(this);
     }
 
     public void acceptChildren(LuaElementVisitor visitor) {
             }
         };
 
-        v.visitElement(this);
+        v.visitLuaElement(this);
 
         return decls.toArray(new Assignable[decls.size()]);
     }
                 new ArrayList<LuaStatementElement>();
 
         LuaElementVisitor v = new LuaRecursiveElementVisitor() {
-            public void visitElement(LuaPsiElement e) {
-                super.visitElement(e);
+            public void visitLuaElement(LuaPsiElement e) {
+                super.visitLuaElement(e);
                 if (e instanceof LuaStatementElement)
                     stats.add((LuaStatementElement) e);
             }
         };
 
-        v.visitElement(this);
+        v.visitLuaElement(this);
 
         return stats.toArray(new LuaStatementElement[stats.size()]);
     }
         final LuaPsiManager m = LuaPsiManager.getInstance(getProject());
         LuaElementVisitor v = new LuaRecursiveElementVisitor() {
             @Override
-            public void visitElement(LuaPsiElement element) {
-                super.visitElement(element);
+            public void visitLuaElement(LuaPsiElement element) {
+                super.visitLuaElement(element);
                 if (element instanceof InferenceCapable && element != LuaPsiFileImpl.this)
                     m.queueInferences((InferenceCapable) element);
             }
                         }
                     };
 
-                    v.visitElement(LuaPsiFileImpl.this);
+                    v.visitLuaElement(LuaPsiFileImpl.this);
 
                     return funcs.toArray(new LuaFunctionDefinition[funcs.size()]);
         }

File src/lang/psi/impl/LuaStubElementBase.java

     }
 
     public void accept(LuaElementVisitor visitor) {
-        visitor.visitElement(this);
+        visitor.visitLuaElement(this);
     }
 
     public void acceptChildren(LuaElementVisitor visitor) {

File src/lang/psi/impl/expressions/LuaConditionalExpressionImpl.java

 
 import com.intellij.lang.ASTNode;
 import com.intellij.psi.PsiElement;
+import com.sylvanaar.idea.Lua.lang.parser.LuaElementTypes;
 import com.sylvanaar.idea.Lua.lang.psi.expressions.LuaConditionalExpression;
 import com.sylvanaar.idea.Lua.lang.psi.expressions.LuaExpression;
 import com.sylvanaar.idea.Lua.lang.psi.types.LuaPrimitiveType;
         return "Conditional: " + super.toString();
     }
 
+    @Override
+    public LuaExpression getOperand() {
+        final PsiElement element = getFirstChild();
+
+        assert element instanceof LuaExpression;
+
+        return (LuaExpression) element;
+    }
 
     @NotNull
     @Override
 
     @Override
     public Object evaluate() {
-        final PsiElement element = getFirstChild();
-
-        assert element instanceof LuaExpression;
-
-        Object value = ((LuaExpression) element).evaluate();
+        Object value = getOperand().evaluate();
 
         if (value == null)
             return value;

File src/lang/psi/impl/lists/LuaExpressionListImpl.java

 import com.sylvanaar.idea.Lua.lang.psi.types.LuaList;
 import com.sylvanaar.idea.Lua.lang.psi.types.LuaPrimitiveType;
 import com.sylvanaar.idea.Lua.lang.psi.types.LuaType;
+import com.sylvanaar.idea.Lua.lang.psi.visitor.LuaElementVisitor;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Arrays;
         return Arrays.asList(findChildrenByClass(LuaExpression.class));
     }
 
+
+    @Override
+    public void accept(LuaElementVisitor visitor) {
+        for (LuaExpression expression : getLuaExpressions()) {
+            expression.accept(visitor);
+        }
+    }
+
     public String toString() {
         return "Expression List (Count " + count() + ")";
     }

File src/lang/psi/visitor/LuaElementVisitor.java

 
 package com.sylvanaar.idea.Lua.lang.psi.visitor;
 
-import com.intellij.openapi.progress.*;
 import com.intellij.psi.*;
 import com.sylvanaar.idea.Lua.lang.luadoc.psi.api.*;
 import com.sylvanaar.idea.Lua.lang.psi.*;
  */
 
 public class LuaElementVisitor extends PsiElementVisitor {
-    public void visitElement(LuaPsiElement element) {
-        ProgressIndicatorProvider.checkCanceled();
+    public void visitLuaElement(LuaPsiElement element) {
+        visitElement(element);
     }
 
 //    @Override
 //        if (e instanceof LuaPsiFile)
 //            visitFile((LuaPsiFile)e);
 //        else
-//            visitElement(e);
+//            visitLuaElement(e);
 //    }
 //
-//    public void visitFile(LuaPsiFile e) {
-//            visitElement(e);
-//    }
+    public void visitLuaFile(LuaPsiFile e) {
+        visitBlock(e);
+    }
 
 
     public void visitFunctionDef(LuaFunctionDefinitionStatement e) {
     }
 
     public void visitIdentifier(LuaIdentifier e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitStatement(LuaStatementElement e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitNumericForStatement(LuaNumericForStatement e) {
     }
 
     public void visitBlock(LuaBlock e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitGenericForStatement(LuaGenericForStatement e) {
     }
 
     public void visitParameter(LuaParameter e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitReturnStatement(LuaReturnStatement e) {
     }
 
     public void visitReferenceElement(LuaReferenceElement e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitKeyword(LuaPsiKeywordImpl e) {
         if (e instanceof LuaReferenceElement)
             visitReferenceElement((LuaReferenceElement) e);
         else
-            visitElement(e);
+            visitLuaElement(e);
     }
 
     public void visitLiteralExpression(LuaLiteralExpression e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitTableConstructor(LuaTableConstructor e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitUnaryExpression(LuaUnaryExpression e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitBinaryExpression(LuaBinaryExpression e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitFunctionCall(LuaFunctionCallExpression e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitBreakStatement(LuaBreakStatement e) {
     }
 
     public void visitCompoundIdentifier(LuaCompoundIdentifier e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitCompoundReference(LuaCompoundReferenceElementImpl e) {
     }
 
     public void visitDocComment(LuaDocPsiElement e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitAnonymousFunction(LuaAnonymousFunctionExpression e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitDocReference(LuaDocReferenceElement e) {
     }
 
     public void visitKeyValueInitializer(LuaKeyValueInitializer e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitParenthesizedExpression(LuaParenthesizedExpression e) {
-        visitElement(e);
+        visitLuaElement(e);
     }
 
     public void visitReferenceElement_NoRecurse(LuaPsiDeclarationReferenceElementImpl e) {

File src/lang/psi/visitor/LuaRecursiveElementVisitor.java

  */
 package com.sylvanaar.idea.Lua.lang.psi.visitor;
 
+import com.intellij.openapi.progress.ProgressIndicatorProvider;
+import com.intellij.psi.PsiElement;
 import com.sylvanaar.idea.Lua.lang.psi.LuaPsiElement;
 
 /**
  * @author ven
  */
 public abstract class LuaRecursiveElementVisitor extends LuaElementVisitor {
-  @Override
-  public void visitElement(LuaPsiElement element) {
-    super.visitElement(element);
-    element.acceptChildren(this);
-  }
-
-
-
+    @Override
+    public void visitElement(final PsiElement element) {
+        ProgressIndicatorProvider.checkCanceled();
+        element.acceptChildren(this);
+    }
 }

File test/lang/parser/StatementsParsingTests.java

   public void testDeclaration$decl3() throws Throwable { doTest(); }
   public void testDeclaration$decl4() throws Throwable { doTest(); }
 
+
+//  public void testAssignment$reassigned1() throws Throwable { doTest(); }
+
 }

File test/lang/resolve/ResolveTests.java

 
 
   public void testDeclaration$simpleLocal() throws Throwable { doTest(); }
+  public void testDeclaration$reassignedLocal() throws Throwable { doTest(); }
 }

File testdata/parsing/lua/statements/assignment/reassigned1.lua.test

+local a = 1
+do
+    a =  2
+end
+return a
+-----
+Lua script: test.lua(0,38)
+  Parameter: ...(0,0)
+    <empty list>
+  Local Declaration With Assignment Statement local a = 1(0,11)
+    PsiElement(local)('local')(0,5)
+    PsiWhiteSpace(' ')(5,6)
+    Identifier List (Count 1)(6,7)
+      Local Decl: a(6,7)
+        PsiElement(identifier)('a')(6,7)
+    PsiWhiteSpace(' ')(7,8)
+    PsiElement(=)('=')(8,9)
+    PsiWhiteSpace(' ')(9,10)
+    Expression List (Count 1)(10,11)
+      Literal:1(10,11)
+        PsiElement(number)('1')(10,11)
+  PsiWhiteSpace('\n')(11,12)
+  Do Block(12,29)
+    PsiElement(do)('do')(12,14)
+    PsiWhiteSpace('\n    ')(14,19)
+    Block(19,25)
+      Assignment Statement a =  2(19,25)
+        Identifier List (Count 1)(19,20)
+          Reference: a(19,20)
+            Local Decl: a(19,20)
+              PsiElement(identifier)('a')(19,20)
+        PsiWhiteSpace(' ')(20,21)
+        PsiElement(=)('=')(21,22)
+        PsiWhiteSpace('  ')(22,24)
+        Expression List (Count 1)(24,25)
+          Literal:2(24,25)
+            PsiElement(number)('2')(24,25)
+    PsiWhiteSpace('\n')(25,26)
+    PsiElement(end)('end')(26,29)
+  PsiWhiteSpace('\n')(29,30)
+  Return statement(30,38)
+    PsiElement(return)('return')(30,36)
+    PsiWhiteSpace(' ')(36,37)
+    Expression List (Count 1)(37,38)
+      Reference: a(37,38)
+        Local: a(37,38)
+          PsiElement(identifier)('a')(37,38)

File testdata/resolve/declaration/reassignedLocal.lua

+local a = 1
+do
+    a =  2
+end
+return <caret>a