protected ResourceFile createTempScriptFile(String name, String pkg) throws IOException {
		if (name.length() > 50) {
			// too long and the script manager complains
			name = name.substring(name.length() - 50);
		}

		File scriptDir = null;
		if (pkg != null) {
			scriptDir = new File(GhidraScriptUtil.USER_SCRIPTS_DIR + "/" + pkg.replace(".", "/"));
			scriptDir.mkdirs();
			scriptDir.deleteOnExit();
		}
		else {
			scriptDir = new File(GhidraScriptUtil.USER_SCRIPTS_DIR);
		}

		File tempFile = File.createTempFile(name, ".java", scriptDir);
		tempFile.deleteOnExit();
		return new ResourceFile(tempFile);
	}
This call will:
-open the file in an editor
-update the text area and buffer fields of this test
@param file the file to open
Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/script/AbstractGhidraScriptMgrPluginTest.java