本文整理汇总了C++中FunctionDefinition::declaration方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionDefinition::declaration方法的具体用法?C++ FunctionDefinition::declaration怎么用?C++ FunctionDefinition::declaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionDefinition
的用法示例。
在下文中一共展示了FunctionDefinition::declaration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AbstractNavigationContext
AbstractDeclarationNavigationContext::AbstractDeclarationNavigationContext( DeclarationPointer decl, KDevelop::TopDUContextPointer topContext, AbstractNavigationContext* previousContext)
: AbstractNavigationContext((topContext ? topContext : TopDUContextPointer(decl ? decl->topContext() : 0)), previousContext), m_declaration(decl), m_fullBackwardSearch(false)
{
//Jump from definition to declaration if possible
FunctionDefinition* definition = dynamic_cast<FunctionDefinition*>(m_declaration.data());
if(definition && definition->declaration())
m_declaration = DeclarationPointer(definition->declaration());
}
示例2: textChanged
void AdaptSignatureAssistant::textChanged(KTextEditor::View* view, const KTextEditor::Range& invocationRange, const QString& removedText)
{
reset();
m_view = view;
//FIXME: update signature assistant to play well with the rename assistant
KTextEditor::Range sigAssistRange = invocationRange;
if (!removedText.isEmpty()) {
sigAssistRange.setRange(sigAssistRange.start(), sigAssistRange.start());
}
m_document = view->document()->url();
DUChainReadLocker lock(DUChain::lock(), 300);
if(!lock.locked()) {
qCDebug(CPP) << "failed to lock duchain in time";
return;
}
KTextEditor::Range simpleInvocationRange = KTextEditor::Range(sigAssistRange);
Declaration* funDecl = getDeclarationAtCursor(simpleInvocationRange.start(), m_document);
if(!funDecl || !funDecl->type<FunctionType>())
return;
if(QtFunctionDeclaration* classFun = dynamic_cast<QtFunctionDeclaration*>(funDecl)) {
if (classFun->isSignal()) {
// do not offer to change signature of a signal, as the implementation will be generated by moc
return;
}
}
Declaration* otherSide = 0;
FunctionDefinition* definition = dynamic_cast<FunctionDefinition*>(funDecl);
if (definition)
{
m_editingDefinition = true;
otherSide = definition->declaration();
}
else if ((definition = FunctionDefinition::definition(funDecl)))
{
m_editingDefinition = false;
otherSide = definition;
}
if (!otherSide)
return;
m_otherSideContext = DUContextPointer(DUChainUtils::getFunctionContext(otherSide));
if (!m_otherSideContext)
return;
m_declarationName = funDecl->identifier();
m_otherSideId = otherSide->id();
m_otherSideTopContext = ReferencedTopDUContext(otherSide->topContext());
m_oldSignature = getDeclarationSignature(otherSide, m_otherSideContext.data(), true);
//Schedule an update, to make sure the ranges match
DUChain::self()->updateContextForUrl(m_otherSideTopContext->url(), TopDUContext::AllDeclarationsAndContexts);
}
示例3: html
QString DeclarationNavigationContext::html(bool shorten)
{
clear();
m_shorten = shorten;
modifyHtml() += "<html><body><p>" + fontSizePrefix(shorten);
addExternalHtml(m_prefix);
if(!m_declaration.data()) {
modifyHtml() += i18n("<br /> lost declaration <br />");
return currentHtml();
}
if( m_previousContext ) {
QString link = createLink( m_previousContext->name(), m_previousContext->name(), NavigationAction(m_previousContext) );
modifyHtml() += navigationHighlight(i18n("Back to %1<br />", link));
}
QExplicitlySharedDataPointer<IDocumentation> doc;
if( !shorten ) {
doc = ICore::self()->documentationController()->documentationForDeclaration(m_declaration.data());
const AbstractFunctionDeclaration* function = dynamic_cast<const AbstractFunctionDeclaration*>(m_declaration.data());
if( function ) {
htmlFunction();
} else if( m_declaration->isTypeAlias() || m_declaration->kind() == Declaration::Instance ) {
if( m_declaration->isTypeAlias() )
modifyHtml() += importantHighlight("type ");
if(m_declaration->type<EnumeratorType>())
modifyHtml() += i18n("enumerator ");
if( !m_declaration->isTypeAlias())
modifyHtml() += ' ' + identifierHighlight(declarationName(m_declaration).toHtmlEscaped(), m_declaration) + " ";
AbstractType::Ptr useType = m_declaration->abstractType();
if(m_declaration->isTypeAlias()) {
//Do not show the own name as type of typedefs
if(useType.cast<TypeAliasType>())
useType = useType.cast<TypeAliasType>()->type();
}
eventuallyMakeTypeLinks( useType );
modifyHtml() += "<br>";
}else{
if( m_declaration->kind() == Declaration::Type && m_declaration->abstractType().cast<StructureType>()) {
htmlClass();
}
if ( m_declaration->kind() == Declaration::Namespace ) {
modifyHtml() += i18n("namespace %1 ", identifierHighlight(m_declaration->qualifiedIdentifier().toString().toHtmlEscaped(), m_declaration));
}
if(m_declaration->type<EnumerationType>()) {
EnumerationType::Ptr enumeration = m_declaration->type<EnumerationType>();
modifyHtml() += i18n("enumeration %1 ", identifierHighlight(m_declaration->identifier().toString().toHtmlEscaped(), m_declaration));
}
if(m_declaration->isForwardDeclaration()) {
ForwardDeclaration* forwardDec = static_cast<ForwardDeclaration*>(m_declaration.data());
Declaration* resolved = forwardDec->resolve(m_topContext.data());
if(resolved) {
modifyHtml() += i18n("( resolved forward-declaration: ");
makeLink(resolved->identifier().toString(), KDevelop::DeclarationPointer(resolved), NavigationAction::NavigateDeclaration );
modifyHtml() += i18n(") ");
}else{
modifyHtml() += i18n("(unresolved forward-declaration) ");
QualifiedIdentifier id = forwardDec->qualifiedIdentifier();
uint count;
const IndexedDeclaration* decls;
PersistentSymbolTable::self().declarations(id, count, decls);
for(uint a = 0; a < count; ++a) {
if(decls[a].isValid() && !decls[a].data()->isForwardDeclaration()) {
modifyHtml() += "<br />";
makeLink(i18n("possible resolution from"), KDevelop::DeclarationPointer(decls[a].data()), NavigationAction::NavigateDeclaration);
modifyHtml() += ' ' + decls[a].data()->url().str();
}
}
}
}
modifyHtml() += "<br />";
}
}else{
AbstractType::Ptr showType = m_declaration->abstractType();
if(showType && showType.cast<FunctionType>()) {
showType = showType.cast<FunctionType>()->returnType();
if(showType)
modifyHtml() += labelHighlight(i18n("Returns: "));
}else if(showType) {
modifyHtml() += labelHighlight(i18n("Type: "));
}
if(showType) {
eventuallyMakeTypeLinks(showType);
modifyHtml() += " ";
}
//.........这里部分代码省略.........