Set<String> (@NotNull List<Instruction> instructions, @NotNull ScopeOwner owner) { final Scope scope = ControlFlowCache.getScope(owner); final Set<String> globalWrites = new LinkedHashSet<>(); for (Instruction instruction : getWriteInstructions(instructions)) { if (instruction instanceof ReadWriteInstruction) { final String name = ((ReadWriteInstruction)instruction).getName(); final PsiElement element = instruction.getElement(); if (scope.isGlobal(name) || (owner instanceof PsiFile && element instanceof PsiNamedElement && isUsedOutside((PsiNamedElement)element, instructions))) { globalWrites.add(name); } } } return globalWrites; }