Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/cpp/service/include/service/cppservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ class CppServiceHandler : virtual public LanguageServiceIf

std::shared_ptr<std::string> _datadir;
const cc::webserver::ServerContext& _context;

std::string toShortDiagnosticString(const model::CppAstNode& node) const;
};

}
Expand Down
117 changes: 85 additions & 32 deletions plugins/cpp/service/src/cppservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,10 @@ void CppServiceHandler::getProperties(
return_["Type"] = variable.qualifiedType;
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying properties "
"of C++ variable: "
<< toShortDiagnosticString(node);

break;
}
Expand All @@ -310,8 +312,10 @@ void CppServiceHandler::getProperties(
return_["Signature"] = function.name;
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying properties "
"of C++ function: "
<< toShortDiagnosticString(node);

break;
}
Expand All @@ -334,8 +338,10 @@ void CppServiceHandler::getProperties(
return_["Qualified name"] = type.qualifiedName;
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying properties "
"of C++ type: "
<< toShortDiagnosticString(node);

break;
}
Expand All @@ -353,8 +359,10 @@ void CppServiceHandler::getProperties(
return_["Qualified name"] = type.qualifiedName;
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying properties "
"of C++ typedef: "
<< toShortDiagnosticString(node);

break;
}
Expand All @@ -373,8 +381,10 @@ void CppServiceHandler::getProperties(
return_["Value"] = std::to_string(enumConst.value);
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying properties "
"of C++ enum constant: "
<< toShortDiagnosticString(node);
}
}
});
Expand Down Expand Up @@ -492,8 +502,10 @@ std::int32_t CppServiceHandler::getReferenceCount(
TypeQuery::entityHash == function.typeHash).count;
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when counting return types "
"of C++ function: "
<< toShortDiagnosticString(node);

return 0;
}
Expand Down Expand Up @@ -526,8 +538,10 @@ std::int32_t CppServiceHandler::getReferenceCount(
TypeQuery::entityHash == variable.typeHash).count;
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when counting types "
"of C++ variable: "
<< toShortDiagnosticString(node);

return 0;
}
Expand Down Expand Up @@ -774,8 +788,10 @@ void CppServiceHandler::getReferences(
std::to_string(var.load()->astNodeId)));
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying parameters "
"of C++ function: "
<< toShortDiagnosticString(node);

break;
}
Expand All @@ -795,8 +811,10 @@ void CppServiceHandler::getReferences(
std::to_string(var.load()->astNodeId)));
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying local variables "
"of C++ function: "
<< toShortDiagnosticString(node);

break;
}
Expand All @@ -822,8 +840,10 @@ void CppServiceHandler::getReferences(
}
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying return type "
"of C++ function: "
<< toShortDiagnosticString(node);

break;
}
Expand Down Expand Up @@ -884,8 +904,10 @@ void CppServiceHandler::getReferences(
}
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying type "
"of C++ variable: "
<< toShortDiagnosticString(node);

break;
}
Expand Down Expand Up @@ -983,8 +1005,10 @@ void CppServiceHandler::getReferences(
nodes = std::vector<model::CppAstNode>(result.begin(), result.end());
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying underlying type "
"of C++ typedef: "
<< toShortDiagnosticString(node);

break;
}
Expand All @@ -1009,8 +1033,10 @@ void CppServiceHandler::getReferences(
});
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying enum constants "
"of C++ enum: "
<< toShortDiagnosticString(node);

break;
}
Expand Down Expand Up @@ -1611,14 +1637,22 @@ CppServiceHandler::getTags(const std::vector<model::CppAstNode>& nodes_)
tags[node.id].push_back(visibility);
}

//--- Virtual Tag ---//
//--- Other Tags ---//

FuncResult funcNodes = _db->query<cc::model::CppFunction>(
FuncQuery::entityHash == defNode.entityHash);
const model::CppFunction& funcNode = *funcNodes.begin();
if (!funcNodes.empty())
{
const model::CppFunction& funcNode = *funcNodes.begin();

for (const model::Tag& tag : funcNode.tags)
tags[node.id].push_back(model::tagToString(tag));
for (const model::Tag& tag : funcNode.tags)
tags[node.id].push_back(model::tagToString(tag));
}
else
LOG(warning)
<< "Unexpected empty result when querying tags "
"of C++ function: "
<< toShortDiagnosticString(node);

break;
}
Expand Down Expand Up @@ -1650,8 +1684,10 @@ CppServiceHandler::getTags(const std::vector<model::CppAstNode>& nodes_)
tags[node.id].push_back(model::tagToString(tag));
}
else
LOG(warning) << "Database query result was not expected to be empty. "
<< __FILE__ << ", line #" << __LINE__;
LOG(warning)
<< "Unexpected empty result when querying tags "
"of C++ variable: "
<< toShortDiagnosticString(node);

break;
}
Expand Down Expand Up @@ -1698,6 +1734,23 @@ std::size_t CppServiceHandler::queryCallsCount(
return _db->query_value<model::CppAstCount>(astCallsQuery(node)).count;
}

inline std::string
CppServiceHandler::toShortDiagnosticString(const model::CppAstNode& node) const
{
return std::string(node.astValue)
.append("\n AST node #").append(std::to_string(node.id))
.append("\n in file ").append(node.location.file.load()->path)
.append(" (")
.append(std::to_string(
static_cast<signed>(node.location.range.start.line))).append(":")
.append(std::to_string(
static_cast<signed>(node.location.range.start.column))).append(" - ")
.append(std::to_string(
static_cast<signed>(node.location.range.end.line))).append(":")
.append(std::to_string(
static_cast<signed>(node.location.range.end.column))).append(")");
}

} // language
} // service
} // cc
Expand Down