Commit edae3130 authored by Milian Wolff's avatar Milian Wolff

Cleanup code and remove compiler warnings.

parent c2692bfc
......@@ -306,7 +306,6 @@ bool isValidCompletionIdentifier(const QualifiedIdentifier& identifier)
*/
bool isValidSpecialCompletionIdentifier(const QualifiedIdentifier& identifier)
{
const int count = identifier.count();
if (identifier.count() < 2) {
return false;
}
......@@ -380,7 +379,7 @@ bool ClangCodeCompletionContext::isValidPosition() const
return true;
}
QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(bool& abort, bool fullCompletion)
QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(bool& abort, bool /*fullCompletion*/)
{
if (!m_valid || !m_duContext || !m_results) {
return {};
......@@ -402,6 +401,10 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(boo
kDebug() << "Clang found" << m_results->NumResults << "completion results";
for (uint i = 0; i < m_results->NumResults; ++i) {
if (abort) {
return {};
}
auto result = m_results->Results[i];
const auto availability = clang_getCompletionAvailability(result.CompletionString);
......@@ -560,6 +563,10 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(boo
}
}
if (abort) {
return {};
}
addOverwritableItems();
addImplementationHelperItems();
eventuallyAddGroup(i18n("Special"), 700, specialItems);
......
......@@ -38,6 +38,7 @@ using namespace KDevelop;
namespace {
// TODO: Use it once clang_getInclusions _does_ returns imports on reparse with CXTranslationUnit_PrecompiledPreamble flag.
// void visitInclusions(CXFile file, CXSourceLocation* stack, unsigned stackDepth, CXClientData d)
// {
// if (stackDepth) {
......@@ -113,11 +114,11 @@ CXChildVisitResult visitImportsInFile(CXCursor cursor, CXCursor, CXClientData da
}
/// @return environment for given @p file i.e. the same environment, but only with include directories used by this file.
ClangParsingEnvironment environmentForFile(CXFile file, ParseSession session)
ClangParsingEnvironment environmentForFile(CXFile file, const ParseSession& session)
{
ImportsForFile importsForFile;
importsForFile.file = file;
auto sessionEnvironment = session.data()->environment();
auto sessionEnvironment = session.environment();
if (!clang_visitChildren(clang_getTranslationUnitCursor(session.unit()), &visitImportsInFile, &importsForFile)) {
// Add only used include directories into the environment.
......
......@@ -199,11 +199,6 @@ void ParseSessionData::setUnit(CXTranslationUnit unit, const char* fileName)
m_file = clang_getFile(m_unit, fileName);
}
ClangParsingEnvironment ParseSessionData::environment() const
{
return m_environment;
}
ParseSession::ParseSession(ParseSessionData::Ptr data)
: d(data)
{
......@@ -330,3 +325,8 @@ bool ParseSession::reparse(const QByteArray& contents, const ClangParsingEnviron
return false;
}
}
ClangParsingEnvironment ParseSession::environment() const
{
return d->m_environment;
}
......@@ -64,8 +64,6 @@ public:
~ParseSessionData();
ClangParsingEnvironment environment() const;
private:
friend class ParseSession;
......@@ -121,7 +119,7 @@ public:
bool reparse(const QByteArray& contents, const ClangParsingEnvironment& environment);
using TopAstNode = CXTranslationUnit;
ClangParsingEnvironment environment() const;
private:
ParseSessionData::Ptr d;
......
......@@ -529,8 +529,8 @@ void TestDUChain::testParsingEnvironment()
auto top = file.topContext();
QVERIFY(top);
auto sessionData = ParseSessionData::Ptr::dynamicCast(top->ast());
QVERIFY(sessionData);
auto session = ParseSession(ParseSessionData::Ptr::dynamicCast(top->ast()));
QVERIFY(session.data());
auto envFile = KSharedPtr<ClangParsingEnvironmentFile>::dynamicCast(file.topContext()->parsingEnvironmentFile());
......@@ -542,7 +542,7 @@ void TestDUChain::testParsingEnvironment()
ClangParsingEnvironment env;
{
ClangParsingEnvironment environment = sessionData->environment();
ClangParsingEnvironment environment = session.environment();
QCOMPARE(env.projectKnown(), false);
// We don't need system include directories as our test file doesn't use it.
env.addDefines(environment.defines());
......@@ -581,7 +581,7 @@ void TestDUChain::testParsingEnvironment()
QVERIFY(!envFile->needsUpdate(&env));
indexed = top->indexed();
lastEnv = sessionData->environment();
lastEnv = session.environment();
qDebug() << top->url();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment