forked from qt-creator/qt-creator
		
	Enhance data stored for macros and macro uses.
In preparation for finding macro uses. * Macro: add offset and length * MacroUse: add line * Document: add convenience functions for finding a macro definition, use or undefined use at a given location. Reviewed-by: Erik Verbruggen
This commit is contained in:
		@@ -194,9 +194,10 @@ void Document::appendMacro(const Macro ¯o)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Document::addMacroUse(const Macro ¯o, unsigned offset, unsigned length,
 | 
			
		||||
                           unsigned beginLine,
 | 
			
		||||
                           const QVector<MacroArgumentReference> &actuals, bool inCondition)
 | 
			
		||||
{
 | 
			
		||||
    MacroUse use(macro, offset, offset + length);
 | 
			
		||||
    MacroUse use(macro, offset, offset + length, beginLine);
 | 
			
		||||
    use.setInCondition(inCondition);
 | 
			
		||||
 | 
			
		||||
    foreach (const MacroArgumentReference &actual, actuals) {
 | 
			
		||||
@@ -330,6 +331,33 @@ Symbol *Document::findSymbolAt(unsigned line, unsigned column, Scope *scope) con
 | 
			
		||||
    return previousSymbol;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const Macro *Document::findMacroDefinitionAt(unsigned line) const
 | 
			
		||||
{
 | 
			
		||||
    foreach (const Macro ¯o, _definedMacros) {
 | 
			
		||||
        if (macro.line() == line)
 | 
			
		||||
            return ¯o;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const Document::MacroUse *Document::findMacroUseAt(unsigned offset) const
 | 
			
		||||
{
 | 
			
		||||
    foreach (const Document::MacroUse &use, _macroUses) {
 | 
			
		||||
        if (use.contains(offset))
 | 
			
		||||
            return &use;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const Document::UndefinedMacroUse *Document::findUndefinedMacroUseAt(unsigned offset) const
 | 
			
		||||
{
 | 
			
		||||
    foreach (const Document::UndefinedMacroUse &use, _undefinedMacroUses) {
 | 
			
		||||
        if (use.contains(offset))
 | 
			
		||||
            return &use;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Document::Ptr Document::create(const QString &fileName)
 | 
			
		||||
{
 | 
			
		||||
    Document::Ptr doc(new Document(fileName));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user