@ -2050,14 +2050,13 @@ void CppCodeCompletion::needRecoveryPoints() {
if ( this - > d - > recoveryPoints . isEmpty ( ) ) {
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 ;
TranslationUnitAST * ast = * m_pSupport - > backgroundParser ( ) - > translationUnit ( m_activeFileName ) ;
ParsedFilePointer pTransUnit = m_pSupport - > backgroundParser ( ) - > translationUnit ( m_activeFileName ) ;
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 ;
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 );
@ -2684,70 +2683,74 @@ void CppCodeCompletion::completeText( bool invokedOnDemand /*= false*/ ) {
///@todo is all this necessary?
if ( ! recoveredDecl . get ( ) & & ! recoveredTypeSpec . get ( ) ) {
TranslationUnitAST * ast = * m_pSupport - > backgroundParser ( ) - > translationUnit ( m_activeFileName ) ;
if ( AST * node = findNodeAt ( ast , line , column ) ) {
kdDebug ( 9007 ) < < " ------------------- AST FOUND -------------------- " < < endl ;
kdDebug ( 9007 ) < < " node-kind = " < < nodeTypeToString ( node - > nodeType ( ) ) < < endl ;
ParsedFilePointer pTransUnit = m_pSupport - > backgroundParser ( ) - > translationUnit ( m_activeFileName ) ;
if ( pTransUnit )
{
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 ) ) {
kdDebug ( 9007 ) < < " ------> found a function definition " < < endl ;
if ( FunctionDefinitionAST * def = functionDefinition ( node ) ) {
kdDebug ( 9007 ) < < " ------> found a function definition " < < endl ;
int startLine , startColumn ;
def - > getStartPosition ( & startLine , & startColumn ) ;
int 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
int start_expr = expressionAt ( contents , contents . length ( ) ) ;
/// @todo remove code duplication
int start_expr = expressionAt ( contents , contents . length ( ) ) ;
// kdDebug(9007) << "start_expr = " << start_expr << endl;
if ( start_expr ! = int ( contents . length ( ) ) )
expr = contents . mid ( start_expr , contents . length ( ) - start_expr ) . stripWhiteSpace ( ) ;
// kdDebug(9007) << "start_expr = " << start_expr << endl;
if ( start_expr ! = int ( contents . length ( ) ) )
expr = contents . mid ( start_expr , contents . length ( ) - start_expr ) . stripWhiteSpace ( ) ;
if ( expr . startsWith ( " TQ_SIGNAL " ) | | expr . startsWith ( " TQ_SLOT " ) ) {
m_completionMode = expr . startsWith ( " TQ_SIGNAL " ) ? SignalCompletion : SlotCompletion ;
if ( expr . startsWith ( " TQ_SIGNAL " ) | | expr . startsWith ( " TQ_SLOT " ) ) {
m_completionMode = expr . startsWith ( " TQ_SIGNAL " ) ? SignalCompletion : SlotCompletion ;
showArguments = false ;
int end_expr = start_expr - 1 ;
while ( end_expr > 0 & & contents [ end_expr ] . isSpace ( ) )
- - end_expr ;
showArguments = false ;
int end_expr = start_expr - 1 ;
while ( end_expr > 0 & & contents [ end_expr ] . isSpace ( ) )
- - end_expr ;
if ( contents [ end_expr ] ! = ' , ' ) {
expr = TQString ( ) ;
if ( contents [ end_expr ] ! = ' , ' ) {
expr = TQString ( ) ;
} else {
start_expr = expressionAt ( contents , end_expr ) ;
expr = contents . mid ( start_expr , end_expr - start_expr ) . stripWhiteSpace ( ) ;
}
} else {
start_expr = expressionAt ( contents , end_expr ) ;
expr = contents . mid ( start_expr , end_expr - start_expr ) . stripWhiteSpace ( ) ;
}
} else {
int idx = expr . length ( ) - 1 ;
while ( expr [ idx ] . isLetterOrNumber ( ) | | expr [ idx ] = = ' _ ' )
- - idx ;
if ( idx ! = int ( expr . length ( ) ) - 1 ) {
+ + idx ;
word = expr . mid ( idx ) . stripWhiteSpace ( ) ;
expr = expr . left ( idx ) . stripWhiteSpace ( ) ;
int idx = expr . length ( ) - 1 ;
while ( expr [ idx ] . isLetterOrNumber ( ) | | expr [ idx ] = = ' _ ' )
- - idx ;
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 ;
scopeOfNode ( def , scope ) ;
this_type = SimpleType ( scope , getIncludeFiles ( ) ) ;
TQStringList scope ;
scopeOfNode ( def , scope ) ;
this_type = SimpleType ( scope , getIncludeFiles ( ) ) ;
if ( scope . size ( ) ) { /*
SimpleVariable var ;
var . type = scope ;
var . name = " this " ;
ctx - > add ( var ) ; */
//kdDebug(9007) << "add variable " << var.name << " with type " << var.type << endl;
}
if ( scope . size ( ) ) { /*
SimpleVariable var ;
var . type = scope ;
var . name = " this " ;
ctx - > add ( var ) ; */
//kdDebug(9007) << "add variable " << var.name << " with type " << var.type << endl;
}
ExpressionInfo exp ( expr ) ;
exp . t = ( ExpressionInfo : : Type ) ( ExpressionInfo : : NormalExpression | ExpressionInfo : : TypeExpression ) ;
type = evaluateExpression ( exp , ctx ) ;
ExpressionInfo exp ( expr ) ;
exp . t = ( ExpressionInfo : : Type ) ( ExpressionInfo : : NormalExpression | ExpressionInfo : : TypeExpression ) ;
type = evaluateExpression ( exp , ctx ) ;
}
}
}
}