2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-07-27 15:29:16 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-07-27 15:29:16 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-07-27 15:29:16 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-07-27 15:29:16 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-07-27 15:29:16 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-07-27 15:29:16 +02:00
|
|
|
|
2010-09-30 12:09:38 +02:00
|
|
|
#include "cpptools_global.h"
|
2013-03-27 18:54:03 +01:00
|
|
|
#include "cpprefactoringchanges.h"
|
2010-09-30 12:09:38 +02:00
|
|
|
|
|
|
|
|
namespace CppTools {
|
2010-07-27 15:29:16 +02:00
|
|
|
|
2010-09-30 12:09:38 +02:00
|
|
|
class CPPTOOLS_EXPORT InsertionLocation
|
2010-07-27 15:29:16 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
InsertionLocation();
|
2010-09-30 12:09:38 +02:00
|
|
|
InsertionLocation(const QString &fileName, const QString &prefix,
|
|
|
|
|
const QString &suffix, unsigned line, unsigned column);
|
|
|
|
|
|
|
|
|
|
QString fileName() const
|
|
|
|
|
{ return m_fileName; }
|
2010-07-27 15:29:16 +02:00
|
|
|
|
|
|
|
|
/// \returns The prefix to insert before any other text.
|
|
|
|
|
QString prefix() const
|
|
|
|
|
{ return m_prefix; }
|
|
|
|
|
|
2010-07-28 12:09:50 +02:00
|
|
|
/// \returns The suffix to insert after the other inserted text.
|
|
|
|
|
QString suffix() const
|
|
|
|
|
{ return m_suffix; }
|
|
|
|
|
|
2010-07-27 15:29:16 +02:00
|
|
|
/// \returns The line where to insert. The line number is 1-based.
|
2010-07-28 12:09:50 +02:00
|
|
|
unsigned line() const
|
2010-07-27 15:29:16 +02:00
|
|
|
{ return m_line; }
|
|
|
|
|
|
|
|
|
|
/// \returns The column where to insert. The column number is 1-based.
|
2010-07-28 12:09:50 +02:00
|
|
|
unsigned column() const
|
2010-07-27 15:29:16 +02:00
|
|
|
{ return m_column; }
|
|
|
|
|
|
|
|
|
|
bool isValid() const
|
2010-09-30 12:09:38 +02:00
|
|
|
{ return !m_fileName.isEmpty() && m_line > 0 && m_column > 0; }
|
2010-07-27 15:29:16 +02:00
|
|
|
|
|
|
|
|
private:
|
2010-09-30 12:09:38 +02:00
|
|
|
QString m_fileName;
|
2010-07-27 15:29:16 +02:00
|
|
|
QString m_prefix;
|
2010-07-28 12:09:50 +02:00
|
|
|
QString m_suffix;
|
2010-07-27 15:29:16 +02:00
|
|
|
unsigned m_line;
|
|
|
|
|
unsigned m_column;
|
|
|
|
|
};
|
|
|
|
|
|
2010-09-30 12:09:38 +02:00
|
|
|
class CPPTOOLS_EXPORT InsertionPointLocator
|
2010-07-27 15:29:16 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum AccessSpec {
|
|
|
|
|
Invalid = -1,
|
|
|
|
|
Signals = 0,
|
|
|
|
|
|
|
|
|
|
Public = 1,
|
|
|
|
|
Protected = 2,
|
|
|
|
|
Private = 3,
|
|
|
|
|
|
|
|
|
|
SlotBit = 1 << 2,
|
|
|
|
|
|
2010-09-27 18:01:04 +02:00
|
|
|
PublicSlot = Public | SlotBit,
|
2010-07-27 15:29:16 +02:00
|
|
|
ProtectedSlot = Protected | SlotBit,
|
2010-12-16 12:05:48 +01:00
|
|
|
PrivateSlot = Private | SlotBit
|
2010-07-27 15:29:16 +02:00
|
|
|
};
|
2013-04-29 23:15:50 +02:00
|
|
|
static QString accessSpecToString(InsertionPointLocator::AccessSpec xsSpec);
|
2010-07-27 15:29:16 +02:00
|
|
|
|
|
|
|
|
public:
|
2011-08-17 11:35:57 +02:00
|
|
|
InsertionPointLocator(const CppRefactoringChanges &refactoringChanges);
|
2010-07-27 15:29:16 +02:00
|
|
|
|
2010-09-27 18:01:04 +02:00
|
|
|
InsertionLocation methodDeclarationInClass(const QString &fileName,
|
2010-09-30 12:09:38 +02:00
|
|
|
const CPlusPlus::Class *clazz,
|
2010-07-27 15:29:16 +02:00
|
|
|
AccessSpec xsSpec) const;
|
|
|
|
|
|
2013-05-30 17:32:15 +02:00
|
|
|
QList<InsertionLocation> methodDefinition(CPlusPlus::Symbol *declaration,
|
2013-06-07 16:44:08 +02:00
|
|
|
bool useSymbolFinder = true,
|
|
|
|
|
const QString &destinationFile = QString()) const;
|
2010-09-27 18:01:04 +02:00
|
|
|
|
2010-07-27 15:29:16 +02:00
|
|
|
private:
|
2011-08-17 11:35:57 +02:00
|
|
|
CppRefactoringChanges m_refactoringChanges;
|
2010-07-27 15:29:16 +02:00
|
|
|
};
|
|
|
|
|
|
2010-09-30 12:09:38 +02:00
|
|
|
} // namespace CppTools
|