DFAMap<ScopeVariable> (DFAMap<ScopeVariable> map, final Instruction instruction, final PsiElement element) { if (element != null && element.getParent() instanceof PyTypeDeclarationStatement) { return map; } String name = null; // Process readwrite instruction if (instruction instanceof ReadWriteInstruction rwInstruction) { if (rwInstruction.getAccess().isWriteAccess()) { name = ((ReadWriteInstruction)instruction).getName(); } else if (rwInstruction.getAccess().isDeleteAccess() && instruction.getElement() instanceof PyReferenceExpression) { map = map.asWritable(); map.remove(((ReadWriteInstruction)instruction).getName()); return map; } } // Processing PyFunction else if (element instanceof PyFunction){ name = ((PyFunction)element).getName(); } if (name == null){ return map; } final ScopeVariable variable = map.get(name); // Parameter case final PsiElement parameterScope = ScopeUtil.getParameterScope(element); if (parameterScope != null) { final ScopeVariable scopeVariable = new ScopeVariableImpl(name, true, element); map = map.asWritable(); map.put(name, scopeVariable); } // Local variable case else { final ScopeVariableImpl scopeVariable; final boolean isParameter = variable != null && variable.isParameter(); if (variable == null) { scopeVariable = new ScopeVariableImpl(name, isParameter, element); } else { scopeVariable = new ScopeVariableImpl(name, isParameter, variable.getDeclarations()); } map = map.asWritable(); map.put(name, scopeVariable); } return map; }