Replaces the text content of oldTextFile with newSource and leaves protected regions unchanged.
The filename=oldTextFile.getFilename() is solely used for delivering the right errors message on the console.
oldTextFile - text file context with a tuple of filename and its text content.
newSource - the new source text
new source with protected regions from old source = oldTextFile.getText()