@ -2050,14 +2050,13 @@ void CppCodeCompletion::needRecoveryPoints() {
if ( this - > d - > recoveryPoints . isEmpty ( ) ) {
if ( this - > d - > recoveryPoints . isEmpty ( ) ) {
kdDebug ( 9007 ) < < " missing recovery-points for file " < < m_activeFileName < < " they have to be computed now " < < endl ;
kdDebug ( 9007 ) < < " missing recovery-points for file " < < m_activeFileName < < " they have to be computed now " < < endl ;
m_pSupport - > backgroundParser ( ) - > lock ( )
m_pSupport - > backgroundParser ( ) - > lock ( ) ;
;
std : : vector < CppCodeCompletion > vec ;
std : : vector < CppCodeCompletion > vec ;
TranslationUnitAST * ast = * m_pSupport - > backgroundParser ( ) - > translationUnit ( m_activeFileName ) ;
ParsedFilePointer pTransUnit = m_pSupport - > backgroundParser ( ) - > translationUnit ( m_activeFileName ) ;
m_pSupport - > backgroundParser ( ) - > unlock ( ) ;
m_pSupport - > backgroundParser ( ) - > unlock ( ) ;
if ( ! ast ) {
if ( ! pTr an sUni t ) {
kdDebug ( 9007 ) < < " background-parser is missing the translation-unit. The file needs to be reparsed. " < < endl ;
kdDebug ( 9007 ) < < " background-parser is missing the translation-unit. The file needs to be reparsed. " < < endl ;
m_pSupport - > parseFileAndDependencies ( m_activeFileName , true ) ;
m_pSupport - > parseFileAndDependencies ( m_activeFileName , true ) ;
// m_pSupport->mainWindow() ->statusBar() ->message( i18n( "Background-parser is missing the necessary translation-unit. It will be computed, but this completion will fail." ).arg( m_activeFileName ), 2000 );
// m_pSupport->mainWindow() ->statusBar() ->message( i18n( "Background-parser is missing the necessary translation-unit. It will be computed, but this completion will fail." ).arg( m_activeFileName ), 2000 );
@ -2684,70 +2683,74 @@ void CppCodeCompletion::completeText( bool invokedOnDemand /*= false*/ ) {
///@todo is all this necessary?
///@todo is all this necessary?
if ( ! recoveredDecl . get ( ) & & ! recoveredTypeSpec . get ( ) ) {
if ( ! recoveredDecl . get ( ) & & ! recoveredTypeSpec . get ( ) ) {
TranslationUnitAST * ast = * m_pSupport - > backgroundParser ( ) - > translationUnit ( m_activeFileName ) ;
ParsedFilePointer pTransUnit = m_pSupport - > backgroundParser ( ) - > translationUnit ( m_activeFileName ) ;
if ( AST * node = findNodeAt ( ast , line , column ) ) {
if ( pTransUnit )
kdDebug ( 9007 ) < < " ------------------- AST FOUND -------------------- " < < endl ;
{
kdDebug ( 9007 ) < < " node-kind = " < < nodeTypeToString ( node - > nodeType ( ) ) < < endl ;
TranslationUnitAST * ast = * pTransUnit ;
if ( AST * node = findNodeAt ( ast , line , column ) ) {
kdDebug ( 9007 ) < < " ------------------- AST FOUND -------------------- " < < endl ;
kdDebug ( 9007 ) < < " node-kind = " < < nodeTypeToString ( node - > nodeType ( ) ) < < endl ;
if ( FunctionDefinitionAST * def = functionDefinition ( node ) ) {
if ( FunctionDefinitionAST * def = functionDefinition ( node ) ) {
kdDebug ( 9007 ) < < " ------> found a function definition " < < endl ;
kdDebug ( 9007 ) < < " ------> found a function definition " < < endl ;
int startLine , startColumn ;
int startLine , startColumn ;
def - > getStartPosition ( & startLine , & startColumn ) ;
def - > getStartPosition ( & startLine , & startColumn ) ;
TQString contents = getText ( startLine , startColumn , line , showArguments ? nCol : column ) ;
TQString contents = getText ( startLine , startColumn , line , showArguments ? nCol : column ) ;
/// @todo remove code duplication
/// @todo remove code duplication
int start_expr = expressionAt ( contents , contents . length ( ) ) ;
int start_expr = expressionAt ( contents , contents . length ( ) ) ;
// kdDebug(9007) << "start_expr = " << start_expr << endl;
// kdDebug(9007) << "start_expr = " << start_expr << endl;
if ( start_expr ! = int ( contents . length ( ) ) )
if ( start_expr ! = int ( contents . length ( ) ) )
expr = contents . mid ( start_expr , contents . length ( ) - start_expr ) . stripWhiteSpace ( ) ;
expr = contents . mid ( start_expr , contents . length ( ) - start_expr ) . stripWhiteSpace ( ) ;
if ( expr . startsWith ( " TQ_SIGNAL " ) | | expr . startsWith ( " TQ_SLOT " ) ) {
if ( expr . startsWith ( " TQ_SIGNAL " ) | | expr . startsWith ( " TQ_SLOT " ) ) {
m_completionMode = expr . startsWith ( " TQ_SIGNAL " ) ? SignalCompletion : SlotCompletion ;
m_completionMode = expr . startsWith ( " TQ_SIGNAL " ) ? SignalCompletion : SlotCompletion ;
showArguments = false ;
showArguments = false ;
int end_expr = start_expr - 1 ;
int end_expr = start_expr - 1 ;
while ( end_expr > 0 & & contents [ end_expr ] . isSpace ( ) )
while ( end_expr > 0 & & contents [ end_expr ] . isSpace ( ) )
- - end_expr ;
- - end_expr ;
if ( contents [ end_expr ] ! = ' , ' ) {
if ( contents [ end_expr ] ! = ' , ' ) {
expr = TQString ( ) ;
expr = TQString ( ) ;
} else {
start_expr = expressionAt ( contents , end_expr ) ;
expr = contents . mid ( start_expr , end_expr - start_expr ) . stripWhiteSpace ( ) ;
}
} else {
} else {
start_expr = expressionAt ( contents , end_expr ) ;
int idx = expr . length ( ) - 1 ;
expr = contents . mid ( start_expr , end_expr - start_expr ) . stripWhiteSpace ( ) ;
while ( expr [ idx ] . isLetterOrNumber ( ) | | expr [ idx ] = = ' _ ' )
}
- - idx ;
} else {
int idx = expr . length ( ) - 1 ;
if ( idx ! = int ( expr . length ( ) ) - 1 ) {
while ( expr [ idx ] . isLetterOrNumber ( ) | | expr [ idx ] = = ' _ ' )
+ + idx ;
- - idx ;
word = expr . mid ( idx ) . stripWhiteSpace ( ) ;
expr = expr . left ( idx ) . stripWhiteSpace ( ) ;
if ( idx ! = int ( expr . length ( ) ) - 1 ) {
}
+ + idx ;
word = expr . mid ( idx ) . stripWhiteSpace ( ) ;
expr = expr . left ( idx ) . stripWhiteSpace ( ) ;
}
}
}
ctx = computeContext ( def , line , column , startLine , startColumn ) ;
ctx = computeContext ( def , line , column , startLine , startColumn ) ;
TQStringList scope ;
TQStringList scope ;
scopeOfNode ( def , scope ) ;
scopeOfNode ( def , scope ) ;
this_type = SimpleType ( scope , getIncludeFiles ( ) ) ;
this_type = SimpleType ( scope , getIncludeFiles ( ) ) ;
if ( scope . size ( ) ) { /*
if ( scope . size ( ) ) { /*
SimpleVariable var ;
SimpleVariable var ;
var . type = scope ;
var . type = scope ;
var . name = " this " ;
var . name = " this " ;
ctx - > add ( var ) ; */
ctx - > add ( var ) ; */
//kdDebug(9007) << "add variable " << var.name << " with type " << var.type << endl;
//kdDebug(9007) << "add variable " << var.name << " with type " << var.type << endl;
}
}
ExpressionInfo exp ( expr ) ;
ExpressionInfo exp ( expr ) ;
exp . t = ( ExpressionInfo : : Type ) ( ExpressionInfo : : NormalExpression | ExpressionInfo : : TypeExpression ) ;
exp . t = ( ExpressionInfo : : Type ) ( ExpressionInfo : : NormalExpression | ExpressionInfo : : TypeExpression ) ;
type = evaluateExpression ( exp , ctx ) ;
type = evaluateExpression ( exp , ctx ) ;
}
}
}
}
}
}
}