Fix namespace detection in files with declare