Unbreak most of the clang codecompletion test by passing file contents

Authored by mwolff on Jan 7 2018, 11:38 PM.

Description

Unbreak most of the clang codecompletion test by passing file contents

Summary:
Since the introduction of the CXUnsavedFile for the current document
in the code completion (commit f14a8fc9 from July 2017 [!!!]) the
unit tests where failing. The reason was that clang only saw empty
file contents when the code completion context was created with
no text. Previously, this used to fall-back to the actual file
on-disk. Nowadays, this fallback does not exist anymore, thus we
always have to pass the text in the unit tests. Do this and cleanup
the code by sharing more code in functions.

Reviewers: KDevelop

Subscribers: kdevelop-devel

Differential Revision: https://phabricator.kde.org/D9723