Merge remote-tracking branch 'origin/8.0'

Change-Id: Ia1c97d5949de607177a5a0632c7e8a37cbfd3475
This commit is contained in:
Eike Ziller
2022-06-27 10:22:29 +02:00
269 changed files with 20437 additions and 5409 deletions

View File

@ -832,7 +832,7 @@ function(add_qtc_test name)
endif()
foreach(dependency ${_arg_DEPENDS})
if (NOT TARGET ${dependency} AND NOT _arg_GTEST)
if (NOT TARGET ${dependency})
if (WITH_DEBUG_CMAKE)
message(STATUS "'${dependency}' is not a target")
endif()

View File

@ -27,6 +27,7 @@ function(_extract_ts_data_from_targets outprefix)
set(_target_sources "")
if(_source_files)
list(FILTER _source_files EXCLUDE REGEX ".*[.]json[.]in|.*[.]svg")
list(APPEND _target_sources ${_source_files})
endif()
if(_extra_translations)

View File

@ -28,35 +28,15 @@
****************************************************************************/
import QtQuick 2.15
import QtQuick.Window 2.15
Item {
id: root
width: 1024
height: 768
visible: true
property alias qtVersion: mainScreen.qtVersion
property alias qdsVersion: mainScreen.qdsVersion
property alias cmakeLists: mainScreen.cmakeLists
property alias qdsInstalled: mainScreen.qdsInstalled
property alias projectFileExists: mainScreen.projectFileExists
property alias rememberSelection: mainScreen.rememberCheckboxCheckState
signal openQtc(bool rememberSelection)
signal openQds(bool rememberSelection)
signal installQds()
signal generateCmake()
signal generateProjectFile()
Screen01 {
id: mainScreen
anchors.fill: parent
openQtcButton.onClicked: openQtc(rememberSelection === Qt.Checked)
openQdsButton.onClicked: openQds(rememberSelection === Qt.Checked)
installButton.onClicked: installQds()
generateCmakeButton.onClicked: generateCmake()
generateProjectFileButton.onClicked: generateProjectFile()
}
}

View File

@ -0,0 +1,135 @@
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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
** 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.
**
** 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.
**
****************************************************************************/
import QtQuick 2.15
import QtQuick.Templates 2.15
import LandingPage as Theme
CheckBox {
id: control
autoExclusive: false
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding,
implicitIndicatorHeight + topPadding + bottomPadding)
spacing: Theme.Values.checkBoxSpacing
hoverEnabled: true
font.family: Theme.Values.baseFont
indicator: Rectangle {
id: checkBoxBackground
implicitWidth: Theme.Values.checkBoxSize
implicitHeight: Theme.Values.checkBoxSize
x: 0
y: parent.height / 2 - height / 2
color: Theme.Colors.backgroundPrimary
border.color: Theme.Colors.foregroundSecondary
border.width: Theme.Values.border
Rectangle {
id: checkBoxIndicator
width: Theme.Values.checkBoxIndicatorSize
height: Theme.Values.checkBoxIndicatorSize
x: (Theme.Values.checkBoxSize - Theme.Values.checkBoxIndicatorSize) * 0.5
y: (Theme.Values.checkBoxSize - Theme.Values.checkBoxIndicatorSize) * 0.5
color: Theme.Colors.accent
visible: control.checked
}
}
contentItem: Text {
id: checkBoxLabel
text: control.text
font: control.font
color: Theme.Colors.text
verticalAlignment: Text.AlignVCenter
leftPadding: control.indicator.width + control.spacing
}
states: [
State {
name: "default"
when: control.enabled && !control.hovered && !control.pressed
PropertyChanges {
target: checkBoxBackground
color: Theme.Colors.backgroundPrimary
border.color: Theme.Colors.foregroundSecondary
}
PropertyChanges {
target: checkBoxLabel
color: Theme.Colors.text
}
},
State {
name: "hover"
when: control.enabled && control.hovered && !control.pressed
PropertyChanges {
target: checkBoxBackground
color: Theme.Colors.hover
border.color: Theme.Colors.foregroundSecondary
}
},
State {
name: "press"
when: control.hovered && control.pressed
PropertyChanges {
target: checkBoxBackground
color: Theme.Colors.hover
border.color: Theme.Colors.accent
}
PropertyChanges {
target: checkBoxIndicator
color: Theme.Colors.backgroundSecondary
}
},
State {
name: "disable"
when: !control.enabled
PropertyChanges {
target: checkBoxBackground
color: Theme.Colors.backgroundPrimary
border.color: Theme.Colors.disabledLink
}
PropertyChanges {
target: checkBoxIndicator
color: Theme.Colors.disabledLink
}
PropertyChanges {
target: checkBoxLabel
color: Theme.Colors.disabledLink
}
}
]
}
/*##^##
Designer {
D{i:0;height:40;width:142}
}
##^##*/

View File

@ -33,46 +33,48 @@ It is supposed to be strictly declarative and only uses a subset of QML. If you
this file manually, you might introduce QML code that is not supported by Qt Design Studio.
Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/
import QtQuick 2.15
import QtQuick.Controls 2.15
import LandingPage
import QdsLandingPageTheme as Theme
import LandingPageApi
import LandingPage as Theme
Rectangle {
id: installQdsBlock
color: Theme.Values.themeBackgroundColorNormal
border.width: 0
property alias installQdsBlockVisible: installQdsBlock.visible
property alias installButton: installButton
height: 200
id: root
Text {
id: statusText
text: qsTr("No Qt Design Studio installation found")
font.family: Theme.Values.baseFont
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: parent.top
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
color: Theme.Colors.backgroundSecondary
height: column.childrenRect.height + (2 * Theme.Values.spacing)
Connections {
target: installButton
function onClicked() { LandingPageApi.installQds() }
}
Text {
id: suggestionText
text: qsTr("Would you like to install it now?")
font.family: Theme.Values.baseFont
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: statusText.bottom
anchors.topMargin: 10
anchors.horizontalCenterOffset: 0
anchors.horizontalCenter: parent.horizontalCenter
}
Column {
id: column
PushButton {
id: installButton
anchors.top: suggestionText.bottom
text: "Install"
anchors.topMargin: Constants.buttonDefaultMargin
anchors.horizontalCenterOffset: 0
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
anchors.centerIn: parent
PageText {
id: statusText
width: parent.width
topPadding: 0
padding: Theme.Values.spacing
text: qsTr("No Qt Design Studio installation found")
}
PageText {
id: suggestionText
width: parent.width
padding: Theme.Values.spacing
text: qsTr("Would you like to install it now?")
}
PushButton {
id: installButton
text: qsTr("Install")
anchors.horizontalCenter: parent.horizontalCenter
}
}
}

View File

@ -0,0 +1,49 @@
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** 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
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** 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.
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*
This is a UI file (.ui.qml) that is intended to be edited in Qt Design Studio only.
It is supposed to be strictly declarative and only uses a subset of QML. If you edit
this file manually, you might introduce QML code that is not supported by Qt Design Studio.
Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import LandingPage as Theme
Text {
font.family: Theme.Values.baseFont
font.pixelSize: Theme.Values.fontSizeSubtitle
horizontalAlignment: Text.AlignHCenter
color: Theme.Colors.text
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WordWrap
}

View File

@ -33,171 +33,78 @@ It is supposed to be strictly declarative and only uses a subset of QML. If you
this file manually, you might introduce QML code that is not supported by Qt Design Studio.
Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/
import QtQuick 2.15
import QtQuick.Controls 2.15
import LandingPage
import QdsLandingPageTheme as Theme
import QtQuick.Layouts 1.15
import LandingPageApi
import LandingPage as Theme
Rectangle {
id: projectInfo
height: 300
color: Theme.Values.themeBackgroundColorNormal
border.color: Theme.Values.themeBackgroundColorNormal
border.width: 0
id: root
property bool qdsInstalled: qdsVersionText.text.length > 0
property bool projectFileExists: false
property string qdsVersion: "UNKNOWN"
property string qtVersion: "UNKNOWN"
property alias cmakeListText: cmakeList.text
property alias generateCmakeButton: generateCmakeButton
property string qtVersion: qsTr("Unknown")
property string qdsVersion: qsTr("Unknown")
property alias generateProjectFileButton: generateProjectFileButton
Item {
id: projectFileInfoBox
width: projectInfo.width
height: 150
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 30
color: Theme.Colors.backgroundSecondary
height: column.childrenRect.height + (2 * Theme.Values.spacing)
Text {
Connections {
target: generateProjectFileButton
function onClicked() { LandingPageApi.generateProjectFile() }
}
Column {
id: column
width: parent.width
anchors.centerIn: parent
spacing: Theme.Values.spacing
PageText {
id: projectFileInfoTitle
width: parent.width
text: qsTr("QML PROJECT FILE INFO")
font.family: Theme.Values.baseFont
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: parent.top
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
}
Item {
Column {
id: projectFileInfoVersionBox
width: parent.width
height: 150
visible: projectFileExists
anchors.top: projectFileInfoTitle.bottom
anchors.topMargin: 0
anchors.horizontalCenter: parent.horizontalCenter
visible: root.projectFileExists
Text {
PageText {
id: qtVersionText
text: qsTr("Qt Version - ") + qtVersion
font.family: Theme.Values.baseFont
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: parent.top
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
width: parent.width
padding: Theme.Values.spacing
text: qsTr("Qt Version - ") + root.qtVersion
}
Text {
PageText {
id: qdsVersionText
text: qsTr("Qt Design Studio Version - ") + qdsVersion
font.family: Theme.Values.baseFont
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: qtVersionText.bottom
horizontalAlignment: Text.AlignHCenter
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
padding: Theme.Values.spacing
text: qsTr("Qt Design Studio Version - ") + root.qdsVersion
}
}
Item {
Column {
id: projectFileInfoMissingBox
width: parent.width
height: 200
visible: !projectFileInfoVersionBox.visible
anchors.top: projectFileInfoTitle.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 0
Text {
PageText {
id: projectFileInfoMissingText
width: parent.width
padding: Theme.Values.spacing
text: qsTr("No QML project file found - Would you like to create one?")
font.family: Theme.Values.baseFont
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: parent.top
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
}
PushButton {
id: generateProjectFileButton
anchors.top: projectFileInfoMissingText.bottom
text: "Generate"
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: Constants.buttonDefaultMargin
}
}
}
Item {
id: cmakeInfoBox
width: projectInfo.width
height: 200
anchors.top: projectFileInfoBox.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 40
Text {
id: cmakeInfoTitle
text: qsTr("CMAKE RESOURCE FILES")
font.family: Theme.Values.baseFont
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: parent.top
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
}
Item {
id: cmakeListBox
width: 150
height: 40
visible: cmakeListText.length > 0
anchors.top: cmakeInfoTitle.bottom
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
Text {
id: cmakeList
text: qsTr("")
font.family: "TitilliumWeb"
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: parent.top
horizontalAlignment: Text.AlignHCenter
anchors.topMargin: 0
anchors.horizontalCenter: parent.horizontalCenter
}
}
Item {
id: cmakeMissingBox
width: cmakeInfoBox.width
height: 200
visible: cmakeListText.length === 0
anchors.top: cmakeInfoTitle.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
Text {
id: cmakeMissingText
text: qsTr("No resource files found - Would you like to generate them?")
font.family: Theme.Values.baseFont
font.pixelSize: Constants.fontSizeSubtitle
anchors.top: parent.top
horizontalAlignment: Text.AlignHCenter
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
}
PushButton {
id: generateCmakeButton
anchors.top: cmakeMissingText.bottom
text: "Generate"
anchors.topMargin: Constants.buttonDefaultMargin
text: qsTr("Generate")
anchors.horizontalCenter: parent.horizontalCenter
}
}

View File

@ -1,5 +1,3 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
@ -24,49 +22,38 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
import QtQuick 2.15
import QtQuick.Templates 2.15
import QdsLandingPageTheme as Theme
import LandingPage as Theme
Button {
id: control
implicitWidth: Math.max(
buttonBackground ? buttonBackground.implicitWidth : 0,
textItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(
buttonBackground ? buttonBackground.implicitHeight : 0,
textItem.implicitHeight + topPadding + bottomPadding)
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
leftPadding: 4
rightPadding: 4
text: "My Button"
property alias fontpixelSize: textItem.font.pixelSize
property bool forceHover: false
hoverEnabled: true
state: "normal"
font.family: Theme.Values.baseFont
font.pixelSize: 16
background: buttonBackground
Rectangle {
background: Rectangle {
id: buttonBackground
color: Theme.Values.themeControlBackground
color: Theme.Colors.backgroundPrimary
implicitWidth: 100
implicitHeight: 40
opacity: enabled ? 1 : 0.3
radius: 2
border.color: Theme.Values.themeControlOutline
implicitHeight: 35
border.color: Theme.Colors.foregroundSecondary
anchors.fill: parent
}
contentItem: textItem
Text {
contentItem: Text {
id: textItem
text: control.text
font.pixelSize: 18
opacity: enabled ? 1.0 : 0.3
color: Theme.Values.themeTextColor
font: control.font
color: Theme.Colors.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
rightPadding: 5
@ -75,46 +62,51 @@ Button {
states: [
State {
name: "normal"
when: !control.down && !control.hovered && !control.forceHover
name: "default"
when: control.enabled && !control.hovered && !control.pressed && !control.checked
PropertyChanges {
target: buttonBackground
color: Theme.Values.themeControlBackground
border.color: Theme.Values.themeControlOutline
color: Theme.Colors.backgroundPrimary
}
PropertyChanges {
target: textItem
color: Theme.Values.themeTextColor
color: Theme.Colors.text
}
},
State {
name: "hover"
when: (control.hovered || control.forceHover) && !control.down
PropertyChanges {
target: textItem
color: Theme.Values.themeTextColor
}
extend: "default"
when: control.enabled && control.hovered && !control.pressed
PropertyChanges {
target: buttonBackground
color: Theme.Values.themeControlBackgroundHover
border.color: Theme.Values.themeControlBackgroundHover
color: Theme.Colors.hover
}
},
State {
name: "activeQds"
when: control.down
PropertyChanges {
target: textItem
color: Theme.Values.themeTextColor
}
name: "press"
extend: "default"
when: control.hovered && control.pressed
PropertyChanges {
target: buttonBackground
color: Theme.Values.themeControlBackgroundInteraction
border.color: Theme.Values.themeControlOutlineInteraction
color: Theme.Colors.accent
border.color: Theme.Colors.accent
}
PropertyChanges {
target: textItem
color: Theme.Colors.backgroundPrimary
}
},
State {
name: "disable"
when: !control.enabled
PropertyChanges {
target: buttonBackground
color: Theme.Colors.backgroundPrimary
border.color: Theme.Colors.disabledLink
}
PropertyChanges {
target: textItem
color: Theme.Colors.disabledLink
}
}
]

View File

@ -33,167 +33,190 @@ It is supposed to be strictly declarative and only uses a subset of QML. If you
this file manually, you might introduce QML code that is not supported by Qt Design Studio.
Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/
import QtQuick 2.15
import QtQuick.Controls 6.2
import LandingPage
import QtQuick.Layouts 1.15
import LandingPageApi
import QdsLandingPageTheme as Theme
import LandingPage as Theme
Rectangle {
id: rectangle2
id: root
width: 1024
height: 768
color: Theme.Values.themeBackgroundColorNormal
property bool qdsInstalled: true
property alias openQtcButton: openQtc
property alias openQdsButton: openQds
property alias projectFileExists: projectInfoStatusBlock.projectFileExists
property alias installButton: installQdsStatusBlock.installButton
property alias generateCmakeButton: projectInfoStatusBlock.generateCmakeButton
property alias generateProjectFileButton: projectInfoStatusBlock.generateProjectFileButton
property alias qtVersion: projectInfoStatusBlock.qtVersion
property alias qdsVersion: projectInfoStatusBlock.qdsVersion
property alias cmakeLists: projectInfoStatusBlock.cmakeListText
property alias installQdsBlockVisible: installQdsStatusBlock.visible
property alias rememberCheckboxCheckState: rememberCheckbox.checkState
color: Theme.Colors.backgroundPrimary
Rectangle {
id: logoArea
width: parent.width
height: 180
color: Theme.Values.themeBackgroundColorNormal
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
Image {
id: qdsLogo
source: "logo.png"
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 30
}
Text {
id: qdsText
text: qsTr("Qt Design Studio")
font.pixelSize: Constants.fontSizeTitle
font.family: Theme.Values.baseFont
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
}
Connections {
target: openQds
function onClicked() { LandingPageApi.openQds(rememberCheckbox.checkState === Qt.Checked) }
}
Item {
id: statusBox
anchors.top: logoArea.bottom
anchors.bottom: buttonBox.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 0
anchors.leftMargin: 0
LandingSeparator {
id: topSeparator
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
}
InstallQdsStatusBlock {
id: installQdsStatusBlock
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
visible: !qdsInstalled
}
ProjectInfoStatusBlock {
id: projectInfoStatusBlock
width: parent.width
visible: !installQdsStatusBlock.visible
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
LandingSeparator {
id: bottomSeparator
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
}
Connections {
target: openQtc
function onClicked() { LandingPageApi.openQtc(rememberCheckbox.checkState === Qt.Checked) }
}
Rectangle {
id: buttonBox
width: parent.width
height: 220
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
color: Theme.Values.themeBackgroundColorNormal
Item {
id: openQdsBox
width: parent.width / 2
height: parent.height
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.leftMargin: 0
Text {
id: openQdsText
text: qsTr("Open with Qt Design Studio")
font.pixelSize: Constants.fontSizeSubtitle
font.family: Theme.Values.baseFont
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 50
states: [
State {
name: "large"
when: root.width > Theme.Values.layoutBreakpointLG
PropertyChanges {
target: Theme.Values
fontSizeTitle: Theme.Values.fontSizeTitleLG
fontSizeSubtitle: Theme.Values.fontSizeSubtitleLG
}
PushButton {
id: openQds
anchors.top: openQdsText.bottom
anchors.horizontalCenter: parent.horizontalCenter
text: "Open"
anchors.topMargin: Constants.buttonSmallMargin
enabled: qdsInstalled
PropertyChanges {
target: buttonBoxGrid
columns: 2
}
},
State {
name: "medium"
when: root.width <= Theme.Values.layoutBreakpointLG
&& root.width > Theme.Values.layoutBreakpointMD
PropertyChanges {
target: Theme.Values
fontSizeTitle: Theme.Values.fontSizeTitleMD
fontSizeSubtitle: Theme.Values.fontSizeSubtitleMD
}
PropertyChanges {
target: buttonBoxGrid
columns: 2
}
},
State {
name: "small"
when: root.width <= Theme.Values.layoutBreakpointMD
PropertyChanges {
target: Theme.Values
fontSizeTitle: Theme.Values.fontSizeTitleSM
fontSizeSubtitle: Theme.Values.fontSizeSubtitleSM
}
PropertyChanges {
target: buttonBoxGrid
columns: 1
}
}
]
Item {
id: openQtcBox
width: parent.width / 2
height: parent.height
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.rightMargin: 0
ScrollView {
id: scrollView
anchors.fill: root
Text {
id: openQtcText
text: qsTr("Open with Qt Creator - Text Mode")
font.pixelSize: Constants.fontSizeSubtitle
font.family: Theme.Values.baseFont
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 50
Column {
id: layout
spacing: 0
width: scrollView.width
Item {
width: layout.width
height: logoSection.childrenRect.height + (2 * Theme.Values.spacing)
Column {
id: logoSection
spacing: 10
anchors.centerIn: parent
Image {
id: qdsLogo
anchors.horizontalCenter: parent.horizontalCenter
source: "logo.png"
}
Text {
id: qdsText
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Qt Design Studio")
font.pixelSize: Theme.Values.fontSizeTitle
font.family: Theme.Values.baseFont
color: Theme.Colors.text
}
}
}
PushButton {
id: openQtc
anchors.top: openQtcText.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: Constants.buttonSmallMargin
text: "Open"
InstallQdsStatusBlock {
id: installQdsStatusBlock
width: parent.width
visible: !LandingPageApi.qdsInstalled
}
}
CheckBox {
id: rememberCheckbox
text: qsTr("Remember my choice")
font.family: Theme.Values.baseFont
anchors.bottom: parent.bottom
anchors.bottomMargin: 30
anchors.horizontalCenter: parent.horizontalCenter
ProjectInfoStatusBlock {
id: projectInfoStatusBlock
width: parent.width
visible: !installQdsStatusBlock.visible
projectFileExists: LandingPageApi.projectFileExists
qtVersion: LandingPageApi.qtVersion
qdsVersion: LandingPageApi.qdsVersion
}
GridLayout {
id: buttonBoxGrid
anchors.horizontalCenter: parent.horizontalCenter
columns: 2
rows: 2
columnSpacing: 3 * Theme.Values.spacing
rowSpacing: Theme.Values.spacing
property int tmpWidth: textMetrics.width
TextMetrics {
id: textMetrics
text: openQtcText.text.length > openQdsText.text.length ? openQtcText.text
: openQdsText.text
font.pixelSize: Theme.Values.fontSizeSubtitle
font.family: Theme.Values.baseFont
}
Column {
id: openQdsBox
Layout.alignment: Qt.AlignHCenter
PageText {
id: openQdsText
width: buttonBoxGrid.tmpWidth
padding: Theme.Values.spacing
text: qsTr("Open with Qt Design Studio")
wrapMode: Text.NoWrap
}
PushButton {
id: openQds
text: qsTr("Open")
enabled: LandingPageApi.qdsInstalled
anchors.horizontalCenter: parent.horizontalCenter
}
}
Column {
id: openQtcBox
Layout.alignment: Qt.AlignHCenter
PageText {
id: openQtcText
width: buttonBoxGrid.tmpWidth
padding: Theme.Values.spacing
text: qsTr("Open with Qt Creator - Text Mode")
wrapMode: Text.NoWrap
}
PushButton {
id: openQtc
text: qsTr("Open")
anchors.horizontalCenter: parent.horizontalCenter
}
}
CustomCheckBox {
id: rememberCheckbox
text: qsTr("Remember my choice")
font.family: Theme.Values.baseFont
Layout.columnSpan: buttonBoxGrid.columns
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: Theme.Values.spacing
Layout.bottomMargin: Theme.Values.spacing
}
}
}
}
}

View File

@ -24,12 +24,16 @@
****************************************************************************/
pragma Singleton
import QtQuick 2.10
import QtQuick 2.15
QtObject {
readonly property int buttonDefaultMargin: 30
readonly property int buttonSmallMargin: 20
readonly property int fontSizeTitle: 55
readonly property int fontSizeSubtitle: 22
readonly property color text: "#ffe7e7e7"
readonly property color foregroundPrimary: "#ffa3a3a3"
readonly property color foregroundSecondary: "#ff808080"
readonly property color backgroundPrimary: "#ff333333"
readonly property color backgroundSecondary: "#ff232323"
readonly property color hover: "#ff404040"
readonly property color accent: "#ff57d658"
readonly property color link: "#ff67e668"
readonly property color disabledLink: "#7fffffff"
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
@ -23,18 +23,18 @@
**
****************************************************************************/
#pragma once
pragma Singleton
import QtQuick 2.15
import LandingPageTheme
#include <clang-c/Index.h>
inline
bool operator==(const CXSourceLocation &first, const CXSourceLocation &second)
{
return clang_equalLocations(first, second);
}
inline
bool operator==(const CXSourceRange &first, const CXSourceRange &second)
{
return clang_equalRanges(first, second);
QtObject {
readonly property color text: Theme.color(Theme.Welcome_TextColor)
readonly property color foregroundPrimary: Theme.color(Theme.Welcome_ForegroundPrimaryColor)
readonly property color foregroundSecondary: Theme.color(Theme.Welcome_ForegroundSecondaryColor)
readonly property color backgroundPrimary: Theme.color(Theme.Welcome_BackgroundPrimaryColor)
readonly property color backgroundSecondary: Theme.color(Theme.Welcome_BackgroundSecondaryColor)
readonly property color hover: Theme.color(Theme.Welcome_HoverColor)
readonly property color accent: Theme.color(Theme.Welcome_AccentColor)
readonly property color link: Theme.color(Theme.Welcome_LinkColor)
readonly property color disabledLink: Theme.color(Theme.Welcome_DisabledLinkColor)
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
@ -23,33 +23,34 @@
**
****************************************************************************/
#include "googletest.h"
pragma Singleton
import QtQuick 2.15
namespace {
QtObject {
id: values
using ::testing::PrintToString;
property string baseFont: "TitilliumWeb"
MATCHER_P(IsDiagnosticContainer, diagnosticContainer, "")
{
if (arg.text != diagnosticContainer.text) {
*result_listener << "text is " + PrintToString(arg.text)
+ " and not " + PrintToString(diagnosticContainer.text);
return false;
}
property real scaleFactor: 1.0
property real checkBoxSize: Math.round(26 * values.scaleFactor)
property real checkBoxIndicatorSize: Math.round(14 * values.scaleFactor)
property real checkBoxSpacing: Math.round(6 * values.scaleFactor)
property real border: 1
if (arg.location != diagnosticContainer.location) {
*result_listener << "location is " + PrintToString(arg.location)
+ " and not " + PrintToString(diagnosticContainer.location);
return false;
}
property int fontSizeTitle: values.fontSizeTitleLG
property int fontSizeSubtitle: values.fontSizeSubtitleLG
if (arg.children != diagnosticContainer.children) {
*result_listener << "children are " + PrintToString(arg.children)
+ " and not " + PrintToString(diagnosticContainer.children);
return false;
}
readonly property int fontSizeTitleSM: 20
readonly property int fontSizeTitleMD: 32
readonly property int fontSizeTitleLG: 50
return true;
readonly property int fontSizeSubtitleSM: 14
readonly property int fontSizeSubtitleMD: 18
readonly property int fontSizeSubtitleLG: 22
// LG > 1000, MD <= 1000 && > 720, SM <= 720
readonly property int layoutBreakpointLG: 1000
readonly property int layoutBreakpointMD: 720
readonly property int spacing: 20
}
} // anonymous

View File

@ -1 +1,2 @@
singleton Constants 1.0 Constants.qml
singleton Values 1.0 Values.qml
singleton Colors 1.0 Colors.qml

View File

@ -1,312 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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
** 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.
**
** 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.
**
****************************************************************************/
pragma Singleton
import QtQuick 2.15
import LandingPageTheme
QtObject {
id: values
property string baseFont: "TitilliumWeb"
property real baseHeight: 29
property real baseFontSize: 12
property real baseIconFont: 12
property real scaleFactor: 1.0
property real height: Math.round(values.baseHeight * values.scaleFactor)
property real myFontSize: Math.round(values.baseFont * values.scaleFactor)
property real myIconFontSize: Math.round(values.baseIconFont * values.scaleFactor)
property real squareComponentWidth: values.height
property real smallRectWidth: values.height / 2 * 1.5
property real inputWidth: values.height * 4
property real sliderHeight: values.height / 2 * 1.5 // TODO:Have a look at -> sliderAreaHeight: Data.Values.height/2*1.5
property real sliderControlSize: 12
property real sliderControlSizeMulti: values.sliderControlSize * values.scaleFactor
property int dragThreshold: 10 // px
property real spinControlIconSize: 8
property real spinControlIconSizeMulti: values.spinControlIconSize * values.scaleFactor
property real sliderTrackHeight: values.height / 3
property real sliderHandleHeight: values.sliderTrackHeight * 1.8
property real sliderHandleWidth: values.sliderTrackHeight * 0.5
property real sliderFontSize: Math.round(8 * values.scaleFactor)
property real sliderPadding: Math.round(6 * values.scaleFactor)
property real sliderMargin: Math.round(3 * values.scaleFactor)
property real sliderPointerWidth: Math.round(7 * values.scaleFactor)
property real sliderPointerHeight: Math.round(2 * values.scaleFactor)
property real checkBoxSpacing: Math.round(6 * values.scaleFactor)
property real radioButtonSpacing: values.checkBoxSpacing
property real radioButtonWidth: values.height
property real radioButtonHeight: values.height
property real radioButtonIndicatorWidth: 14
property real radioButtonIndicatorHeight: 14
property real switchSpacing: values.checkBoxSpacing
property real columnWidth: 225 + (175 * (values.scaleFactor * 2))
property real marginTopBottom: 4
property real border: 1
property real maxComboBoxPopupHeight: Math.round(300 * values.scaleFactor)
property real maxTextAreaPopupHeight: Math.round(150 * values.scaleFactor)
property real contextMenuLabelSpacing: Math.round(30 * values.scaleFactor)
property real contextMenuHorizontalPadding: Math.round(6 * values.scaleFactor)
property real inputHorizontalPadding: Math.round(6 * values.scaleFactor)
property real typeLabelVerticalShift: Math.round(6 * values.scaleFactor)
property real scrollBarThickness: 10
property real scrollBarActivePadding: 1
property real scrollBarInactivePadding: 2
property real toolTipHeight: 25
property int toolTipDelay: 1000
// Controls hover animation params
property int hoverDuration: 500
property int hoverEasing: Easing.OutExpo
// Layout sizes
property real sectionColumnSpacing: 20 // distance between label and sliderControlSize
property real sectionRowSpacing: 5
property real sectionHeadGap: 15
property real sectionHeadHeight: 21 // tab and section
property real sectionHeadSpacerHeight: 10
property real controlLabelWidth: 15
property real controlLabelGap: 5
property real controlGap: 5 // TODO different name
property real twoControlColumnGap: values.controlLabelGap
+ values.controlLabelWidth
+ values.controlGap
property real columnGap: 10
property real iconAreaWidth: Math.round(21 * values.scaleFactor)
property real linkControlWidth: values.iconAreaWidth
property real linkControlHeight: values.height
property real infinityControlWidth: values.iconAreaWidth
property real infinityControlHeight: values.height
property real transform3DSectionSpacing: 15
// Control sizes
property real defaultControlWidth: values.squareComponentWidth * 5
property real defaultControlHeight: values.height
property real actionIndicatorWidth: values.iconAreaWidth //StudioTheme.Values.squareComponentWidth
property real actionIndicatorHeight: values.height
property real spinBoxIndicatorWidth: values.smallRectWidth - 2 * values.border
property real spinBoxIndicatorHeight: values.height / 2 - values.border
property real sliderIndicatorWidth: values.squareComponentWidth
property real sliderIndicatorHeight: values.height
property real translationIndicatorWidth: values.squareComponentWidth
property real translationIndicatorHeight: values.height
property real checkIndicatorWidth: values.squareComponentWidth
property real checkIndicatorHeight: values.height
property real singleControlColumnWidth: 2 * values.twoControlColumnWidth
+ values.twoControlColumnGap
+ values.actionIndicatorWidth
property real twoControlColumnWidthMin: 3 * values.height - 2 * values.border
property real twoControlColumnWidthMax: 3 * values.twoControlColumnWidthMin
property real twoControlColumnWidth: values.twoControlColumnWidthMin
property real controlColumnWithoutControlsWidth: 2 * (values.actionIndicatorWidth
+ values.twoControlColumnGap)
+ values.linkControlWidth
property real controlColumnWidth: values.controlColumnWithoutControlsWidth
+ 2 * values.twoControlColumnWidth
property real controlColumnWidthMin: values.controlColumnWithoutControlsWidth
+ 2 * values.twoControlColumnWidthMin
property real propertyLabelWidthMin: 80
property real propertyLabelWidthMax: 120
property real propertyLabelWidth: values.propertyLabelWidthMin
property real sectionLeftPadding: 8
property real sectionLayoutRightPadding: values.scrollBarThickness + 6
property real columnFactor: values.propertyLabelWidthMin
/ (values.propertyLabelWidthMin + values.controlColumnWidthMin)
function responsiveResize(width) {
var tmpWidth = width - values.sectionColumnSpacing
- values.sectionLeftPadding - values.sectionLayoutRightPadding
var labelColumnWidth = Math.round(tmpWidth * values.columnFactor)
labelColumnWidth = Math.max(Math.min(values.propertyLabelWidthMax, labelColumnWidth),
values.propertyLabelWidthMin)
var controlColumnWidth = tmpWidth - labelColumnWidth
var controlWidth = Math.round((controlColumnWidth - values.controlColumnWithoutControlsWidth) * 0.5)
controlWidth = Math.max(Math.min(values.twoControlColumnWidthMax, controlWidth),
values.twoControlColumnWidthMin)
values.propertyLabelWidth = labelColumnWidth
values.twoControlColumnWidth = controlWidth
}
// Color Editor Popup
property real colorEditorPopupWidth: 4 * values.colorEditorPopupSpinBoxWidth
+ 3 * values.controlGap
+ 2 * values.colorEditorPopupPadding
property real colorEditorPopupHeight: 800
property real colorEditorPopupPadding: 10
property real colorEditorPopupMargin: 20
property real colorEditorPopupSpacing: 10
property real colorEditorPopupLineHeight: 60
property real hueSliderHeight: 20
property real hueSliderHandleWidth: 10
property real colorEditorPopupCmoboBoxWidth: 110
property real colorEditorPopupSpinBoxWidth: 54
// Theme Colors
property bool isLightTheme: themeControlBackground.hsvValue > themeTextColor.hsvValue
property string themePanelBackground: Theme.color(Theme.DSpanelBackground)
property string themeGreenLight: Theme.color(Theme.DSgreenLight)
property string themeAmberLight: Theme.color(Theme.DSamberLight)
property string themeRedLight: Theme.color(Theme.DSredLight)
property string themeInteraction: Theme.color(Theme.DSinteraction)
property string themeError: Theme.color(Theme.DSerrorColor)
property string themeWarning: Theme.color(Theme.DSwarningColor)
property string themeDisabled: Theme.color(Theme.DSdisabledColor)
property string themeInteractionHover: Theme.color(Theme.DSinteractionHover)
property string themeAliasIconChecked: Theme.color(Theme.DSnavigatorAliasIconChecked)
// Control colors
property color themeControlBackground: Theme.color(Theme.DScontrolBackground)
property string themeControlBackgroundInteraction: Theme.color(Theme.DScontrolBackgroundInteraction)
property string themeControlBackgroundDisabled: Theme.color(Theme.DScontrolBackgroundDisabled)
property string themeControlBackgroundGlobalHover: Theme.color(Theme.DScontrolBackgroundGlobalHover)
property string themeControlBackgroundHover: Theme.color(Theme.DScontrolBackgroundHover)
property string themeControlOutline: Theme.color(Theme.DScontrolOutline)
property string themeControlOutlineInteraction: Theme.color(Theme.DScontrolOutlineInteraction)
property string themeControlOutlineDisabled: Theme.color(Theme.DScontrolOutlineDisabled)
// Panels & Panes
property string themeBackgroundColorNormal: Theme.color(Theme.DSBackgroundColorNormal)
property string themeBackgroundColorAlternate: Theme.color(Theme.DSBackgroundColorAlternate)
// Text colors
property color themeTextColor: Theme.color(Theme.DStextColor)
property string themeTextColorDisabled: Theme.color(Theme.DStextColorDisabled)
property string themeTextSelectionColor: Theme.color(Theme.DStextSelectionColor)
property string themeTextSelectedTextColor: Theme.color(Theme.DStextSelectedTextColor)
property string themeTextColorDisabledMCU: Theme.color(Theme.DStextColorDisabled)
property string themePlaceholderTextColor: Theme.color(Theme.DSplaceholderTextColor)
property string themePlaceholderTextColorInteraction: Theme.color(Theme.DSplaceholderTextColorInteraction)
// Icon colors
property string themeIconColor: Theme.color(Theme.DSiconColor)
property string themeIconColorHover: Theme.color(Theme.DSiconColorHover)
property string themeIconColorInteraction: Theme.color(Theme.DSiconColorInteraction)
property string themeIconColorDisabled: Theme.color(Theme.DSiconColorDisabled)
property string themeIconColorSelected: Theme.color(Theme.DSiconColorSelected)
property string themeLinkIndicatorColor: Theme.color(Theme.DSlinkIndicatorColor)
property string themeLinkIndicatorColorHover: Theme.color(Theme.DSlinkIndicatorColorHover)
property string themeLinkIndicatorColorInteraction: Theme.color(Theme.DSlinkIndicatorColorInteraction)
property string themeLinkIndicatorColorDisabled: Theme.color(Theme.DSlinkIndicatorColorDisabled)
property string themeInfiniteLoopIndicatorColor: Theme.color(Theme.DSlinkIndicatorColor)
property string themeInfiniteLoopIndicatorColorHover: Theme.color(Theme.DSlinkIndicatorColorHover)
property string themeInfiniteLoopIndicatorColorInteraction: Theme.color(Theme.DSlinkIndicatorColorInteraction)
// Popup background color (ComboBox, SpinBox, TextArea)
property string themePopupBackground: Theme.color(Theme.DSpopupBackground)
// GradientPopupDialog modal overly color
property string themePopupOverlayColor: Theme.color(Theme.DSpopupOverlayColor)
// ToolTip (UrlChooser)
property string themeToolTipBackground: Theme.color(Theme.DStoolTipBackground)
property string themeToolTipOutline: Theme.color(Theme.DStoolTipOutline)
property string themeToolTipText: Theme.color(Theme.DStoolTipText)
// Slider colors
property string themeSliderActiveTrack: Theme.color(Theme.DSsliderActiveTrack)
property string themeSliderActiveTrackHover: Theme.color(Theme.DSactiveTrackHover)
property string themeSliderActiveTrackFocus: Theme.color(Theme.DSsliderActiveTrackFocus)
property string themeSliderInactiveTrack: Theme.color(Theme.DSsliderInactiveTrack)
property string themeSliderInactiveTrackHover: Theme.color(Theme.DSsliderInactiveTrackHover)
property string themeSliderInactiveTrackFocus: Theme.color(Theme.DSsliderInactiveTrackFocus)
property string themeSliderHandle: Theme.color(Theme.DSsliderHandle)
property string themeSliderHandleHover: Theme.color(Theme.DSsliderHandleHover)
property string themeSliderHandleFocus: Theme.color(Theme.DSsliderHandleFocus)
property string themeSliderHandleInteraction: Theme.color(Theme.DSsliderHandleInteraction)
property string themeScrollBarTrack: Theme.color(Theme.DSscrollBarTrack)
property string themeScrollBarHandle: Theme.color(Theme.DSscrollBarHandle)
property string themeSectionHeadBackground: Theme.color(Theme.DSsectionHeadBackground)
property string themeTabActiveBackground: Theme.color(Theme.DStabActiveBackground)
property string themeTabActiveText: Theme.color(Theme.DStabActiveText)
property string themeTabInactiveBackground: Theme.color(Theme.DStabInactiveBackground)
property string themeTabInactiveText: Theme.color(Theme.DStabInactiveText)
property string themeStateSeparator: Theme.color(Theme.DSstateSeparatorColor)
property string themeStateBackground: Theme.color(Theme.DSstateBackgroundColor)
property string themeStatePreviewOutline: Theme.color(Theme.DSstatePreviewOutline)
property string themeUnimportedModuleColor: Theme.color(Theme.DSUnimportedModuleColor)
// Taken out of Constants.js
property string themeChangedStateText: Theme.color(Theme.DSchangedStateText)
}

View File

@ -1 +0,0 @@
singleton Values 1.0 Values.qml

View File

@ -12,6 +12,10 @@ Project {
directory: "imports"
}
QmlFiles {
directory: "mockimports"
}
JavaScriptFiles {
directory: "content"
}
@ -69,11 +73,14 @@ Project {
*/
}
/* List of plugin directories passed to QML runtime */
importPaths: [ "imports", "../../../../share/3rdparty/studiofonts" ]
importPaths: [ "imports", "../../../../src/share/3rdparty/studiofonts", "mockimports" ]
fileSelectors: [ "QDS_theming" ]
qt6Project: true
qdsVersion: "3.2"
mainUiFile: "content/Screen01.ui.qml"
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
@ -23,23 +23,22 @@
**
****************************************************************************/
void function()
{
}
class Foo;
void functionWithArguments(int i, char *c, const Foo &ref)
{
}
void otherFunction()
{
}
void f()
{
pragma Singleton
import QtQuick 2.15
import StudioFonts
QtObject {
property bool qdsInstalled: true
property bool projectFileExists: true
property string qtVersion: "6.1"
property string qdsVersion: "3.6"
function openQtc(rememberSelection) { console.log("openQtc", rememberSelection) }
function openQds(rememberSelection) { console.log("openQds", rememberSelection) }
function installQds() { console.log("installQds") }
function generateProjectFile() { console.log("generateProjectFile") }
// This property ensures that the Titillium font will be loaded and
// can be used by the theme.
property string family: StudioFonts.titilliumWeb_regular
}

View File

@ -0,0 +1 @@
singleton LandingPageApi 1.0 LandingPageApi.qml

View File

@ -28,13 +28,5 @@
****************************************************************************/
import QtQuick 2.15
import QtQuick.Controls 2.15
import QdsLandingPageTheme as Theme
Rectangle {
color: Theme.Values.themeControlBackground
width: parent.width
height: 2
z: 10
anchors.horizontalCenter: parent.horizontalCenter
}
QtObject {}

View File

@ -0,0 +1 @@
Dummy 1.0 Dummy.qml

View File

@ -37,4 +37,5 @@ else()
endif()
@endif
install(TARGETS %{ProjectName})
install(TARGETS %{ProjectName}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -4,4 +4,5 @@ project(%{ProjectName} LANGUAGES C)
add_executable(%{ProjectName} %{CFileName})
install(TARGETS %{ProjectName})
install(TARGETS %{ProjectName}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -7,4 +7,5 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(%{ProjectName} %{CppFileName})
install(TARGETS %{ProjectName})
install(TARGETS %{ProjectName}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -28,4 +28,6 @@ set_target_properties(%{TargetName} PROPERTIES
target_link_libraries(%{TargetName}
PRIVATE Qt6::Quick)
install(TARGETS %{TargetName} BUNDLE DESTINATION .)
install(TARGETS %{TargetName}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -71,7 +71,9 @@ set_target_properties(%{ProjectName} PROPERTIES
WIN32_EXECUTABLE TRUE
)
install(TARGETS %{ProjectName} BUNDLE DESTINATION .)
install(TARGETS %{ProjectName}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_import_qml_plugins(%{ProjectName})

View File

@ -74,7 +74,9 @@ set_target_properties(%{ProjectName} PROPERTIES
WIN32_EXECUTABLE TRUE
)
install(TARGETS %{ProjectName} BUNDLE DESTINATION .)
install(TARGETS %{ProjectName}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(%{ProjectName})

File diff suppressed because it is too large Load Diff

View File

@ -2024,7 +2024,7 @@ bool Bind::visit(SimpleDeclarationAST *ast)
decl->setInitializer(asStringLiteral(initializer));
}
if (_scope->isClass()) {
if (_scope->asClass()) {
decl->setVisibility(_visibility);
if (Function *funTy = decl->type()->asFunctionType()) {
@ -2050,7 +2050,7 @@ bool Bind::visit(EmptyDeclarationAST *ast)
{
(void) ast;
int semicolon_token = ast->semicolon_token;
if (_scope && (_scope->isClass() || _scope->isNamespace())) {
if (_scope && (_scope->asClass() || _scope->asNamespace())) {
const Token &tk = tokenAt(semicolon_token);
if (! tk.generated())
@ -2227,7 +2227,7 @@ bool Bind::visit(AliasDeclarationAST *ast)
decl->setType(ty);
decl->setStorage(Symbol::Typedef);
ast->symbol = decl;
if (_scope->isClass())
if (_scope->asClass())
decl->setVisibility(_visibility);
_scope->addMember(decl);
@ -2299,7 +2299,7 @@ bool Bind::visit(FunctionDefinitionAST *ast)
setDeclSpecifiers(fun, declSpecifiers);
fun->setEndOffset(tokenAt(ast->lastToken() - 1).utf16charsEnd());
if (_scope->isClass()) {
if (_scope->asClass()) {
fun->setVisibility(_visibility);
fun->setMethodKey(methodKey);
}
@ -3147,7 +3147,7 @@ bool Bind::visit(ClassSpecifierAST *ast)
klass->setEndOffset(tokenAt(ast->lastToken() - 1).utf16charsEnd());
_scope->addMember(klass);
if (_scope->isClass())
if (_scope->asClass())
klass->setVisibility(_visibility);
// set the class key
@ -3210,7 +3210,7 @@ bool Bind::visit(EnumSpecifierAST *ast)
ast->symbol = e;
_scope->addMember(e);
if (_scope->isClass())
if (_scope->asClass())
e->setVisibility(_visibility);
Scope *previousScope = switchScope(e);
@ -3398,7 +3398,7 @@ void Bind::ensureValidClassName(const Name **name, int sourceLocation)
const QualifiedNameId *qName = (*name)->asQualifiedNameId();
const Name *uqName = qName ? qName->name() : *name;
if (!uqName->isNameId() && !uqName->isTemplateNameId()) {
if (!uqName->asNameId() && !uqName->asTemplateNameId()) {
translationUnit()->error(sourceLocation, "expected a class-name");
*name = uqName->identifier();

View File

@ -21,10 +21,11 @@
#include "CoreTypes.h"
#include "TypeVisitor.h"
#include "Matcher.h"
#include "Names.h"
#include <algorithm>
using namespace CPlusPlus;
namespace CPlusPlus {
UndefinedType UndefinedType::instance;
void UndefinedType::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
@ -204,3 +205,5 @@ bool NamedType::match0(const Type *otherType, Matcher *matcher) const
return false;
}
} // CPlusPlus

View File

@ -29,11 +29,7 @@ namespace CPlusPlus {
class CPLUSPLUS_EXPORT UndefinedType : public Type
{
public:
static UndefinedType *instance()
{
static UndefinedType t;
return &t;
}
static UndefinedType instance;
const UndefinedType *asUndefinedType() const override
{ return this; }

View File

@ -26,24 +26,20 @@
using namespace CPlusPlus;
FullySpecifiedType::FullySpecifiedType() :
_type(&UndefinedType::instance), _flags(0)
{}
FullySpecifiedType::FullySpecifiedType(Type *type) :
_type(type), _flags(0)
{
if (! type)
_type = UndefinedType::instance();
_type = &UndefinedType::instance;
}
FullySpecifiedType::~FullySpecifiedType()
{ }
bool FullySpecifiedType::isValid() const
{ return _type != UndefinedType::instance(); }
{ return _type != &UndefinedType::instance; }
Type *FullySpecifiedType::type() const
{ return _type; }
void FullySpecifiedType::setType(Type *type)
{ _type = type; }
FullySpecifiedType FullySpecifiedType::qualifiedType() const
{
@ -178,7 +174,7 @@ Type &FullySpecifiedType::operator*()
{ return *_type; }
FullySpecifiedType::operator bool() const
{ return _type != UndefinedType::instance(); }
{ return _type != &UndefinedType::instance; }
const Type &FullySpecifiedType::operator*() const
{ return *_type; }
@ -215,12 +211,6 @@ FullySpecifiedType FullySpecifiedType::simplified() const
return *this;
}
unsigned FullySpecifiedType::flags() const
{ return _flags; }
void FullySpecifiedType::setFlags(unsigned flags)
{ _flags = flags; }
bool FullySpecifiedType::match(const FullySpecifiedType &otherTy, Matcher *matcher) const
{
static const unsigned flagsMask = [](){

View File

@ -25,17 +25,18 @@
namespace CPlusPlus {
class CPLUSPLUS_EXPORT FullySpecifiedType
class CPLUSPLUS_EXPORT FullySpecifiedType final
{
public:
FullySpecifiedType(Type *type = nullptr);
~FullySpecifiedType();
FullySpecifiedType();
FullySpecifiedType(Type *type);
~FullySpecifiedType() = default;
bool isValid() const;
explicit operator bool() const;
Type *type() const;
void setType(Type *type);
Type *type() const { return _type; }
void setType(Type *type) { _type = type; }
FullySpecifiedType qualifiedType() const;
@ -109,8 +110,8 @@ public:
FullySpecifiedType simplified() const;
unsigned flags() const;
void setFlags(unsigned flags);
unsigned flags() const { return _flags; }
void setFlags(unsigned flags) { _flags = flags; }
private:
Type *_type;

View File

@ -105,7 +105,7 @@ private:
};
};
class CPLUSPLUS_EXPORT Identifier: public Literal, public Name
class CPLUSPLUS_EXPORT Identifier final : public Literal, public Name
{
public:
Identifier(const char *chars, int size)
@ -114,8 +114,7 @@ public:
const Identifier *identifier() const override { return this; }
const Identifier *asNameId() const override
{ return this; }
const Identifier *asNameId() const override { return this; }
protected:
void accept0(NameVisitor *visitor) const override;

View File

@ -35,30 +35,6 @@ Name::Name()
Name::~Name()
{ }
bool Name::isNameId() const
{ return asNameId() != nullptr; }
bool Name::isAnonymousNameId() const
{ return asAnonymousNameId() != nullptr; }
bool Name::isTemplateNameId() const
{ return asTemplateNameId() != nullptr; }
bool Name::isDestructorNameId() const
{ return asDestructorNameId() != nullptr; }
bool Name::isOperatorNameId() const
{ return asOperatorNameId() != nullptr; }
bool Name::isConversionNameId() const
{ return asConversionNameId() != nullptr; }
bool Name::isQualifiedNameId() const
{ return asQualifiedNameId() != nullptr; }
bool Name::isSelectorNameId() const
{ return asSelectorNameId() != nullptr; }
void Name::accept(NameVisitor *visitor) const
{
if (visitor->preVisit(this))

View File

@ -35,15 +35,6 @@ public:
virtual const Identifier *identifier() const = 0;
bool isNameId() const;
bool isAnonymousNameId() const;
bool isTemplateNameId() const;
bool isDestructorNameId() const;
bool isOperatorNameId() const;
bool isConversionNameId() const;
bool isQualifiedNameId() const;
bool isSelectorNameId() const;
virtual const Identifier *asNameId() const { return nullptr; }
virtual const AnonymousNameId *asAnonymousNameId() const { return nullptr; }
virtual const TemplateNameId *asTemplateNameId() const { return nullptr; }

View File

@ -171,9 +171,6 @@ bool OperatorNameId::match0(const Name *otherName, Matcher *matcher) const
OperatorNameId::Kind OperatorNameId::kind() const
{ return _kind; }
const Identifier *OperatorNameId::identifier() const
{ return nullptr; }
ConversionNameId::ConversionNameId(const FullySpecifiedType &type)
: _type(type)
{ }
@ -191,11 +188,7 @@ bool ConversionNameId::match0(const Name *otherName, Matcher *matcher) const
return false;
}
FullySpecifiedType ConversionNameId::type() const
{ return _type; }
const Identifier *ConversionNameId::identifier() const
{ return nullptr; }
SelectorNameId::~SelectorNameId()
{ }
@ -249,5 +242,4 @@ bool AnonymousNameId::match0(const Name *otherName, Matcher *matcher) const
return false;
}
const Identifier *AnonymousNameId::identifier() const
{ return nullptr; }

View File

@ -234,10 +234,8 @@ public:
Kind kind() const;
const Identifier *identifier() const override;
const OperatorNameId *asOperatorNameId() const override
{ return this; }
const Identifier *identifier() const override { return nullptr; }
const OperatorNameId *asOperatorNameId() const override { return this; }
protected:
void accept0(NameVisitor *visitor) const override;
@ -253,12 +251,9 @@ public:
ConversionNameId(const FullySpecifiedType &type);
virtual ~ConversionNameId();
FullySpecifiedType type() const;
const Identifier *identifier() const override;
const ConversionNameId *asConversionNameId() const override
{ return this; }
FullySpecifiedType type() const { return _type; }
const Identifier *identifier() const override { return nullptr; }
const ConversionNameId *asConversionNameId() const override { return this; }
protected:
void accept0(NameVisitor *visitor) const override;
@ -300,7 +295,7 @@ private:
bool _hasArguments;
};
class CPLUSPLUS_EXPORT AnonymousNameId: public Name
class CPLUSPLUS_EXPORT AnonymousNameId final : public Name
{
public:
AnonymousNameId(int classTokenIndex);
@ -308,10 +303,9 @@ public:
int classTokenIndex() const;
const Identifier *identifier() const override;
const Identifier *identifier() const override { return nullptr; }
const AnonymousNameId *asAnonymousNameId() const override
{ return this; }
const AnonymousNameId *asAnonymousNameId() const override { return this; }
protected:
void accept0(NameVisitor *visitor) const override;

View File

@ -154,7 +154,7 @@ Symbol *SymbolTable::lookat(const Identifier *id) const
} else if (const DestructorNameId *d = identity->asDestructorNameId()) {
if (d->identifier()->match(id))
break;
} else if (identity->isQualifiedNameId()) {
} else if (identity->asQualifiedNameId()) {
return nullptr;
} else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
if (selectorNameId->identifier()->match(id))

View File

@ -142,23 +142,7 @@ void Symbol::visitSymbol(Symbol *symbol, SymbolVisitor *visitor)
symbol->visitSymbol(visitor);
}
int Symbol::sourceLocation() const
{ return _sourceLocation; }
bool Symbol::isGenerated() const
{ return _isGenerated; }
bool Symbol::isDeprecated() const
{ return _isDeprecated; }
void Symbol::setDeprecated(bool isDeprecated)
{ _isDeprecated = isDeprecated; }
bool Symbol::isUnavailable() const
{ return _isUnavailable; }
void Symbol::setUnavailable(bool isUnavailable)
{ _isUnavailable = isUnavailable; }
void Symbol::setSourceLocation(int sourceLocation, TranslationUnit *translationUnit)
{
@ -176,21 +160,6 @@ void Symbol::setSourceLocation(int sourceLocation, TranslationUnit *translationU
}
}
int Symbol::line() const
{
return _line;
}
int Symbol::column() const
{
return _column;
}
const StringLiteral *Symbol::fileId() const
{
return _fileId;
}
const char *Symbol::fileName() const
{ return _fileId ? _fileId->chars() : ""; }
@ -208,9 +177,6 @@ const Name *Symbol::unqualifiedName() const
return _name;
}
const Name *Symbol::name() const
{ return _name; }
void Symbol::setName(const Name *name)
{
_name = name;
@ -231,9 +197,6 @@ const Identifier *Symbol::identifier() const
return nullptr;
}
Scope *Symbol::enclosingScope() const
{ return _enclosingScope; }
void Symbol::setEnclosingScope(Scope *scope)
{
CPP_CHECK(! _enclosingScope);
@ -299,126 +262,6 @@ Block *Symbol::enclosingBlock() const
return nullptr;
}
unsigned Symbol::index() const
{ return _index; }
Symbol *Symbol::next() const
{ return _next; }
unsigned Symbol::hashCode() const
{ return _hashCode; }
int Symbol::storage() const
{ return _storage; }
void Symbol::setStorage(int storage)
{ _storage = storage; }
int Symbol::visibility() const
{ return _visibility; }
void Symbol::setVisibility(int visibility)
{ _visibility = visibility; }
bool Symbol::isFriend() const
{ return _storage == Friend; }
bool Symbol::isRegister() const
{ return _storage == Register; }
bool Symbol::isStatic() const
{ return _storage == Static; }
bool Symbol::isExtern() const
{ return _storage == Extern; }
bool Symbol::isMutable() const
{ return _storage == Mutable; }
bool Symbol::isTypedef() const
{ return _storage == Typedef; }
bool Symbol::isPublic() const
{ return _visibility == Public; }
bool Symbol::isProtected() const
{ return _visibility == Protected; }
bool Symbol::isPrivate() const
{ return _visibility == Private; }
bool Symbol::isScope() const
{ return asScope() != nullptr; }
bool Symbol::isEnum() const
{ return asEnum() != nullptr; }
bool Symbol::isFunction() const
{ return asFunction() != nullptr; }
bool Symbol::isNamespace() const
{ return asNamespace() != nullptr; }
bool Symbol::isTemplate() const
{ return asTemplate() != nullptr; }
bool Symbol::isClass() const
{ return asClass() != nullptr; }
bool Symbol::isForwardClassDeclaration() const
{ return asForwardClassDeclaration() != nullptr; }
bool Symbol::isQtPropertyDeclaration() const
{ return asQtPropertyDeclaration() != nullptr; }
bool Symbol::isQtEnum() const
{ return asQtEnum() != nullptr; }
bool Symbol::isBlock() const
{ return asBlock() != nullptr; }
bool Symbol::isUsingNamespaceDirective() const
{ return asUsingNamespaceDirective() != nullptr; }
bool Symbol::isUsingDeclaration() const
{ return asUsingDeclaration() != nullptr; }
bool Symbol::isDeclaration() const
{ return asDeclaration() != nullptr; }
bool Symbol::isArgument() const
{ return asArgument() != nullptr; }
bool Symbol::isTypenameArgument() const
{ return asTypenameArgument() != nullptr; }
bool Symbol::isBaseClass() const
{ return asBaseClass() != nullptr; }
bool Symbol::isObjCBaseClass() const
{ return asObjCBaseClass() != nullptr; }
bool Symbol::isObjCBaseProtocol() const
{ return asObjCBaseProtocol() != nullptr; }
bool Symbol::isObjCClass() const
{ return asObjCClass() != nullptr; }
bool Symbol::isObjCForwardClassDeclaration() const
{ return asObjCForwardClassDeclaration() != nullptr; }
bool Symbol::isObjCProtocol() const
{ return asObjCProtocol() != nullptr; }
bool Symbol::isObjCForwardProtocolDeclaration() const
{ return asObjCForwardProtocolDeclaration() != nullptr; }
bool Symbol::isObjCMethod() const
{ return asObjCMethod() != nullptr; }
bool Symbol::isObjCPropertyDeclaration() const
{ return asObjCPropertyDeclaration() != nullptr; }
void Symbol::copy(Symbol *other)
{
_sourceLocation = other->_sourceLocation;

View File

@ -61,16 +61,16 @@ public:
virtual ~Symbol();
/// Returns this Symbol's source location.
int sourceLocation() const;
int sourceLocation() const { return _sourceLocation; }
/// \returns this Symbol's line number. The line number is 1-based.
int line() const;
int line() const { return _line; }
/// \returns this Symbol's column number. The column number is 1-based.
int column() const;
int column() const { return _column; }
/// Returns this Symbol's file name.
const StringLiteral *fileId() const;
const StringLiteral *fileId() const { return _fileId; }
/// Returns this Symbol's file name.
const char *fileName() const;
@ -79,7 +79,7 @@ public:
int fileNameLength() const;
/// Returns this Symbol's name.
const Name *name() const;
const Name *name() const { return _name; }
/// Sets this Symbol's name.
void setName(const Name *name); // ### dangerous
@ -88,115 +88,46 @@ public:
const Identifier *identifier() const;
/// Returns this Symbol's storage class specifier.
int storage() const;
int storage() const { return _storage; }
/// Sets this Symbol's storage class specifier.
void setStorage(int storage);
void setStorage(int storage) { _storage = storage; }
/// Returns this Symbol's visibility.
int visibility() const;
int visibility() const { return _visibility; }
/// Sets this Symbol's visibility.
void setVisibility(int visibility);
void setVisibility(int visibility) { _visibility = visibility; }
/// Returns the next chained Symbol.
Symbol *next() const;
Symbol *next() const { return _next; }
/// Returns true if this Symbol has friend storage specifier.
bool isFriend() const;
bool isFriend() const { return _storage == Friend; }
/// Returns true if this Symbol has register storage specifier.
bool isRegister() const;
bool isRegister() const { return _storage == Register; }
/// Returns true if this Symbol has static storage specifier.
bool isStatic() const;
bool isStatic() const { return _storage == Static; }
/// Returns true if this Symbol has extern storage specifier.
bool isExtern() const;
bool isExtern() const { return _storage == Extern; }
/// Returns true if this Symbol has mutable storage specifier.
bool isMutable() const;
bool isMutable() const { return _storage == Mutable; }
/// Returns true if this Symbol has typedef storage specifier.
bool isTypedef() const;
bool isTypedef() const { return _storage == Typedef; }
/// Returns true if this Symbol's visibility is public.
bool isPublic() const;
bool isPublic() const { return _visibility == Public; }
/// Returns true if this Symbol's visibility is protected.
bool isProtected() const;
bool isProtected() const { return _visibility == Protected; }
/// Returns true if this Symbol's visibility is private.
bool isPrivate() const;
/// Returns true if this Symbol is a Scope.
bool isScope() const;
/// Returns true if this Symbol is an Enum.
bool isEnum() const;
/// Returns true if this Symbol is an Function.
bool isFunction() const;
/// Returns true if this Symbol is a Namespace.
bool isNamespace() const;
/// Returns true if this Symbol is a Template.
bool isTemplate() const;
/// Returns true if this Symbol is a Class.
bool isClass() const;
/// Returns true if this Symbol is a Block.
bool isBlock() const;
/// Returns true if this Symbol is a UsingNamespaceDirective.
bool isUsingNamespaceDirective() const;
/// Returns true if this Symbol is a UsingDeclaration.
bool isUsingDeclaration() const;
/// Returns true if this Symbol is a Declaration.
bool isDeclaration() const;
/// Returns true if this Symbol is an Argument.
bool isArgument() const;
/// Returns true if this Symbol is a Typename argument.
bool isTypenameArgument() const;
/// Returns true if this Symbol is a BaseClass.
bool isBaseClass() const;
/// Returns true if this Symbol is a ForwardClassDeclaration.
bool isForwardClassDeclaration() const;
/// Returns true if this Symbol is a QtPropertyDeclaration.
bool isQtPropertyDeclaration() const;
/// Returns true if this Symbol is a QtEnum.
bool isQtEnum() const;
bool isObjCBaseClass() const;
bool isObjCBaseProtocol() const;
/// Returns true if this Symbol is an Objective-C Class declaration.
bool isObjCClass() const;
/// Returns true if this Symbol is an Objective-C Class forward declaration.
bool isObjCForwardClassDeclaration() const;
/// Returns true if this Symbol is an Objective-C Protocol declaration.
bool isObjCProtocol() const;
/// Returns true if this Symbol is an Objective-C Protocol forward declaration.
bool isObjCForwardProtocolDeclaration() const;
/// Returns true if this Symbol is an Objective-C method declaration.
bool isObjCMethod() const;
/// Returns true if this Symbol is an Objective-C @property declaration.
bool isObjCPropertyDeclaration() const;
bool isPrivate() const { return _visibility == Private; }
Utils::Link toLink() const;
@ -226,53 +157,98 @@ public:
virtual const ObjCMethod *asObjCMethod() const { return nullptr; }
virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const { return nullptr; }
/// Returns this Symbol as a Scope.
virtual Scope *asScope() { return nullptr; }
/// Returns this Symbol as an Enum.
virtual Enum *asEnum() { return nullptr; }
/// Returns this Symbol as an Function.
virtual Function *asFunction() { return nullptr; }
/// Returns this Symbol as a Namespace.
virtual Namespace *asNamespace() { return nullptr; }
/// Returns this Symbol as a Template.
virtual Template *asTemplate() { return nullptr; }
virtual NamespaceAlias *asNamespaceAlias() { return nullptr; }
/// Returns this Symbol as a Class.
virtual Class *asClass() { return nullptr; }
/// Returns this Symbol as a Block.
virtual Block *asBlock() { return nullptr; }
/// Returns this Symbol as a UsingNamespaceDirective.
virtual UsingNamespaceDirective *asUsingNamespaceDirective() { return nullptr; }
/// Returns this Symbol as a UsingDeclaration.
virtual UsingDeclaration *asUsingDeclaration() { return nullptr; }
/// Returns this Symbol as a Declaration.
virtual Declaration *asDeclaration() { return nullptr; }
/// Returns this Symbol as an Argument.
virtual Argument *asArgument() { return nullptr; }
/// Returns this Symbol as a Typename argument.
virtual TypenameArgument *asTypenameArgument() { return nullptr; }
/// Returns this Symbol as a BaseClass.
virtual BaseClass *asBaseClass() { return nullptr; }
/// Returns this Symbol as a ForwardClassDeclaration.
virtual ForwardClassDeclaration *asForwardClassDeclaration() { return nullptr; }
/// Returns this Symbol as a QtPropertyDeclaration.
virtual QtPropertyDeclaration *asQtPropertyDeclaration() { return nullptr; }
/// Returns this Symbol as a QtEnum.
virtual QtEnum *asQtEnum() { return nullptr; }
virtual ObjCBaseClass *asObjCBaseClass() { return nullptr; }
virtual ObjCBaseProtocol *asObjCBaseProtocol() { return nullptr; }
/// Returns this Symbol as an Objective-C Class declaration.
virtual ObjCClass *asObjCClass() { return nullptr; }
/// Returns this Symbol as an Objective-C Class forward declaration.
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() { return nullptr; }
/// Returns this Symbol as an Objective-C Protocol declaration.
virtual ObjCProtocol *asObjCProtocol() { return nullptr; }
/// Returns this Symbol as an Objective-C Protocol forward declaration.
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() { return nullptr; }
/// Returns this Symbol as an Objective-C method declaration.
virtual ObjCMethod *asObjCMethod() { return nullptr; }
/// Returns this Symbol as an Objective-C @property declaration.
virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration() { return nullptr; }
/// Returns this Symbol's type.
virtual FullySpecifiedType type() const = 0;
/// Returns this Symbol's hash value.
unsigned hashCode() const;
unsigned hashCode() const { return _hashCode; }
/// Returns this Symbol's index.
unsigned index() const;
unsigned index() const { return _index; }
const Name *unqualifiedName() const;
bool isGenerated() const;
bool isGenerated() const { return _isGenerated; }
bool isDeprecated() const;
void setDeprecated(bool isDeprecated);
bool isDeprecated() const { return _isDeprecated; }
void setDeprecated(bool isDeprecated) { _isDeprecated = isDeprecated; }
bool isUnavailable() const;
void setUnavailable(bool isUnavailable);
bool isUnavailable() const { return _isUnavailable; }
void setUnavailable(bool isUnavailable) { _isUnavailable = isUnavailable; }
/// Returns this Symbol's eclosing scope.
Scope *enclosingScope() const;
Scope *enclosingScope() const { return _enclosingScope; }
/// Returns the eclosing namespace scope.
Namespace *enclosingNamespace() const;

View File

@ -42,15 +42,13 @@ UsingNamespaceDirective::UsingNamespaceDirective(Clone *clone, Subst *subst, Usi
: Symbol(clone, subst, original)
{ }
UsingNamespaceDirective::~UsingNamespaceDirective()
{ }
FullySpecifiedType UsingNamespaceDirective::type() const
{ return FullySpecifiedType(); }
void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
NamespaceAlias::NamespaceAlias(TranslationUnit *translationUnit,
int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), _namespaceName(nullptr)
@ -61,15 +59,6 @@ NamespaceAlias::NamespaceAlias(Clone *clone, Subst *subst, NamespaceAlias *origi
, _namespaceName(clone->name(original->_namespaceName, subst))
{ }
NamespaceAlias::~NamespaceAlias()
{ }
const Name *NamespaceAlias::namespaceName() const
{ return _namespaceName; }
void NamespaceAlias::setNamespaceName(const Name *namespaceName)
{ _namespaceName = namespaceName; }
FullySpecifiedType NamespaceAlias::type() const
{ return FullySpecifiedType(); }
@ -86,15 +75,13 @@ UsingDeclaration::UsingDeclaration(Clone *clone, Subst *subst, UsingDeclaration
: Symbol(clone, subst, original)
{ }
UsingDeclaration::~UsingDeclaration()
{ }
FullySpecifiedType UsingDeclaration::type() const
{ return FullySpecifiedType(); }
void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
void CPlusPlus::UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
Declaration::Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
, _initializer(nullptr)
@ -204,41 +191,16 @@ Declaration::Declaration(Clone *clone, Subst *subst, Declaration *original)
_type = newType;
}
Declaration::~Declaration()
{ }
void Declaration::setType(const FullySpecifiedType &type)
{ _type = type; }
void Declaration::setInitializer(const StringLiteral *initializer)
{
_initializer = initializer;
}
FullySpecifiedType Declaration::type() const
{ return _type; }
const StringLiteral *Declaration::getInitializer() const
{
return _initializer;
}
void Declaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
EnumeratorDeclaration::EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Declaration(translationUnit, sourceLocation, name)
, _constantValue(nullptr)
{}
EnumeratorDeclaration::~EnumeratorDeclaration()
{}
const StringLiteral *EnumeratorDeclaration::constantValue() const
{ return _constantValue; }
void EnumeratorDeclaration::setConstantValue(const StringLiteral *constantValue)
{ _constantValue = constantValue; }
Argument::Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name),
@ -251,27 +213,10 @@ Argument::Argument(Clone *clone, Subst *subst, Argument *original)
, _type(clone->type(original->_type, subst))
{ }
Argument::~Argument()
{ }
bool Argument::hasInitializer() const
{ return _initializer != nullptr; }
const StringLiteral *Argument::initializer() const
{ return _initializer; }
void Argument::setInitializer(const StringLiteral *initializer)
{ _initializer = initializer; }
void Argument::setType(const FullySpecifiedType &type)
{ _type = type; }
FullySpecifiedType Argument::type() const
{ return _type; }
void Argument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
TypenameArgument::TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
, _isClassDeclarator(false)
@ -283,18 +228,10 @@ TypenameArgument::TypenameArgument(Clone *clone, Subst *subst, TypenameArgument
, _isClassDeclarator(original->_isClassDeclarator)
{ }
TypenameArgument::~TypenameArgument()
{ }
void TypenameArgument::setType(const FullySpecifiedType &type)
{ _type = type; }
FullySpecifiedType TypenameArgument::type() const
{ return _type; }
void TypenameArgument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
Function::Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Scope(translationUnit, sourceLocation, name),
_flags(0)
@ -307,27 +244,6 @@ Function::Function(Clone *clone, Subst *subst, Function *original)
, _flags(original->_flags)
{ }
Function::~Function()
{ }
bool Function::isNormal() const
{ return f._methodKey == NormalMethod; }
bool Function::isSignal() const
{ return f._methodKey == SignalMethod; }
bool Function::isSlot() const
{ return f._methodKey == SlotMethod; }
bool Function::isInvokable() const
{ return f._methodKey == InvokableMethod; }
int Function::methodKey() const
{ return f._methodKey; }
void Function::setMethodKey(int key)
{ f._methodKey = key; }
bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const
{
if (! other)
@ -409,12 +325,6 @@ FullySpecifiedType Function::type() const
return ty;
}
FullySpecifiedType Function::returnType() const
{ return _returnType; }
void Function::setReturnType(const FullySpecifiedType &returnType)
{ _returnType = returnType; }
bool Function::hasReturnType() const
{
const FullySpecifiedType ty = returnType();
@ -431,7 +341,7 @@ int Function::argumentCount() const
// arguments with a lambda as default argument will also have more blocks.
int argc = 0;
for (int it = 0; it < memCnt; ++it)
if (memberAt(it)->isArgument())
if (memberAt(it)->asArgument())
++argc;
return argc;
}
@ -470,66 +380,6 @@ int Function::minimumArgumentCount() const
return index;
}
bool Function::isVirtual() const
{ return f._isVirtual; }
void Function::setVirtual(bool isVirtual)
{ f._isVirtual = isVirtual; }
bool Function::isOverride() const
{ return f._isOverride; }
void Function::setOverride(bool isOverride)
{ f._isOverride = isOverride; }
bool Function::isFinal() const
{ return f._isFinal; }
void Function::setFinal(bool isFinal)
{ f._isFinal = isFinal; }
bool Function::isVariadic() const
{ return f._isVariadic; }
void Function::setVariadic(bool isVariadic)
{ f._isVariadic = isVariadic; }
bool Function::isVariadicTemplate() const
{ return f._isVariadicTemplate; }
void Function::setVariadicTemplate(bool isVariadicTemplate)
{ f._isVariadicTemplate = isVariadicTemplate; }
bool Function::isConst() const
{ return f._isConst; }
void Function::setConst(bool isConst)
{ f._isConst = isConst; }
bool Function::isVolatile() const
{ return f._isVolatile; }
void Function::setVolatile(bool isVolatile)
{ f._isVolatile = isVolatile; }
bool Function::isPureVirtual() const
{ return f._isPureVirtual; }
void Function::setPureVirtual(bool isPureVirtual)
{ f._isPureVirtual = isPureVirtual; }
Function::RefQualifier Function::refQualifier() const
{ return static_cast<RefQualifier>(f._refQualifier); }
void Function::setRefQualifier(Function::RefQualifier refQualifier)
{ f._refQualifier = refQualifier; }
bool Function::isAmbiguous() const
{ return f._isAmbiguous; }
void Function::setAmbiguous(bool isAmbiguous)
{ f._isAmbiguous = isAmbiguous; }
void Function::visitSymbol0(SymbolVisitor *visitor)
{
if (visitor->visit(this)) {
@ -569,11 +419,6 @@ bool Function::maybeValidPrototype(int actualArgumentCount) const
return true;
}
const StringLiteral *Function::exceptionSpecification()
{ return _exceptionSpecification; }
void Function::setExceptionSpecification(const StringLiteral *spec)
{ _exceptionSpecification = spec; }
Block::Block(TranslationUnit *translationUnit, int sourceLocation)
: Scope(translationUnit, sourceLocation, /*name = */ nullptr)
@ -583,9 +428,6 @@ Block::Block(Clone *clone, Subst *subst, Block *original)
: Scope(clone, subst, original)
{ }
Block::~Block()
{ }
FullySpecifiedType Block::type() const
{ return FullySpecifiedType(); }
@ -608,21 +450,9 @@ Enum::Enum(Clone *clone, Subst *subst, Enum *original)
, _isScoped(original->isScoped())
{ }
Enum::~Enum()
{ }
FullySpecifiedType Enum::type() const
{ return FullySpecifiedType(const_cast<Enum *>(this)); }
bool Enum::isScoped() const
{
return _isScoped;
}
void Enum::setScoped(bool scoped)
{
_isScoped = scoped;
}
void Enum::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
@ -652,9 +482,6 @@ Template::Template(Clone *clone, Subst *subst, Template *original)
: Scope(clone, subst, original)
{ }
Template::~Template()
{ }
int Template::templateParameterCount() const
{
if (declaration() != nullptr)
@ -663,17 +490,14 @@ int Template::templateParameterCount() const
return 0;
}
Symbol *Template::templateParameterAt(int index) const
{ return memberAt(index); }
Symbol *Template::declaration() const
{
if (isEmpty())
return nullptr;
if (Symbol *s = memberAt(memberCount() - 1)) {
if (s->isClass() || s->isForwardClassDeclaration() ||
s->isTemplate() || s->isFunction() || s->isDeclaration())
if (s->asClass() || s->asForwardClassDeclaration() ||
s->asTemplate() || s->asFunction() || s->asDeclaration())
return s;
}
@ -712,9 +536,6 @@ Namespace::Namespace(Clone *clone, Subst *subst, Namespace *original)
, _isInline(original->_isInline)
{ }
Namespace::~Namespace()
{ }
void Namespace::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
@ -749,30 +570,10 @@ BaseClass::BaseClass(Clone *clone, Subst *subst, BaseClass *original)
, _type(clone->type(original->_type, subst))
{ }
BaseClass::~BaseClass()
{ }
FullySpecifiedType BaseClass::type() const
{ return _type; }
void BaseClass::setType(const FullySpecifiedType &type)
{ _type = type; }
bool BaseClass::isVirtual() const
{ return _isVirtual; }
void BaseClass::setVirtual(bool isVirtual)
{ _isVirtual = isVirtual; }
bool BaseClass::isVariadic() const
{ return _isVariadic; }
void BaseClass::setVariadic(bool isVariadic)
{ _isVariadic = isVariadic; }
void BaseClass::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit,
int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
@ -782,9 +583,6 @@ ForwardClassDeclaration::ForwardClassDeclaration(Clone *clone, Subst *subst, For
: Symbol(clone, subst, original)
{ }
ForwardClassDeclaration::~ForwardClassDeclaration()
{ }
FullySpecifiedType ForwardClassDeclaration::type() const
{ return FullySpecifiedType(const_cast<ForwardClassDeclaration *>(this)); }
@ -815,24 +613,6 @@ Class::Class(Clone *clone, Subst *subst, Class *original)
addBaseClass(clone->symbol(original->_baseClasses.at(i), subst)->asBaseClass());
}
Class::~Class()
{ }
bool Class::isClass() const
{ return _key == ClassKey; }
bool Class::isStruct() const
{ return _key == StructKey; }
bool Class::isUnion() const
{ return _key == UnionKey; }
Class::Key Class::classKey() const
{ return _key; }
void Class::setClassKey(Key key)
{ _key = key; }
void Class::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
@ -880,21 +660,6 @@ QtPropertyDeclaration::QtPropertyDeclaration(Clone *clone, Subst *subst, QtPrope
, _flags(original->_flags)
{ }
QtPropertyDeclaration::~QtPropertyDeclaration()
{ }
void QtPropertyDeclaration::setType(const FullySpecifiedType &type)
{ _type = type; }
void QtPropertyDeclaration::setFlags(int flags)
{ _flags = flags; }
int QtPropertyDeclaration::flags() const
{ return _flags; }
FullySpecifiedType QtPropertyDeclaration::type() const
{ return _type; }
void QtPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
@ -907,12 +672,6 @@ QtEnum::QtEnum(Clone *clone, Subst *subst, QtEnum *original)
: Symbol(clone, subst, original)
{ }
QtEnum::~QtEnum()
{ }
FullySpecifiedType QtEnum::type() const
{ return FullySpecifiedType(); }
void QtEnum::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
@ -925,8 +684,6 @@ ObjCBaseClass::ObjCBaseClass(Clone *clone, Subst *subst, ObjCBaseClass *original
: Symbol(clone, subst, original)
{ }
ObjCBaseClass::~ObjCBaseClass()
{ }
FullySpecifiedType ObjCBaseClass::type() const
{ return FullySpecifiedType(); }
@ -942,9 +699,6 @@ ObjCBaseProtocol::ObjCBaseProtocol(Clone *clone, Subst *subst, ObjCBaseProtocol
: Symbol(clone, subst, original)
{ }
ObjCBaseProtocol::~ObjCBaseProtocol()
{ }
FullySpecifiedType ObjCBaseProtocol::type() const
{ return FullySpecifiedType(); }
@ -970,30 +724,6 @@ ObjCClass::ObjCClass(Clone *clone, Subst *subst, ObjCClass *original)
addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol());
}
ObjCClass::~ObjCClass()
{}
bool ObjCClass::isInterface() const
{ return _isInterface; }
void ObjCClass::setInterface(bool isInterface)
{ _isInterface = isInterface; }
bool ObjCClass::isCategory() const
{ return _categoryName != nullptr; }
const Name *ObjCClass::categoryName() const
{ return _categoryName; }
void ObjCClass::setCategoryName(const Name *categoryName)
{ _categoryName = categoryName; }
ObjCBaseClass *ObjCClass::baseClass() const
{ return _baseClass; }
void ObjCClass::setBaseClass(ObjCBaseClass *baseClass)
{ _baseClass = baseClass; }
int ObjCClass::protocolCount() const
{ return int(_protocols.size()); }
@ -1043,9 +773,6 @@ ObjCProtocol::ObjCProtocol(Clone *clone, Subst *subst, ObjCProtocol *original)
addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol());
}
ObjCProtocol::~ObjCProtocol()
{}
int ObjCProtocol::protocolCount() const
{ return int(_protocols.size()); }
@ -1087,9 +814,6 @@ ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(Clone *clone, Subst *su
: Symbol(clone, subst, original)
{ }
ObjCForwardClassDeclaration::~ObjCForwardClassDeclaration()
{}
FullySpecifiedType ObjCForwardClassDeclaration::type() const
{ return FullySpecifiedType(); }
@ -1117,9 +841,6 @@ ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(Clone *clone, Sub
: Symbol(clone, subst, original)
{ }
ObjCForwardProtocolDeclaration::~ObjCForwardProtocolDeclaration()
{}
FullySpecifiedType ObjCForwardProtocolDeclaration::type() const
{ return FullySpecifiedType(); }
@ -1148,9 +869,6 @@ ObjCMethod::ObjCMethod(Clone *clone, Subst *subst, ObjCMethod *original)
, _flags(original->_flags)
{ }
ObjCMethod::~ObjCMethod()
{ }
void ObjCMethod::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
@ -1165,12 +883,6 @@ bool ObjCMethod::match0(const Type *otherType, Matcher *matcher) const
FullySpecifiedType ObjCMethod::type() const
{ return FullySpecifiedType(const_cast<ObjCMethod *>(this)); }
FullySpecifiedType ObjCMethod::returnType() const
{ return _returnType; }
void ObjCMethod::setReturnType(const FullySpecifiedType &returnType)
{ _returnType = returnType; }
bool ObjCMethod::hasReturnType() const
{
const FullySpecifiedType ty = returnType();
@ -1180,7 +892,7 @@ bool ObjCMethod::hasReturnType() const
int ObjCMethod::argumentCount() const
{
const int c = memberCount();
if (c > 0 && memberAt(c - 1)->isBlock())
if (c > 0 && memberAt(c - 1)->asBlock())
return c - 1;
return c;
}
@ -1196,12 +908,6 @@ bool ObjCMethod::hasArguments() const
(argumentCount() == 1 && argumentAt(0)->type()->isVoidType()));
}
bool ObjCMethod::isVariadic() const
{ return f._isVariadic; }
void ObjCMethod::setVariadic(bool isVariadic)
{ f._isVariadic = isVariadic; }
void ObjCMethod::visitSymbol0(SymbolVisitor *visitor)
{
if (visitor->visit(this)) {
@ -1228,39 +934,6 @@ ObjCPropertyDeclaration::ObjCPropertyDeclaration(Clone *clone, Subst *subst, Obj
, _propertyAttributes(original->_propertyAttributes)
{ }
ObjCPropertyDeclaration::~ObjCPropertyDeclaration()
{}
bool ObjCPropertyDeclaration::hasAttribute(int attribute) const
{ return _propertyAttributes & attribute; }
void ObjCPropertyDeclaration::setAttributes(int attributes)
{ _propertyAttributes = attributes; }
bool ObjCPropertyDeclaration::hasGetter() const
{ return hasAttribute(Getter); }
bool ObjCPropertyDeclaration::hasSetter() const
{ return hasAttribute(Setter); }
const Name *ObjCPropertyDeclaration::getterName() const
{ return _getterName; }
void ObjCPropertyDeclaration::setGetterName(const Name *getterName)
{ _getterName = getterName; }
const Name *ObjCPropertyDeclaration::setterName() const
{ return _setterName; }
void ObjCPropertyDeclaration::setSetterName(const Name *setterName)
{ _setterName = setterName; }
void ObjCPropertyDeclaration::setType(const FullySpecifiedType &type)
{ _type = type; }
FullySpecifiedType ObjCPropertyDeclaration::type() const
{ return _type; }
void ObjCPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
{
if (visitor->visit(this)) {

View File

@ -31,64 +31,55 @@ namespace CPlusPlus {
class StringLiteral;
class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol
class CPLUSPLUS_EXPORT UsingNamespaceDirective final : public Symbol
{
public:
UsingNamespaceDirective(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
UsingNamespaceDirective(Clone *clone, Subst *subst, UsingNamespaceDirective *original);
virtual ~UsingNamespaceDirective();
~UsingNamespaceDirective() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
const UsingNamespaceDirective *asUsingNamespaceDirective() const override
{ return this; }
UsingNamespaceDirective *asUsingNamespaceDirective() override
{ return this; }
const UsingNamespaceDirective *asUsingNamespaceDirective() const override { return this; }
UsingNamespaceDirective *asUsingNamespaceDirective() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
};
class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol
class CPLUSPLUS_EXPORT UsingDeclaration final : public Symbol
{
public:
UsingDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
UsingDeclaration(Clone *clone, Subst *subst, UsingDeclaration *original);
virtual ~UsingDeclaration();
~UsingDeclaration() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
const UsingDeclaration *asUsingDeclaration() const override
{ return this; }
UsingDeclaration *asUsingDeclaration() override
{ return this; }
const UsingDeclaration *asUsingDeclaration() const override { return this; }
UsingDeclaration *asUsingDeclaration() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
};
class CPLUSPLUS_EXPORT NamespaceAlias: public Symbol
class CPLUSPLUS_EXPORT NamespaceAlias final : public Symbol
{
public:
NamespaceAlias(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
NamespaceAlias(Clone *clone, Subst *subst, NamespaceAlias *original);
virtual ~NamespaceAlias();
~NamespaceAlias() override = default;
const Name *namespaceName() const;
void setNamespaceName(const Name *namespaceName);
const Name *namespaceName() const { return _namespaceName; }
void setNamespaceName(const Name *namespaceName) { _namespaceName = namespaceName; }
// Symbol's interface
FullySpecifiedType type() const override;
const NamespaceAlias *asNamespaceAlias() const override
{ return this; }
NamespaceAlias *asNamespaceAlias() override
{ return this; }
const NamespaceAlias *asNamespaceAlias() const override { return this; }
NamespaceAlias *asNamespaceAlias() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -97,31 +88,25 @@ private:
const Name *_namespaceName;
};
class CPLUSPLUS_EXPORT Declaration: public Symbol
class CPLUSPLUS_EXPORT Declaration : public Symbol
{
public:
Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Declaration(Clone *clone, Subst *subst, Declaration *original);
virtual ~Declaration();
~Declaration() override = default;
void setType(const FullySpecifiedType &type);
void setInitializer(StringLiteral const* initializer);
void setType(const FullySpecifiedType &type) { _type = type; }
void setInitializer(StringLiteral const* initializer) { _initializer = initializer; }
// Symbol's interface
FullySpecifiedType type() const override;
const StringLiteral *getInitializer() const;
FullySpecifiedType type() const override { return _type; }
const StringLiteral *getInitializer() const { return _initializer; }
const Declaration *asDeclaration() const override
{ return this; }
const Declaration *asDeclaration() const override { return this; }
Declaration *asDeclaration() override { return this; }
Declaration *asDeclaration() override
{ return this; }
virtual EnumeratorDeclaration *asEnumeratorDeclarator()
{ return nullptr; }
virtual const EnumeratorDeclaration *asEnumeratorDeclarator() const
{ return nullptr; }
virtual EnumeratorDeclaration *asEnumeratorDeclarator() { return nullptr; }
virtual const EnumeratorDeclaration *asEnumeratorDeclarator() const { return nullptr; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -131,47 +116,41 @@ private:
const StringLiteral *_initializer;
};
class CPLUSPLUS_EXPORT EnumeratorDeclaration: public Declaration
class CPLUSPLUS_EXPORT EnumeratorDeclaration final : public Declaration
{
public:
EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
virtual ~EnumeratorDeclaration();
~EnumeratorDeclaration() override = default;
const StringLiteral *constantValue() const;
void setConstantValue(const StringLiteral *constantValue);
const StringLiteral *constantValue() const { return _constantValue; }
void setConstantValue(const StringLiteral *constantValue) { _constantValue = constantValue; }
EnumeratorDeclaration *asEnumeratorDeclarator() override
{ return this; }
const EnumeratorDeclaration *asEnumeratorDeclarator() const override
{ return this; }
EnumeratorDeclaration *asEnumeratorDeclarator() override { return this; }
const EnumeratorDeclaration *asEnumeratorDeclarator() const override { return this; }
private:
const StringLiteral *_constantValue;
};
class CPLUSPLUS_EXPORT Argument: public Symbol
class CPLUSPLUS_EXPORT Argument final : public Symbol
{
public:
Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Argument(Clone *clone, Subst *subst, Argument *original);
virtual ~Argument();
~Argument() override = default;
void setType(const FullySpecifiedType &type);
void setType(const FullySpecifiedType &type) { _type = type; }
bool hasInitializer() const;
bool hasInitializer() const { return _initializer != nullptr; }
const StringLiteral *initializer() const;
void setInitializer(const StringLiteral *initializer);
const StringLiteral *initializer() const { return _initializer; }
void setInitializer(const StringLiteral *initializer) { _initializer = initializer; }
// Symbol's interface
FullySpecifiedType type() const override;
FullySpecifiedType type() const override { return _type; }
const Argument *asArgument() const override
{ return this; }
Argument *asArgument() override
{ return this; }
const Argument *asArgument() const override { return this; }
Argument *asArgument() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -181,25 +160,22 @@ private:
FullySpecifiedType _type;
};
class CPLUSPLUS_EXPORT TypenameArgument: public Symbol
class CPLUSPLUS_EXPORT TypenameArgument final : public Symbol
{
public:
TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
TypenameArgument(Clone *clone, Subst *subst, TypenameArgument *original);
virtual ~TypenameArgument();
~TypenameArgument() = default;
void setType(const FullySpecifiedType &type);
void setType(const FullySpecifiedType &type) { _type = type; }
void setClassDeclarator(bool isClassDecl) { _isClassDeclarator = isClassDecl; }
bool isClassDeclarator() const { return _isClassDeclarator; }
// Symbol's interface
FullySpecifiedType type() const override;
FullySpecifiedType type() const override { return _type; }
const TypenameArgument *asTypenameArgument() const override
{ return this; }
TypenameArgument *asTypenameArgument() override
{ return this; }
const TypenameArgument *asTypenameArgument() const override { return this; }
TypenameArgument *asTypenameArgument() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -209,12 +185,12 @@ private:
bool _isClassDeclarator;
};
class CPLUSPLUS_EXPORT Block: public Scope
class CPLUSPLUS_EXPORT Block final : public Scope
{
public:
Block(TranslationUnit *translationUnit, int sourceLocation);
Block(Clone *clone, Subst *subst, Block *original);
virtual ~Block();
~Block() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
@ -229,28 +205,22 @@ protected:
void visitSymbol0(SymbolVisitor *visitor) override;
};
class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type
class CPLUSPLUS_EXPORT ForwardClassDeclaration final : public Symbol, public Type
{
public:
ForwardClassDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ForwardClassDeclaration(Clone *clone, Subst *subst, ForwardClassDeclaration *original);
virtual ~ForwardClassDeclaration();
~ForwardClassDeclaration() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
const ForwardClassDeclaration *asForwardClassDeclaration() const override
{ return this; }
ForwardClassDeclaration *asForwardClassDeclaration() override
{ return this; }
const ForwardClassDeclaration *asForwardClassDeclaration() const override { return this; }
ForwardClassDeclaration *asForwardClassDeclaration() override { return this; }
// Type's interface
const ForwardClassDeclaration *asForwardClassDeclarationType() const override
{ return this; }
ForwardClassDeclaration *asForwardClassDeclarationType() override
{ return this; }
const ForwardClassDeclaration *asForwardClassDeclarationType() const override { return this; }
ForwardClassDeclaration *asForwardClassDeclarationType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -258,31 +228,25 @@ protected:
bool match0(const Type *otherType, Matcher *matcher) const override;
};
class CPLUSPLUS_EXPORT Enum: public Scope, public Type
class CPLUSPLUS_EXPORT Enum final : public Scope, public Type
{
public:
Enum(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Enum(Clone *clone, Subst *subst, Enum *original);
virtual ~Enum();
~Enum() override = default;
bool isScoped() const;
void setScoped(bool scoped);
bool isScoped() const { return _isScoped; }
void setScoped(bool scoped) { _isScoped = scoped; }
// Symbol's interface
FullySpecifiedType type() const override;
const Enum *asEnum() const override
{ return this; }
Enum *asEnum() override
{ return this; }
const Enum *asEnum() const override { return this; }
Enum *asEnum() override { return this; }
// Type's interface
const Enum *asEnumType() const override
{ return this; }
Enum *asEnumType() override
{ return this; }
const Enum *asEnumType() const override { return this; }
Enum *asEnumType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -293,7 +257,7 @@ private:
bool _isScoped;
};
class CPLUSPLUS_EXPORT Function: public Scope, public Type
class CPLUSPLUS_EXPORT Function final : public Scope, public Type
{
public:
enum MethodKey {
@ -312,17 +276,18 @@ public:
public:
Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Function(Clone *clone, Subst *subst, Function *original);
virtual ~Function();
~Function() override = default;
bool isNormal() const;
bool isSignal() const;
bool isSlot() const;
bool isInvokable() const;
int methodKey() const;
void setMethodKey(int key);
bool isNormal() const { return f._methodKey == NormalMethod; }
bool isSignal() const { return f._methodKey == SignalMethod; }
bool isSlot() const { return f._methodKey == SlotMethod; }
bool isInvokable() const { return f._methodKey == InvokableMethod; }
FullySpecifiedType returnType() const;
void setReturnType(const FullySpecifiedType &returnType);
int methodKey() const { return f._methodKey; }
void setMethodKey(int key) { f._methodKey = key; }
FullySpecifiedType returnType() const { return _returnType; }
void setReturnType(const FullySpecifiedType &returnType) { _returnType = returnType; }
/** Convenience function that returns whether the function returns something (including void). */
bool hasReturnType() const;
@ -334,61 +299,55 @@ public:
bool hasArguments() const;
int minimumArgumentCount() const;
bool isVirtual() const;
void setVirtual(bool isVirtual);
bool isVirtual() const { return f._isVirtual; }
void setVirtual(bool isVirtual) { f._isVirtual = isVirtual; }
bool isOverride() const;
void setOverride(bool isOverride);
bool isOverride() const { return f._isOverride; }
void setOverride(bool isOverride) { f._isOverride = isOverride; }
bool isFinal() const;
void setFinal(bool isFinal);
bool isFinal() const { return f._isFinal; }
void setFinal(bool isFinal) { f._isFinal = isFinal; }
bool isVariadic() const;
void setVariadic(bool isVariadic);
bool isVariadic() const { return f._isVariadic; }
void setVariadic(bool isVariadic) { f._isVariadic = isVariadic; }
bool isVariadicTemplate() const;
void setVariadicTemplate(bool isVariadicTemplate);
bool isVariadicTemplate() const { return f._isVariadicTemplate; }
void setVariadicTemplate(bool isVariadicTemplate) { f._isVariadicTemplate = isVariadicTemplate; }
bool isConst() const;
void setConst(bool isConst);
bool isConst() const { return f._isConst; }
void setConst(bool isConst) { f._isConst = isConst; }
bool isStatic() const { return f._isStatic; }
void setStatic(bool isStatic) { f._isStatic = isStatic; }
bool isVolatile() const;
void setVolatile(bool isVolatile);
bool isVolatile() const { return f._isVolatile; }
void setVolatile(bool isVolatile) { f._isVolatile = isVolatile; }
bool isPureVirtual() const;
void setPureVirtual(bool isPureVirtual);
bool isPureVirtual() const { return f._isPureVirtual; }
void setPureVirtual(bool isPureVirtual) { f._isPureVirtual = isPureVirtual; }
RefQualifier refQualifier() const;
void setRefQualifier(RefQualifier refQualifier);
RefQualifier refQualifier() const { return static_cast<RefQualifier>(f._refQualifier); }
void setRefQualifier(RefQualifier refQualifier) { f._refQualifier = refQualifier; }
bool isSignatureEqualTo(const Function *other, Matcher *matcher = nullptr) const;
bool isAmbiguous() const; // internal
void setAmbiguous(bool isAmbiguous); // internal
bool isAmbiguous() const { return f._isAmbiguous; } // internal
void setAmbiguous(bool isAmbiguous) { f._isAmbiguous = isAmbiguous; } // internal
bool maybeValidPrototype(int actualArgumentCount) const;
const StringLiteral *exceptionSpecification();
void setExceptionSpecification(const StringLiteral *spec);
const StringLiteral *exceptionSpecification() { return _exceptionSpecification; }
void setExceptionSpecification(const StringLiteral *spec) { _exceptionSpecification = spec; }
// Symbol's interface
FullySpecifiedType type() const override;
const Function *asFunction() const override
{ return this; }
Function *asFunction() override
{ return this; }
const Function *asFunction() const override { return this; }
Function *asFunction() override { return this; }
// Type's interface
const Function *asFunctionType() const override
{ return this; }
Function *asFunctionType() override
{ return this; }
const Function *asFunctionType() const override { return this; }
Function *asFunctionType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -418,32 +377,26 @@ private:
};
};
class CPLUSPLUS_EXPORT Template: public Scope, public Type
class CPLUSPLUS_EXPORT Template final : public Scope, public Type
{
public:
Template(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Template(Clone *clone, Subst *subst, Template *original);
virtual ~Template();
~Template() override = default;
int templateParameterCount() const;
Symbol *templateParameterAt(int index) const;
Symbol *templateParameterAt(int index) const { return memberAt(index); }
Symbol *declaration() const;
// Symbol's interface
FullySpecifiedType type() const override;
const Template *asTemplate() const override
{ return this; }
Template *asTemplate() override
{ return this; }
const Template *asTemplate() const override { return this; }
Template *asTemplate() override { return this; }
// Type's interface
const Template *asTemplateType() const override
{ return this; }
Template *asTemplateType() override
{ return this; }
const Template *asTemplateType() const override { return this; }
Template *asTemplateType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -452,34 +405,25 @@ protected:
};
class CPLUSPLUS_EXPORT Namespace: public Scope, public Type
class CPLUSPLUS_EXPORT Namespace final : public Scope, public Type
{
public:
Namespace(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Namespace(Clone *clone, Subst *subst, Namespace *original);
virtual ~Namespace();
~Namespace() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
const Namespace *asNamespace() const override
{ return this; }
Namespace *asNamespace() override
{ return this; }
const Namespace *asNamespace() const override { return this; }
Namespace *asNamespace() override { return this; }
// Type's interface
const Namespace *asNamespaceType() const override
{ return this; }
const Namespace *asNamespaceType() const override { return this; }
Namespace *asNamespaceType() override { return this; }
Namespace *asNamespaceType() override
{ return this; }
bool isInline() const
{ return _isInline; }
void setInline(bool onoff)
{ _isInline = onoff; }
bool isInline() const { return _isInline; }
void setInline(bool onoff) { _isInline = onoff; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -490,28 +434,25 @@ private:
bool _isInline;
};
class CPLUSPLUS_EXPORT BaseClass: public Symbol
class CPLUSPLUS_EXPORT BaseClass final : public Symbol
{
public:
BaseClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
BaseClass(Clone *clone, Subst *subst, BaseClass *original);
virtual ~BaseClass();
~BaseClass() override = default;
bool isVirtual() const;
void setVirtual(bool isVirtual);
bool isVirtual() const { return _isVirtual; }
void setVirtual(bool isVirtual) { _isVirtual = isVirtual; }
bool isVariadic() const;
void setVariadic(bool isVariadic);
bool isVariadic() const { return _isVariadic; }
void setVariadic(bool isVariadic) { _isVariadic = isVariadic; }
// Symbol's interface
FullySpecifiedType type() const override;
void setType(const FullySpecifiedType &type);
FullySpecifiedType type() const override { return _type; }
void setType(const FullySpecifiedType &type) { _type = type; }
const BaseClass *asBaseClass() const override
{ return this; }
BaseClass *asBaseClass() override
{ return this; }
const BaseClass *asBaseClass() const override { return this; }
BaseClass *asBaseClass() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -522,12 +463,12 @@ private:
FullySpecifiedType _type;
};
class CPLUSPLUS_EXPORT Class: public Scope, public Type
class CPLUSPLUS_EXPORT Class final : public Scope, public Type
{
public:
Class(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Class(Clone *clone, Subst *subst, Class *original);
virtual ~Class();
~Class() override = default;
enum Key {
ClassKey,
@ -535,11 +476,12 @@ public:
UnionKey
};
bool isClass() const;
bool isStruct() const;
bool isUnion() const;
Key classKey() const;
void setClassKey(Key key);
bool isClass() const { return _key == ClassKey; }
bool isStruct() const { return _key == StructKey; }
bool isUnion() const { return _key == UnionKey; }
Key classKey() const { return _key; }
void setClassKey(Key key) { _key = key; }
int baseClassCount() const;
BaseClass *baseClassAt(int index) const;
@ -549,18 +491,12 @@ public:
// Symbol's interface
FullySpecifiedType type() const override;
const Class *asClass() const override
{ return this; }
Class *asClass() override
{ return this; }
const Class *asClass() const override { return this; }
Class *asClass() override { return this; }
// Type's interface
const Class *asClassType() const override
{ return this; }
Class *asClassType() override
{ return this; }
const Class *asClassType() const override { return this; }
Class *asClassType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -572,7 +508,7 @@ private:
std::vector<BaseClass *> _baseClasses;
};
class CPLUSPLUS_EXPORT QtPropertyDeclaration: public Symbol
class CPLUSPLUS_EXPORT QtPropertyDeclaration final : public Symbol
{
public:
enum Flag {
@ -597,21 +533,17 @@ public:
public:
QtPropertyDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
QtPropertyDeclaration(Clone *clone, Subst *subst, QtPropertyDeclaration *original);
virtual ~QtPropertyDeclaration();
~QtPropertyDeclaration() = default;
void setType(const FullySpecifiedType &type);
void setFlags(int flags);
int flags() const;
void setType(const FullySpecifiedType &type) { _type = type; }
void setFlags(int flags) { _flags = flags; }
int flags() const { return _flags; }
// Symbol's interface
FullySpecifiedType type() const override;
FullySpecifiedType type() const override { return _type; }
const QtPropertyDeclaration *asQtPropertyDeclaration() const override
{ return this; }
QtPropertyDeclaration *asQtPropertyDeclaration() override
{ return this; }
const QtPropertyDeclaration *asQtPropertyDeclaration() const override { return this; }
QtPropertyDeclaration *asQtPropertyDeclaration() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -621,88 +553,73 @@ private:
int _flags;
};
class CPLUSPLUS_EXPORT QtEnum: public Symbol
class CPLUSPLUS_EXPORT QtEnum final : public Symbol
{
public:
QtEnum(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
QtEnum(Clone *clone, Subst *subst, QtEnum *original);
virtual ~QtEnum();
~QtEnum() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
FullySpecifiedType type() const override { return FullySpecifiedType(); }
const QtEnum *asQtEnum() const override
{ return this; }
QtEnum *asQtEnum() override
{ return this; }
const QtEnum *asQtEnum() const override { return this; }
QtEnum *asQtEnum() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
};
class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol
class CPLUSPLUS_EXPORT ObjCBaseClass final : public Symbol
{
public:
ObjCBaseClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCBaseClass(Clone *clone, Subst *subst, ObjCBaseClass *original);
virtual ~ObjCBaseClass();
~ObjCBaseClass() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
const ObjCBaseClass *asObjCBaseClass() const override
{ return this; }
ObjCBaseClass *asObjCBaseClass() override
{ return this; }
const ObjCBaseClass *asObjCBaseClass() const override { return this; }
ObjCBaseClass *asObjCBaseClass() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
};
class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol
class CPLUSPLUS_EXPORT ObjCBaseProtocol final : public Symbol
{
public:
ObjCBaseProtocol(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCBaseProtocol(Clone *clone, Subst *subst, ObjCBaseProtocol *original);
virtual ~ObjCBaseProtocol();
~ObjCBaseProtocol() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
const ObjCBaseProtocol *asObjCBaseProtocol() const override
{ return this; }
ObjCBaseProtocol *asObjCBaseProtocol() override
{ return this; }
const ObjCBaseProtocol *asObjCBaseProtocol() const override { return this; }
ObjCBaseProtocol *asObjCBaseProtocol() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
};
class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type
class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration final : public Symbol, public Type
{
public:
ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCForwardProtocolDeclaration(Clone *clone, Subst *subst, ObjCForwardProtocolDeclaration *original);
virtual ~ObjCForwardProtocolDeclaration();
~ObjCForwardProtocolDeclaration() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const override
{ return this; }
ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() override
{ return this; }
const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const override { return this; }
ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() override { return this; }
// Type's interface
const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const override
{ return this; }
ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() override
{ return this; }
const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const override { return this; }
ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -710,12 +627,12 @@ protected:
bool match0(const Type *otherType, Matcher *matcher) const override;
};
class CPLUSPLUS_EXPORT ObjCProtocol: public Scope, public Type
class CPLUSPLUS_EXPORT ObjCProtocol final : public Scope, public Type
{
public:
ObjCProtocol(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCProtocol(Clone *clone, Subst *subst, ObjCProtocol *original);
virtual ~ObjCProtocol();
~ObjCProtocol() override = default;
int protocolCount() const;
ObjCBaseProtocol *protocolAt(int index) const;
@ -724,18 +641,12 @@ public:
// Symbol's interface
FullySpecifiedType type() const override;
const ObjCProtocol *asObjCProtocol() const override
{ return this; }
ObjCProtocol *asObjCProtocol() override
{ return this; }
const ObjCProtocol *asObjCProtocol() const override { return this; }
ObjCProtocol *asObjCProtocol() override { return this; }
// Type's interface
const ObjCProtocol *asObjCProtocolType() const override
{ return this; }
ObjCProtocol *asObjCProtocolType() override
{ return this; }
const ObjCProtocol *asObjCProtocolType() const override { return this; }
ObjCProtocol *asObjCProtocolType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -746,28 +657,22 @@ private:
std::vector<ObjCBaseProtocol *> _protocols;
};
class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type
class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration final : public Symbol, public Type
{
public:
ObjCForwardClassDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCForwardClassDeclaration(Clone *clone, Subst *subst, ObjCForwardClassDeclaration *original);
virtual ~ObjCForwardClassDeclaration();
~ObjCForwardClassDeclaration() override = default;
// Symbol's interface
FullySpecifiedType type() const override;
const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const override
{ return this; }
ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() override
{ return this; }
const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const override { return this; }
ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() override { return this; }
// Type's interface
const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const override
{ return this; }
ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() override
{ return this; }
const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const override { return this; }
ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -775,22 +680,22 @@ protected:
bool match0(const Type *otherType, Matcher *matcher) const override;
};
class CPLUSPLUS_EXPORT ObjCClass: public Scope, public Type
class CPLUSPLUS_EXPORT ObjCClass final : public Scope, public Type
{
public:
ObjCClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCClass(Clone *clone, Subst *subst, ObjCClass *original);
virtual ~ObjCClass();
~ObjCClass() override = default;
bool isInterface() const;
void setInterface(bool isInterface);
bool isInterface() const { return _isInterface; }
void setInterface(bool isInterface) { _isInterface = isInterface; }
bool isCategory() const;
const Name *categoryName() const;
void setCategoryName(const Name *categoryName);
bool isCategory() const { return _categoryName != nullptr; }
const Name *categoryName() const { return _categoryName; }
void setCategoryName(const Name *categoryName) { _categoryName = categoryName; }
ObjCBaseClass *baseClass() const;
void setBaseClass(ObjCBaseClass *baseClass);
ObjCBaseClass *baseClass() const { return _baseClass; }
void setBaseClass(ObjCBaseClass *baseClass) { _baseClass = baseClass; }
int protocolCount() const;
ObjCBaseProtocol *protocolAt(int index) const;
@ -799,18 +704,12 @@ public:
// Symbol's interface
FullySpecifiedType type() const override;
const ObjCClass *asObjCClass() const override
{ return this; }
ObjCClass *asObjCClass() override
{ return this; }
const ObjCClass *asObjCClass() const override { return this; }
ObjCClass *asObjCClass() override { return this; }
// Type's interface
const ObjCClass *asObjCClassType() const override
{ return this; }
ObjCClass *asObjCClassType() override
{ return this; }
const ObjCClass *asObjCClassType() const override { return this; }
ObjCClass *asObjCClassType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -824,15 +723,15 @@ private:
bool _isInterface;
};
class CPLUSPLUS_EXPORT ObjCMethod: public Scope, public Type
class CPLUSPLUS_EXPORT ObjCMethod final : public Scope, public Type
{
public:
ObjCMethod(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCMethod(Clone *clone, Subst *subst, ObjCMethod *original);
virtual ~ObjCMethod();
~ObjCMethod() override = default;
FullySpecifiedType returnType() const;
void setReturnType(const FullySpecifiedType &returnType);
FullySpecifiedType returnType() const { return _returnType; }
void setReturnType(const FullySpecifiedType &returnType) { _returnType = returnType; }
/** Convenience function that returns whether the function returns something (including void). */
bool hasReturnType() const;
@ -843,24 +742,18 @@ public:
/** Convenience function that returns whether the function receives any arguments. */
bool hasArguments() const;
bool isVariadic() const;
void setVariadic(bool isVariadic);
bool isVariadic() const { return f._isVariadic; }
void setVariadic(bool isVariadic) { f._isVariadic = isVariadic; }
// Symbol's interface
FullySpecifiedType type() const override;
const ObjCMethod *asObjCMethod() const override
{ return this; }
ObjCMethod *asObjCMethod() override
{ return this; }
const ObjCMethod *asObjCMethod() const override { return this; }
ObjCMethod *asObjCMethod() override { return this; }
// Type's interface
const ObjCMethod *asObjCMethodType() const override
{ return this; }
ObjCMethod *asObjCMethodType() override
{ return this; }
const ObjCMethod *asObjCMethodType() const override { return this; }
ObjCMethod *asObjCMethodType() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
@ -878,7 +771,7 @@ private:
};
};
class CPLUSPLUS_EXPORT ObjCPropertyDeclaration: public Symbol
class CPLUSPLUS_EXPORT ObjCPropertyDeclaration final : public Symbol
{
public:
enum PropertyAttributes {
@ -901,31 +794,27 @@ public:
int sourceLocation,
const Name *name);
ObjCPropertyDeclaration(Clone *clone, Subst *subst, ObjCPropertyDeclaration *original);
virtual ~ObjCPropertyDeclaration();
~ObjCPropertyDeclaration() override = default;
bool hasAttribute(int attribute) const;
void setAttributes(int attributes);
bool hasAttribute(int attribute) const { return _propertyAttributes & attribute; }
void setAttributes(int attributes) { _propertyAttributes = attributes; }
bool hasGetter() const;
bool hasSetter() const;
bool hasGetter() const { return hasAttribute(Getter); }
bool hasSetter() const { return hasAttribute(Setter); }
const Name *getterName() const;
const Name *getterName() const { return _getterName; }
void setGetterName(const Name *getterName) { _getterName = getterName; }
void setGetterName(const Name *getterName);
const Name *setterName() const { return _setterName; }
void setSetterName(const Name *setterName) { _setterName = setterName; }
const Name *setterName() const;
void setSetterName(const Name *setterName);
void setType(const FullySpecifiedType &type);
void setType(const FullySpecifiedType &type) { _type = type; }
// Symbol's interface
FullySpecifiedType type() const override;
FullySpecifiedType type() const override { return _type; }
const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const override
{ return this; }
ObjCPropertyDeclaration *asObjCPropertyDeclaration() override
{ return this; }
const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const override { return this; }
ObjCPropertyDeclaration *asObjCPropertyDeclaration() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;

View File

@ -33,7 +33,7 @@ Type::~Type()
{ }
bool Type::isUndefinedType() const
{ return this == UndefinedType::instance(); }
{ return this == &UndefinedType::instance; }
bool Type::isVoidType() const
{ return asVoidType() != nullptr; }

View File

@ -174,7 +174,7 @@ protected:
bool visit(Template *symbol) override
{
if (Symbol *decl = symbol->declaration()) {
if (decl->isFunction() || decl->isClass() || decl->isDeclaration())
if (decl->asFunction() || decl->asClass() || decl->asDeclaration())
return process(symbol);
}
return true;
@ -522,7 +522,7 @@ QString Document::functionAt(int line, int column, int *lineOpeningDeclaratorPar
if (!scope)
scope = symbol->enclosingScope();
while (scope && !scope->isFunction() )
while (scope && !scope->asFunction() )
scope = scope->enclosingScope();
if (!scope)

View File

@ -458,8 +458,8 @@ FullySpecifiedType UseMinimalNames::apply(const Name *name, Rewrite *rewrite) co
SubstitutionEnvironment *env = rewrite->env;
Scope *scope = env->scope();
if (name->isTemplateNameId() ||
(name->isQualifiedNameId() && name->asQualifiedNameId()->name()->isTemplateNameId()))
if (name->asTemplateNameId() ||
(name->asQualifiedNameId() && name->asQualifiedNameId()->name()->asTemplateNameId()))
return FullySpecifiedType();
if (! scope)

View File

@ -514,7 +514,7 @@ QString FindUsages::matchingLine(const Token &tk) const
bool FindUsages::isLocalScope(Scope *scope)
{
if (scope) {
if (scope->isBlock() || scope->isTemplate() || scope->isFunction())
if (scope->asBlock() || scope->asTemplate() || scope->asFunction())
return true;
}
@ -527,7 +527,7 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
const LookupItem &r = candidates.at(i);
if (Symbol *s = r.declaration()) {
if (_declSymbol->isTypenameArgument()) {
if (_declSymbol->asTypenameArgument()) {
if (s != _declSymbol)
return false;
}
@ -535,8 +535,8 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
Scope *declEnclosingScope = _declSymbol->enclosingScope();
Scope *enclosingScope = s->enclosingScope();
if (isLocalScope(declEnclosingScope) || isLocalScope(enclosingScope)) {
if (_declSymbol->isClass() && declEnclosingScope->isTemplate()
&& s->isClass() && enclosingScope->isTemplate()) {
if (_declSymbol->asClass() && declEnclosingScope->asTemplate()
&& s->asClass() && enclosingScope->asTemplate()) {
// for definition of functions of class defined outside the class definition
Scope *templEnclosingDeclSymbol = declEnclosingScope;
Scope *scopeOfTemplEnclosingDeclSymbol
@ -547,9 +547,9 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
return false;
} else if (_declSymbol->isClass() && declEnclosingScope->isTemplate()
&& enclosingScope->isClass()
&& enclosingScope->enclosingScope()->isTemplate()) {
} else if (_declSymbol->asClass() && declEnclosingScope->asTemplate()
&& enclosingScope->asClass()
&& enclosingScope->enclosingScope()->asTemplate()) {
// for declaration inside template class
Scope *templEnclosingDeclSymbol = declEnclosingScope;
Scope *scopeOfTemplEnclosingDeclSymbol
@ -560,18 +560,18 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
return false;
} else if (enclosingScope->isTemplate() && ! _declSymbol->isTypenameArgument()) {
if (declEnclosingScope->isTemplate()) {
} else if (enclosingScope->asTemplate() && ! _declSymbol->asTypenameArgument()) {
if (declEnclosingScope->asTemplate()) {
if (enclosingScope->enclosingScope() != declEnclosingScope->enclosingScope())
return false;
} else {
if (enclosingScope->enclosingScope() != declEnclosingScope)
return false;
}
} else if (declEnclosingScope->isTemplate() && s->isTemplate()) {
} else if (declEnclosingScope->asTemplate() && s->asTemplate()) {
if (declEnclosingScope->enclosingScope() != enclosingScope)
return false;
} else if (! s->isUsingDeclaration()
} else if (! s->asUsingDeclaration()
&& enclosingScope != declEnclosingScope) {
return false;
}
@ -854,7 +854,7 @@ void FindUsages::memInitializer(MemInitializerAST *ast)
if (! ast)
return;
if (_currentScope->isFunction()) {
if (_currentScope->asFunction()) {
Class *classScope = _currentScope->enclosingClass();
if (! classScope) {
if (ClassOrNamespace *binding = _context.lookupType(_currentScope)) {

View File

@ -57,7 +57,7 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
}
FullySpecifiedType symbolType = symbol->type();
if (symbol->isFunction() || (symbol->isDeclaration() && symbolType &&
if (symbol->asFunction() || (symbol->asDeclaration() && symbolType &&
symbolType->isFunctionType()))
{
const Function *function = symbol->asFunction();
@ -80,9 +80,9 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
} else if (symbol->isPrivate()) {
return symbol->isStatic() ? FuncPrivateStatic : FuncPrivate;
}
} else if (symbol->enclosingScope() && symbol->enclosingScope()->isEnum()) {
} else if (symbol->enclosingScope() && symbol->enclosingScope()->asEnum()) {
return Enumerator;
} else if (symbol->isDeclaration() || symbol->isArgument()) {
} else if (symbol->asDeclaration() || symbol->asArgument()) {
if (symbol->isPublic()) {
return symbol->isStatic() ? VarPublicStatic : VarPublic;
} else if (symbol->isProtected()) {
@ -90,26 +90,26 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
} else if (symbol->isPrivate()) {
return symbol->isStatic() ? VarPrivateStatic : VarPrivate;
}
} else if (symbol->isEnum()) {
} else if (symbol->asEnum()) {
return Utils::CodeModelIcon::Enum;
} else if (symbol->isForwardClassDeclaration()) {
} else if (symbol->asForwardClassDeclaration()) {
return Utils::CodeModelIcon::Class; // TODO: Store class key in ForwardClassDeclaration
} else if (const Class *klass = symbol->asClass()) {
return klass->isStruct() ? Struct : Utils::CodeModelIcon::Class;
} else if (symbol->isObjCClass() || symbol->isObjCForwardClassDeclaration()) {
} else if (symbol->asObjCClass() || symbol->asObjCForwardClassDeclaration()) {
return Utils::CodeModelIcon::Class;
} else if (symbol->isObjCProtocol() || symbol->isObjCForwardProtocolDeclaration()) {
} else if (symbol->asObjCProtocol() || symbol->asObjCForwardProtocolDeclaration()) {
return Utils::CodeModelIcon::Class;
} else if (symbol->isObjCMethod()) {
} else if (symbol->asObjCMethod()) {
return FuncPublic;
} else if (symbol->isNamespace()) {
} else if (symbol->asNamespace()) {
return Utils::CodeModelIcon::Namespace;
} else if (symbol->isTypenameArgument()) {
} else if (symbol->asTypenameArgument()) {
return Utils::CodeModelIcon::Class;
} else if (symbol->isQtPropertyDeclaration() || symbol->isObjCPropertyDeclaration()) {
} else if (symbol->asQtPropertyDeclaration() || symbol->asObjCPropertyDeclaration()) {
return Property;
} else if (symbol->isUsingNamespaceDirective() ||
symbol->isUsingDeclaration()) {
} else if (symbol->asUsingNamespaceDirective() ||
symbol->asUsingDeclaration()) {
// TODO: Might be nice to have a different icons for these things
return Utils::CodeModelIcon::Namespace;
}

View File

@ -56,7 +56,7 @@ static void addNames(const Name *name, QList<const Name *> *names, bool addAllNa
if (const QualifiedNameId *q = name->asQualifiedNameId()) {
addNames(q->base(), names);
addNames(q->name(), names, addAllNames);
} else if (addAllNames || name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) {
} else if (addAllNames || name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
names->append(name);
}
}
@ -71,7 +71,7 @@ static void path_helper(Symbol *symbol,
path_helper(symbol->enclosingScope(), names, policy);
if (symbol->name()) {
if (symbol->isClass() || symbol->isNamespace()) {
if (symbol->asClass() || symbol->asNamespace()) {
if (policy == LookupContext::HideInlineNamespaces) {
auto ns = symbol->asNamespace();
if (ns && ns->isInline())
@ -79,12 +79,12 @@ static void path_helper(Symbol *symbol,
}
addNames(symbol->name(), names);
} else if (symbol->isObjCClass() || symbol->isObjCBaseClass() || symbol->isObjCProtocol()
|| symbol->isObjCForwardClassDeclaration() || symbol->isObjCForwardProtocolDeclaration()
|| symbol->isForwardClassDeclaration()) {
} else if (symbol->asObjCClass() || symbol->asObjCBaseClass() || symbol->asObjCProtocol()
|| symbol->asObjCForwardClassDeclaration() || symbol->asObjCForwardProtocolDeclaration()
|| symbol->asForwardClassDeclaration()) {
addNames(symbol->name(), names);
} else if (symbol->isFunction()) {
} else if (symbol->asFunction()) {
if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId())
addNames(q->base(), names);
} else if (Enum *e = symbol->asEnum()) {
@ -316,7 +316,7 @@ QList<LookupItem> LookupContext::lookupByUsing(const Name *name,
{
QList<LookupItem> candidates;
// if it is a nameId there can be a using declaration for it
if (name->isNameId() || name->isTemplateNameId()) {
if (name->asNameId() || name->asTemplateNameId()) {
const QList<Symbol *> symbols = bindingScope->symbols();
for (Symbol *s : symbols) {
if (Scope *scope = s->asScope()) {
@ -409,7 +409,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
}
}
} else if (UsingDeclaration *ud = m->asUsingDeclaration()) {
if (name->isNameId()) {
if (name->asNameId()) {
if (const Name *usingDeclarationName = ud->name()) {
if (const QualifiedNameId *q = usingDeclarationName->asQualifiedNameId()) {
if (q->name() && q->name()->match(name))
@ -433,7 +433,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) {
return b->lookupType(name);
} else if (Class *scopeAsClass = scope->asClass()) {
if (scopeAsClass->enclosingScope()->isBlock()) {
if (scopeAsClass->enclosingScope()->asBlock()) {
if (ClassOrNamespace *b = lookupType(scopeAsClass->name(),
scopeAsClass->enclosingScope(),
enclosingBinding,
@ -460,13 +460,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
return candidates;
for (; scope; scope = scope->enclosingScope()) {
if (name->identifier() != nullptr && scope->isBlock()) {
if (name->identifier() != nullptr && scope->asBlock()) {
bindings()->lookupInScope(name, scope, &candidates, /*templateId = */ nullptr, /*binding=*/ nullptr);
if (! candidates.isEmpty()) {
// it's a local.
//for qualified it can be outside of the local scope
if (name->isQualifiedNameId())
if (name->asQualifiedNameId())
continue;
else
break;
@ -502,13 +502,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty()) {
// it's an argument or a template parameter.
//for qualified it can be outside of the local scope
if (name->isQualifiedNameId())
if (name->asQualifiedNameId())
continue;
else
break;
}
if (fun->name() && fun->name()->isQualifiedNameId()) {
if (fun->name() && fun->name()->asQualifiedNameId()) {
if (ClassOrNamespace *binding = bindings()->lookupType(fun)) {
candidates = binding->find(name);
@ -540,7 +540,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty()) {
// it's a template parameter.
//for qualified it can be outside of the local scope
if (name->isQualifiedNameId())
if (name->asQualifiedNameId())
continue;
else
break;
@ -572,7 +572,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty())
return candidates;
} else if (scope->isObjCClass() || scope->isObjCProtocol()) {
} else if (scope->asObjCClass() || scope->asObjCProtocol()) {
if (ClassOrNamespace *binding = bindings()->lookupType(scope))
candidates = binding->find(name);
@ -740,7 +740,7 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
for (Symbol *s : symbols) {
if (s->isFriend())
continue;
else if (s->isUsingNamespaceDirective())
else if (s->asUsingNamespaceDirective())
continue;
@ -825,11 +825,11 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
for (Symbol *s = scope->find(id); s; s = s->next()) {
if (s->isFriend())
continue; // skip friends
else if (s->isUsingNamespaceDirective())
else if (s->asUsingNamespaceDirective())
continue; // skip using namespace directives
else if (! id->match(s->identifier()))
continue;
else if (s->name() && s->name()->isQualifiedNameId())
else if (s->name() && s->name()->asQualifiedNameId())
continue; // skip qualified ids.
if (Q_UNLIKELY(debug)) {
@ -851,7 +851,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
}
}
if (templateId && (s->isDeclaration() || s->isFunction())) {
if (templateId && (s->asDeclaration() || s->asFunction())) {
FullySpecifiedType ty = DeprecatedGenTemplateInstance::instantiate(templateId, s, control());
item.setType(ty); // override the type.
}
@ -991,7 +991,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
} else if (! processed->contains(this)) {
processed->insert(this);
if (name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) {
if (name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
flush();
const QList<Symbol *> symbolList = symbols();
@ -1136,7 +1136,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
ClassOrNamespace *origin)
{
Q_ASSERT(name != nullptr);
Q_ASSERT(name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId());
Q_ASSERT(name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId());
const_cast<ClassOrNamespace *>(this)->flush();
@ -1255,7 +1255,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
return reference;
}
if (!name->isTemplateNameId())
if (!name->asTemplateNameId())
_alreadyConsideredClasses.insert(referenceClass);
QSet<ClassOrNamespace *> knownUsings = Utils::toSet(reference->usings());
@ -1270,7 +1270,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
instantiation->_templateId = templId;
QSet<ClassOrNamespace *> otherProcessed;
while (!origin->_symbols.isEmpty() && origin->_symbols[0]->isBlock()) {
while (!origin->_symbols.isEmpty() && origin->_symbols[0]->asBlock()) {
if (otherProcessed.contains(origin))
break;
otherProcessed.insert(origin);
@ -1634,7 +1634,7 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name, ClassOrNa
return findOrCreateType(q->base(), origin)->findOrCreateType(q->name(), origin, clazz);
} else if (name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) {
} else if (name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
QSet<ClassOrNamespace *> processed;
ClassOrNamespace *e = nestedType(name, &processed, origin);
@ -1791,7 +1791,7 @@ bool CreateBindings::visit(Class *klass)
ClassOrNamespace *previous = _currentClassOrNamespace;
ClassOrNamespace *binding = nullptr;
if (klass->name() && klass->name()->isQualifiedNameId())
if (klass->name() && klass->name()->asQualifiedNameId())
binding = _currentClassOrNamespace->lookupType(klass->name());
if (! binding)
@ -1956,7 +1956,7 @@ bool CreateBindings::visit(NamespaceAlias *a)
return false;
} else if (ClassOrNamespace *e = _currentClassOrNamespace->lookupType(a->namespaceName())) {
if (a->name()->isNameId() || a->name()->isTemplateNameId() || a->name()->isAnonymousNameId())
if (a->name()->asNameId() || a->name()->asTemplateNameId() || a->name()->asAnonymousNameId())
_currentClassOrNamespace->addNestedType(a->name(), e);
} else if (false) {
@ -2042,12 +2042,12 @@ Symbol *CreateBindings::instantiateTemplateFunction(const Name *instantiationNam
Template *specialization) const
{
if (!specialization || !specialization->declaration()
|| !specialization->declaration()->isFunction())
|| !specialization->declaration()->asFunction())
return nullptr;
int argumentCountOfInstantiation = 0;
const TemplateNameId *instantiation = nullptr;
if (instantiationName->isTemplateNameId()) {
if (instantiationName->asTemplateNameId()) {
instantiation = instantiationName->asTemplateNameId();
argumentCountOfInstantiation = instantiation->templateArgumentCount();
} else {

View File

@ -1045,7 +1045,7 @@ ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &origina
ClassOrNamespace *binding = nullptr;
if (Class *klass = ty->asClassType()) {
if (scope->isBlock())
if (scope->asBlock())
binding = _context.lookupType(klass->name(), scope, enclosingBinding);
if (!binding)
binding = _context.lookupType(klass, enclosingBinding);
@ -1135,7 +1135,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
instantiatedFunction = overloadTy->asFunctionType();
} else if (overloadType->isTemplateType()
&& overloadType->asTemplateType()->declaration()
&& overloadType->asTemplateType()->declaration()->isFunction()) {
&& overloadType->asTemplateType()->declaration()->asFunction()) {
instantiatedFunction = overloadType->asTemplateType()->declaration()->asFunction();
}

View File

@ -41,7 +41,7 @@ void SymbolNameVisitor::accept(Symbol *symbol)
if (Scope *scope = symbol->enclosingScope())
accept(scope);
if (! symbol->isTemplate()) {
if (! symbol->asTemplate()) {
if (const Name *name = symbol->name()) {
std::swap(_symbol, symbol);
accept(name);

View File

@ -285,8 +285,10 @@ bool DefaultImpl::dissolveCommand(QString *program, QStringList *arguments)
*arguments = QStringList();
} else {
if (!success) {
const ProcessResultData result = { 0, QProcess::NormalExit, QProcess::FailedToStart,
tr("Error in command line.") };
const ProcessResultData result = {0,
QProcess::NormalExit,
QProcess::FailedToStart,
QtcProcess::tr("Error in command line.")};
emit done(result);
return false;
}
@ -314,8 +316,8 @@ bool DefaultImpl::ensureProgramExists(const QString &program)
if (programFilePath.exists() && programFilePath.isExecutableFile())
return true;
const QString errorString = tr("The program \"%1\" does not exist or is not executable.")
.arg(program);
const QString errorString
= QtcProcess::tr("The program \"%1\" does not exist or is not executable.").arg(program);
const ProcessResultData result = { 0, QProcess::NormalExit, QProcess::FailedToStart,
errorString };
emit done(result);
@ -1983,21 +1985,24 @@ void QtcProcessPrivate::handleReadyRead(const QByteArray &outputData, const QByt
m_hangTimerCount = 0;
// TODO: store a copy of m_processChannelMode on start()? Currently we assert that state
// is NotRunning when setting the process channel mode.
if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedOutputChannel
|| m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
std::cout << outputData.constData() << std::flush;
} else {
m_stdOut.append(outputData);
if (!outputData.isEmpty())
if (!outputData.isEmpty()) {
if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedOutputChannel
|| m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
std::cout << outputData.constData() << std::flush;
} else {
m_stdOut.append(outputData);
emitReadyReadStandardOutput();
}
}
if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedErrorChannel
|| m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
std::cerr << errorData.constData() << std::flush;
} else {
m_stdErr.append(errorData);
if (!errorData.isEmpty())
if (!errorData.isEmpty()) {
if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedErrorChannel
|| m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
std::cerr << errorData.constData() << std::flush;
} else {
m_stdErr.append(errorData);
emitReadyReadStandardError();
}
}
}

View File

@ -79,43 +79,44 @@ static QString modeOption(TerminalMode m)
static QString msgCommChannelFailed(const QString &error)
{
return TerminalImpl::tr("Cannot set up communication channel: %1").arg(error);
return QtcProcess::tr("Cannot set up communication channel: %1").arg(error);
}
static QString msgPromptToClose()
{
// Shown in a terminal which might have a different character set on Windows.
return TerminalImpl::tr("Press <RETURN> to close this window...");
return QtcProcess::tr("Press <RETURN> to close this window...");
}
static QString msgCannotCreateTempFile(const QString &why)
{
return TerminalImpl::tr("Cannot create temporary file: %1").arg(why);
return QtcProcess::tr("Cannot create temporary file: %1").arg(why);
}
static QString msgCannotWriteTempFile()
{
return TerminalImpl::tr("Cannot write temporary file. Disk full?");
return QtcProcess::tr("Cannot write temporary file. Disk full?");
}
static QString msgCannotCreateTempDir(const QString & dir, const QString &why)
{
return TerminalImpl::tr("Cannot create temporary directory \"%1\": %2").arg(dir, why);
return QtcProcess::tr("Cannot create temporary directory \"%1\": %2").arg(dir, why);
}
static QString msgUnexpectedOutput(const QByteArray &what)
{
return TerminalImpl::tr("Unexpected output from helper program (%1).").arg(QString::fromLatin1(what));
return QtcProcess::tr("Unexpected output from helper program (%1).")
.arg(QString::fromLatin1(what));
}
static QString msgCannotChangeToWorkDir(const FilePath &dir, const QString &why)
{
return TerminalImpl::tr("Cannot change to working directory \"%1\": %2").arg(dir.toString(), why);
return QtcProcess::tr("Cannot change to working directory \"%1\": %2").arg(dir.toString(), why);
}
static QString msgCannotExecute(const QString & p, const QString &why)
{
return TerminalImpl::tr("Cannot execute \"%1\": %2").arg(p, why);
return QtcProcess::tr("Cannot execute \"%1\": %2").arg(p, why);
}
class TerminalProcessPrivate
@ -310,8 +311,8 @@ void TerminalImpl::start()
if (!success) {
delete d->m_pid;
d->m_pid = nullptr;
const QString msg = tr("The process \"%1\" could not be started: %2")
.arg(cmdLine, winErrorMessage(GetLastError()));
const QString msg = QtcProcess::tr("The process \"%1\" could not be started: %2")
.arg(cmdLine, winErrorMessage(GetLastError()));
cleanupAfterStartFailure(msg);
return;
}
@ -335,13 +336,14 @@ void TerminalImpl::start()
pcmd = m_setup.m_commandLine.executable().toString();
} else {
if (perr != ProcessArgs::FoundMeta) {
emitError(QProcess::FailedToStart, tr("Quoting error in command."));
emitError(QProcess::FailedToStart, QtcProcess::tr("Quoting error in command."));
return;
}
if (m_setup.m_terminalMode == TerminalMode::Debug) {
// FIXME: QTCREATORBUG-2809
emitError(QProcess::FailedToStart, tr("Debugging complex shell commands in a terminal"
" is currently not supported."));
emitError(QProcess::FailedToStart,
QtcProcess::tr("Debugging complex shell commands in a terminal"
" is currently not supported."));
return;
}
pcmd = qEnvironmentVariable("SHELL", "/bin/sh");
@ -358,9 +360,10 @@ void TerminalImpl::start()
&m_setup.m_environment,
&m_setup.m_workingDirectory);
if (qerr != ProcessArgs::SplitOk) {
emitError(QProcess::FailedToStart, qerr == ProcessArgs::BadQuoting
? tr("Quoting error in terminal command.")
: tr("Terminal command may not be a shell command."));
emitError(QProcess::FailedToStart,
qerr == ProcessArgs::BadQuoting
? QtcProcess::tr("Quoting error in terminal command.")
: QtcProcess::tr("Terminal command may not be a shell command."));
return;
}
@ -414,8 +417,10 @@ void TerminalImpl::start()
d->m_process.setReaperTimeout(m_setup.m_reaperTimeout);
d->m_process.start();
if (!d->m_process.waitForStarted()) {
const QString msg = tr("Cannot start the terminal emulator \"%1\", change the setting in the "
"Environment options.").arg(terminal.command);
const QString msg
= QtcProcess::tr("Cannot start the terminal emulator \"%1\", change the setting in the "
"Environment options.")
.arg(terminal.command);
cleanupAfterStartFailure(msg);
return;
}
@ -542,7 +547,8 @@ QString TerminalImpl::stubServerListen()
const QString stubServer = stubFifoDir + QLatin1String("/stub-socket");
if (!d->m_stubServer.listen(stubServer)) {
::rmdir(d->m_stubServerDir.constData());
return tr("Cannot create socket \"%1\": %2").arg(stubServer, d->m_stubServer.errorString());
return QtcProcess::tr("Cannot create socket \"%1\": %2")
.arg(stubServer, d->m_stubServer.errorString());
}
return QString();
#endif
@ -613,8 +619,9 @@ void TerminalImpl::readStubOutput()
SYNCHRONIZE | PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE,
FALSE, d->m_processId);
if (d->m_hInferior == NULL) {
emitError(QProcess::FailedToStart, tr("Cannot obtain a handle to the inferior: %1")
.arg(winErrorMessage(GetLastError())));
emitError(QProcess::FailedToStart,
QtcProcess::tr("Cannot obtain a handle to the inferior: %1")
.arg(winErrorMessage(GetLastError())));
// Uhm, and now what?
continue;
}
@ -623,8 +630,9 @@ void TerminalImpl::readStubOutput()
DWORD chldStatus;
if (!GetExitCodeProcess(d->m_hInferior, &chldStatus))
emitError(QProcess::UnknownError, tr("Cannot obtain exit status from inferior: %1")
.arg(winErrorMessage(GetLastError())));
emitError(QProcess::UnknownError,
QtcProcess::tr("Cannot obtain exit status from inferior: %1")
.arg(winErrorMessage(GetLastError())));
cleanupInferior();
emitFinished(chldStatus, QProcess::NormalExit);
});

View File

@ -38,6 +38,7 @@
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/devicesupport/idevicewidget.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>

View File

@ -28,7 +28,6 @@
#include "androidavdmanager.h"
#include "androiddevice.h"
#include "androiddeviceinfo.h"
#include "androidglobal.h"
#include "androidmanager.h"
#include <coreplugin/icore.h>
@ -38,6 +37,7 @@
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qmlprojectmanager/qmlprojectconstants.h>

View File

@ -24,6 +24,7 @@
****************************************************************************/
#pragma once
#include "androidconfigurations.h"
#include <projectexplorer/runcontrol.h>

View File

@ -45,6 +45,7 @@
#include <coreplugin/icore.h>
#include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/projectexplorerconstants.h>
using namespace ProjectExplorer;

View File

@ -28,6 +28,7 @@
#include "qdbconstants.h"
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>

View File

@ -46,6 +46,7 @@ extend_qtc_plugin(ClangCodeModel
extend_qtc_plugin(ClangCodeModel
CONDITION WITH_TESTS
SOURCES
test/activationsequenceprocessortest.cpp test/activationsequenceprocessortest.h
test/clangbatchfileprocessor.cpp test/clangbatchfileprocessor.h
test/clangdtests.cpp test/clangdtests.h
test/clangfixittest.cpp test/clangfixittest.h

View File

@ -92,6 +92,8 @@ QtcPlugin {
condition: qtc.testsEnabled
prefix: "test/"
files: [
"activationsequenceprocessortest.cpp",
"activationsequenceprocessortest.h",
"clangbatchfileprocessor.cpp",
"clangbatchfileprocessor.h",
"clangdtests.cpp",

View File

@ -29,6 +29,7 @@
#include "clangutils.h"
#ifdef WITH_TESTS
# include "test/activationsequenceprocessortest.h"
# include "test/clangbatchfileprocessor.h"
# include "test/clangdtests.h"
# include "test/clangfixittest.h"
@ -46,6 +47,7 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h>
@ -203,6 +205,7 @@ void ClangCodeModelPlugin::maybeHandleBatchFileAndExit() const
QVector<QObject *> ClangCodeModelPlugin::createTestObjects() const
{
return {
new Tests::ActivationSequenceProcessorTest,
new Tests::ClangdTestCompletion,
new Tests::ClangdTestExternalChanges,
new Tests::ClangdTestFindReferences,
@ -215,6 +218,5 @@ QVector<QObject *> ClangCodeModelPlugin::createTestObjects() const
}
#endif
} // namespace Internal
} // namespace Clang

View File

@ -0,0 +1,180 @@
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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
** 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.
**
** 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.
**
****************************************************************************/
#include "activationsequenceprocessortest.h"
#include "../clangactivationsequenceprocessor.h"
#include <cplusplus/Token.h>
#include <QtTest>
using namespace CPlusPlus;
namespace ClangCodeModel::Internal::Tests {
static bool resultIs(const ActivationSequenceProcessor &processor, Kind expectedKind,
int expectedOffset, int expectedNewPos)
{
return processor.completionKind() == expectedKind
&& processor.offset() == expectedOffset
&& processor.operatorStartPosition() == expectedNewPos;
}
void ActivationSequenceProcessorTest::testCouldNotProcesseRandomCharacters()
{
ActivationSequenceProcessor processor(QStringLiteral("xxx"), 3, false);
QVERIFY(resultIs(processor, T_EOF_SYMBOL, 0, 3));
}
void ActivationSequenceProcessorTest::testCouldNotProcesseEmptyString()
{
ActivationSequenceProcessor processor(QStringLiteral(""), 0, true);
QVERIFY(resultIs(processor, T_EOF_SYMBOL, 0, 0));
}
void ActivationSequenceProcessorTest::testDot()
{
ActivationSequenceProcessor processor(QStringLiteral("."), 1, true);
QVERIFY(resultIs(processor, T_DOT, 1, 0));
}
void ActivationSequenceProcessorTest::testComma()
{
ActivationSequenceProcessor processor(QStringLiteral(","), 2, false);
QVERIFY(resultIs(processor, T_COMMA, 1, 1));
}
void ActivationSequenceProcessorTest::testLeftParenAsFunctionCall()
{
ActivationSequenceProcessor processor(QStringLiteral("("), 3, true);
QVERIFY(resultIs(processor, T_LPAREN, 1, 2));
}
void ActivationSequenceProcessorTest::testLeftParenNotAsFunctionCall()
{
ActivationSequenceProcessor processor(QStringLiteral("("), 3, false);
QVERIFY(resultIs(processor, T_EOF_SYMBOL, 0, 3));
}
void ActivationSequenceProcessorTest::testColonColon()
{
ActivationSequenceProcessor processor(QStringLiteral("::"), 20, true);
QVERIFY(resultIs(processor, T_COLON_COLON, 2, 18));
}
void ActivationSequenceProcessorTest::testArrow()
{
ActivationSequenceProcessor processor(QStringLiteral("->"), 2, true);
QVERIFY(resultIs(processor, T_ARROW, 2, 0));
}
void ActivationSequenceProcessorTest::testDotStar()
{
ActivationSequenceProcessor processor(QStringLiteral(".*"), 3, true);
QVERIFY(resultIs(processor, T_DOT_STAR, 2, 1));
}
void ActivationSequenceProcessorTest::testArrowStar()
{
ActivationSequenceProcessor processor(QStringLiteral("->*"), 3, true);
QVERIFY(resultIs(processor, T_ARROW_STAR, 3, 0));
}
void ActivationSequenceProcessorTest::testDoxyGenCommentBackSlash()
{
ActivationSequenceProcessor processor(QStringLiteral(" \\"), 3, true);
QVERIFY(resultIs(processor, T_DOXY_COMMENT, 1, 2));
}
void ActivationSequenceProcessorTest::testDoxyGenCommentAt()
{
ActivationSequenceProcessor processor(QStringLiteral(" @"), 2, true);
QVERIFY(resultIs(processor, T_DOXY_COMMENT, 1, 1));
}
void ActivationSequenceProcessorTest::testAngleStringLiteral()
{
ActivationSequenceProcessor processor(QStringLiteral("<"), 1, true);
QVERIFY(resultIs(processor, T_ANGLE_STRING_LITERAL, 1, 0));
}
void ActivationSequenceProcessorTest::testStringLiteral()
{
ActivationSequenceProcessor processor(QStringLiteral("\""), 1, true);
QVERIFY(resultIs(processor, T_STRING_LITERAL, 1, 0));
}
void ActivationSequenceProcessorTest::testSlash()
{
ActivationSequenceProcessor processor(QStringLiteral("/"), 1, true);
QVERIFY(resultIs(processor, T_SLASH, 1, 0));
}
void ActivationSequenceProcessorTest::testPound()
{
ActivationSequenceProcessor processor(QStringLiteral("#"), 1, true);
QVERIFY(resultIs(processor, T_POUND, 1, 0));
}
void ActivationSequenceProcessorTest::testPositionIsOne()
{
ActivationSequenceProcessor processor(QStringLiteral("<xx"), 1, false);
QVERIFY(resultIs(processor, T_ANGLE_STRING_LITERAL, 1, 0));
}
void ActivationSequenceProcessorTest::testPositionIsTwo()
{
ActivationSequenceProcessor processor(QStringLiteral(" @x"), 2, true);
QVERIFY(resultIs(processor, T_DOXY_COMMENT, 1, 1));
}
void ActivationSequenceProcessorTest::testPositionIsTwoWithASingleSign()
{
ActivationSequenceProcessor processor(QStringLiteral("x<x"), 2, false);
QVERIFY(resultIs(processor, T_ANGLE_STRING_LITERAL, 1, 1));
}
void ActivationSequenceProcessorTest::testPositionIsThree()
{
ActivationSequenceProcessor processor(QStringLiteral("xx<"), 3, false);
QVERIFY(resultIs(processor, T_ANGLE_STRING_LITERAL, 1, 2));
}
} // namespace ClangCodeModel::Internal::Tests

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
@ -22,38 +22,38 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#define TEST_DEFINE 1
namespace Fooish
#include <QObject>
namespace ClangCodeModel::Internal::Tests {
class ActivationSequenceProcessorTest : public QObject
{
float flvalue = 100.f;
Q_OBJECT
class Bar;
class Bar {
public:
Bar();
volatile int member = 0;
private slots:
void testCouldNotProcesseRandomCharacters();
void testCouldNotProcesseEmptyString();
void testDot();
void testComma();
void testLeftParenAsFunctionCall();
void testLeftParenNotAsFunctionCall();
void testColonColon();
void testArrow();
void testDotStar();
void testArrowStar();
void testDoxyGenCommentBackSlash();
void testDoxyGenCommentAt();
void testAngleStringLiteral();
void testStringLiteral();
void testSlash();
void testPound();
void testPositionIsOne();
void testPositionIsTwo();
void testPositionIsTwoWithASingleSign();
void testPositionIsThree();
};
struct Barish
{
int foo(float p, int u);
int mem = 10;
};
}
class FooClass;
int foo(const float p, int u);
int foo();
int foo(float p, int u)
{
return foo() + p + u;
}
int foo(int x, float y);
} // namespace ClangCodeModel::Internal::Tests

View File

@ -51,4 +51,5 @@ extend_qtc_plugin(ClangTools
clangtoolspreconfiguredsessiontests.cpp clangtoolspreconfiguredsessiontests.h
clangtoolsunittests.cpp clangtoolsunittests.h
clangtoolsunittests.qrc
readexporteddiagnosticstest.cpp readexporteddiagnosticstest.h
)

View File

@ -33,7 +33,6 @@
#include "clangtoolsdiagnosticmodel.h"
#include "clangtoolsdiagnosticview.h"
#include "clangtoolslogfilereader.h"
#include "clangtoolsplugin.h"
#include "clangtoolsprojectsettings.h"
#include "clangtoolssettings.h"
#include "clangtoolsutils.h"
@ -54,6 +53,7 @@
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorericons.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>

View File

@ -91,6 +91,8 @@ QtcPlugin {
"clangtoolsunittests.cpp",
"clangtoolsunittests.h",
"clangtoolsunittests.qrc",
"readexporteddiagnosticstest.cpp",
"readexporteddiagnosticstest.h",
]
}

View File

@ -34,6 +34,7 @@
#include "settingswidget.h"
#ifdef WITH_TESTS
#include "readexporteddiagnosticstest.h"
#include "clangtoolspreconfiguredsessiontests.h"
#include "clangtoolsunittests.h"
#endif
@ -193,6 +194,7 @@ QVector<QObject *> ClangToolsPlugin::createTestObjects() const
#ifdef WITH_TESTS
tests << new PreconfiguredSessionTests;
tests << new ClangToolsUnitTests;
tests << new ReadExportedDiagnosticsTest;
#endif
return tests;
}

View File

@ -28,16 +28,18 @@
#include "clangtool.h"
#include "clangtoolsdiagnostic.h"
#include "clangtoolssettings.h"
#include "clangtoolsutils.h"
#include <coreplugin/icore.h>
#include <cppeditor/clangdiagnosticconfig.h>
#include <cppeditor/cppmodelmanager.h>
#include <cppeditor/cpptoolsreuse.h>
#include <cppeditor/cpptoolstestcase.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchain.h>
#include <qtsupport/qtkitinformation.h>

View File

@ -22,5 +22,17 @@
<file>unit-tests/clangtidy_clazy/clangtidy_clazy.pro</file>
<file>unit-tests/clangtidy_clazy/clazy_example.cpp</file>
<file>unit-tests/clangtidy_clazy/tidy_example.cpp</file>
<file>unit-tests/exported-diagnostics/clang-analyzer.dividezero.cpp</file>
<file>unit-tests/exported-diagnostics/clang-analyzer.dividezero.yaml</file>
<file>unit-tests/exported-diagnostics/clang-analyzer.dividezero_win.yaml</file>
<file>unit-tests/exported-diagnostics/clazy.qgetenv.cpp</file>
<file>unit-tests/exported-diagnostics/clazy.qgetenv.yaml</file>
<file>unit-tests/exported-diagnostics/clazy.qgetenv_win.yaml</file>
<file>unit-tests/exported-diagnostics/CMakeLists.txt</file>
<file>unit-tests/exported-diagnostics/empty.yaml</file>
<file>unit-tests/exported-diagnostics/main.cpp</file>
<file>unit-tests/exported-diagnostics/tidy.modernize-use-nullptr.cpp</file>
<file>unit-tests/exported-diagnostics/tidy.modernize-use-nullptr.yaml</file>
<file>unit-tests/exported-diagnostics/tidy.modernize-use-nullptr_win.yaml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,314 @@
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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
** 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.
**
** 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.
**
****************************************************************************/
#include "readexporteddiagnosticstest.h"
#include "clangtoolslogfilereader.h"
#include <cppeditor/cpptoolstestcase.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QtTest>
using namespace CppEditor::Tests;
using namespace Debugger;
using namespace Utils;
namespace ClangTools::Internal {
const char asciiWord[] = "FOO";
const char asciiMultiLine[] = "FOO\nBAR";
const char asciiMultiLine_dos[] = "FOO\r\nBAR";
const char nonAsciiMultiLine[] = "\xc3\xbc" "\n"
"\xe4\xba\x8c" "\n"
"\xf0\x90\x8c\x82" "X";
ReadExportedDiagnosticsTest::ReadExportedDiagnosticsTest()
: m_baseDir(new TemporaryCopiedDir(":/clangtools/unit-tests/exported-diagnostics")) {}
ReadExportedDiagnosticsTest::~ReadExportedDiagnosticsTest() { delete m_baseDir; }
void ReadExportedDiagnosticsTest::initTestCase() { QVERIFY(m_baseDir->isValid()); }
void ReadExportedDiagnosticsTest::init() { m_message.clear(); }
void ReadExportedDiagnosticsTest::testNonExistingFile()
{
const Diagnostics diags = readExportedDiagnostics("nonExistingFile.yaml", {}, &m_message);
QVERIFY(diags.isEmpty());
QVERIFY(!m_message.isEmpty());
}
void ReadExportedDiagnosticsTest::testEmptyFile()
{
const Diagnostics diags = readExportedDiagnostics(filePath("empty.yaml"), {}, &m_message);
QVERIFY(diags.isEmpty());
QVERIFY2(m_message.isEmpty(), qPrintable(m_message));
}
void ReadExportedDiagnosticsTest::testUnexpectedFileContents()
{
const Diagnostics diags = readExportedDiagnostics(filePath("tidy.modernize-use-nullptr.cpp"),
{}, &m_message);
QVERIFY(!m_message.isEmpty());
QVERIFY(diags.isEmpty());
}
static QString appendYamlSuffix(const char *filePathFragment)
{
const QString yamlSuffix = QLatin1String(Utils::HostOsInfo::isWindowsHost()
? "_win.yaml" : ".yaml");
return filePathFragment + yamlSuffix;
}
void ReadExportedDiagnosticsTest::testTidy()
{
const FilePath sourceFile = filePath("tidy.modernize-use-nullptr.cpp");
const QString exportedFile = createFile(
filePath(appendYamlSuffix("tidy.modernize-use-nullptr")).toString(),
sourceFile.toString());
Diagnostic expectedDiag;
expectedDiag.name = "modernize-use-nullptr";
expectedDiag.location = {sourceFile, 2, 25};
expectedDiag.description = "use nullptr [modernize-use-nullptr]";
expectedDiag.type = "warning";
expectedDiag.hasFixits = true;
expectedDiag.explainingSteps = {
ExplainingStep{"nullptr",
expectedDiag.location,
{expectedDiag.location, {sourceFile, 2, 26}},
true}};
const Diagnostics diags = readExportedDiagnostics(Utils::FilePath::fromString(exportedFile),
{}, &m_message);
QVERIFY2(m_message.isEmpty(), qPrintable(m_message));
QCOMPARE(diags, {expectedDiag});
}
void ReadExportedDiagnosticsTest::testAcceptDiagsFromFilePaths_None()
{
const QString sourceFile = filePath("tidy.modernize-use-nullptr.cpp").toString();
const QString exportedFile = createFile(filePath("tidy.modernize-use-nullptr.yaml").toString(),
sourceFile);
const auto acceptNone = [](const Utils::FilePath &) { return false; };
const Diagnostics diags = readExportedDiagnostics(FilePath::fromString(exportedFile),
acceptNone, &m_message);
QVERIFY2(m_message.isEmpty(), qPrintable(m_message));
QVERIFY(diags.isEmpty());
}
// Diagnostics from clang (static) analyzer passed through via clang-tidy
void ReadExportedDiagnosticsTest::testTidy_ClangAnalyzer()
{
const FilePath sourceFile = filePath("clang-analyzer.dividezero.cpp");
const QString exportedFile = createFile(
filePath(appendYamlSuffix("clang-analyzer.dividezero")).toString(),
sourceFile.toString());
Diagnostic expectedDiag;
expectedDiag.name = "clang-analyzer-core.DivideZero";
expectedDiag.location = {sourceFile, 4, 15};
expectedDiag.description = "Division by zero [clang-analyzer-core.DivideZero]";
expectedDiag.type = "warning";
expectedDiag.hasFixits = false;
expectedDiag.explainingSteps = {
ExplainingStep{"Assuming 'z' is equal to 0",
{sourceFile, 3, 7},
{},
false,
},
ExplainingStep{"Taking true branch",
{sourceFile, 3, 3},
{},
false,
},
ExplainingStep{"Division by zero",
{sourceFile, 4, 15},
{},
false,
},
};
const Diagnostics diags = readExportedDiagnostics(Utils::FilePath::fromString(exportedFile),
{}, &m_message);
QVERIFY2(m_message.isEmpty(), qPrintable(m_message));
QCOMPARE(diags, {expectedDiag});
}
void ReadExportedDiagnosticsTest::testClazy()
{
const FilePath sourceFile = filePath("clazy.qgetenv.cpp");
const QString exportedFile = createFile(filePath(appendYamlSuffix("clazy.qgetenv")).toString(),
sourceFile.toString());
Diagnostic expectedDiag;
expectedDiag.name = "clazy-qgetenv";
expectedDiag.location = {sourceFile, 7, 5};
expectedDiag.description = "qgetenv().isEmpty() allocates. Use qEnvironmentVariableIsEmpty() instead [clazy-qgetenv]";
expectedDiag.type = "warning";
expectedDiag.hasFixits = true;
expectedDiag.explainingSteps = {
ExplainingStep{"qEnvironmentVariableIsEmpty",
expectedDiag.location,
{expectedDiag.location, {sourceFile, 7, 12}},
true
},
ExplainingStep{")",
{sourceFile, 7, 18},
{{sourceFile, 7, 18}, {sourceFile, 7, 29}},
true},
};
const Diagnostics diags = readExportedDiagnostics(Utils::FilePath::fromString(exportedFile),
{}, &m_message);
QVERIFY2(m_message.isEmpty(), qPrintable(m_message));
QCOMPARE(diags, {expectedDiag});
}
void ReadExportedDiagnosticsTest::testOffsetInvalidText()
{
QVERIFY(!byteOffsetInUtf8TextToLineColumn(nullptr, 0));
}
void ReadExportedDiagnosticsTest::testOffsetInvalidOffset_EmptyInput()
{
QVERIFY(!byteOffsetInUtf8TextToLineColumn("", 0));
}
void ReadExportedDiagnosticsTest::testOffsetInvalidOffset_Before()
{
QVERIFY(!byteOffsetInUtf8TextToLineColumn(asciiWord, -1));
}
void ReadExportedDiagnosticsTest::testOffsetInvalidOffset_After()
{
QVERIFY(!byteOffsetInUtf8TextToLineColumn(asciiWord, 3));
}
void ReadExportedDiagnosticsTest::testOffsetInvalidOffset_NotFirstByteOfMultiByte()
{
QVERIFY(!byteOffsetInUtf8TextToLineColumn(nonAsciiMultiLine, 1));
}
void ReadExportedDiagnosticsTest::testOffsetStartOfFirstLine()
{
const auto info = byteOffsetInUtf8TextToLineColumn(asciiWord, 0);
QVERIFY(info);
QCOMPARE(info->line, 1);
QCOMPARE(info->column, 1);
}
void ReadExportedDiagnosticsTest::testOffsetEndOfFirstLine()
{
const auto info = byteOffsetInUtf8TextToLineColumn(asciiWord, 2);
QVERIFY(info);
QCOMPARE(info->line, 1);
QCOMPARE(info->column, 3);
}
// The invocation
//
// clang-tidy "-checks=-*,readability-braces-around-statements" /path/to/file
//
// for the code
//
// void f(bool b)
// {
// if (b)
// f(b);
// }
//
// emits
//
// 3:11: warning: statement should be inside braces [readability-braces-around-statements]
//
// The newline in the if-line is considered as column 11, which is normally not visible in the
// editor.
void ReadExportedDiagnosticsTest::testOffsetOffsetPointingToLineSeparator_unix()
{
const auto info = byteOffsetInUtf8TextToLineColumn(asciiMultiLine, 3);
QVERIFY(info);
QCOMPARE(info->line, 1);
QCOMPARE(info->column, 4);
}
// For a file with dos style line endings ("\r\n"), clang-tidy points to '\r'.
void ReadExportedDiagnosticsTest::testOffsetOffsetPointingToLineSeparator_dos()
{
const auto info = byteOffsetInUtf8TextToLineColumn(asciiMultiLine_dos, 3);
QVERIFY(info);
QCOMPARE(info->line, 1);
QCOMPARE(info->column, 4);
}
void ReadExportedDiagnosticsTest::testOffsetStartOfSecondLine()
{
const auto info = byteOffsetInUtf8TextToLineColumn(asciiMultiLine, 4);
QVERIFY(info);
QCOMPARE(info->line, 2);
QCOMPARE(info->column, 1);
}
void ReadExportedDiagnosticsTest::testOffsetMultiByteCodePoint1()
{
const auto info = byteOffsetInUtf8TextToLineColumn(nonAsciiMultiLine, 3);
QVERIFY(info);
QCOMPARE(info->line, 2);
QCOMPARE(info->column, 1);
}
void ReadExportedDiagnosticsTest::testOffsetMultiByteCodePoint2()
{
const auto info = byteOffsetInUtf8TextToLineColumn(nonAsciiMultiLine, 11);
QVERIFY(info);
QCOMPARE(info->line, 3);
QCOMPARE(info->column, 2);
}
// Replace FILE_PATH with a real absolute file path in the *.yaml files.
QString ReadExportedDiagnosticsTest::createFile(const QString &yamlFilePath,
const QString &filePathToInject) const
{
QTC_ASSERT(QDir::isAbsolutePath(filePathToInject), return QString());
const Utils::FilePath newFileName = FilePath::fromString(m_baseDir->absolutePath(
QFileInfo(yamlFilePath).fileName().toLocal8Bit()));
Utils::FileReader reader;
if (QTC_GUARD(reader.fetch(Utils::FilePath::fromString(yamlFilePath),
QIODevice::ReadOnly | QIODevice::Text))) {
QByteArray contents = reader.data();
contents.replace("FILE_PATH", filePathToInject.toLocal8Bit());
Utils::FileSaver fileSaver(newFileName, QIODevice::WriteOnly | QIODevice::Text);
QTC_CHECK(fileSaver.write(contents));
QTC_CHECK(fileSaver.finalize());
}
return newFileName.toString();
}
FilePath ReadExportedDiagnosticsTest::filePath(const QString &fileName) const
{
return FilePath::fromString(m_baseDir->absolutePath(fileName.toUtf8()));
}
} // namespace ClangTools::Internal

View File

@ -0,0 +1,76 @@
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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
** 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.
**
** 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.
**
****************************************************************************/
#pragma once
#include <QObject>
#include <QString>
namespace CppEditor::Tests { class TemporaryCopiedDir; }
namespace Utils { class FilePath; }
namespace ClangTools::Internal {
class ReadExportedDiagnosticsTest : public QObject
{
Q_OBJECT
public:
ReadExportedDiagnosticsTest();
~ReadExportedDiagnosticsTest();
private slots:
void initTestCase();
void init();
void testNonExistingFile();
void testEmptyFile();
void testUnexpectedFileContents();
void testTidy();
void testAcceptDiagsFromFilePaths_None();
void testTidy_ClangAnalyzer();
void testClazy();
void testOffsetInvalidText();
void testOffsetInvalidOffset_EmptyInput();
void testOffsetInvalidOffset_Before();
void testOffsetInvalidOffset_After();
void testOffsetInvalidOffset_NotFirstByteOfMultiByte();
void testOffsetStartOfFirstLine();
void testOffsetEndOfFirstLine();
void testOffsetOffsetPointingToLineSeparator_unix();
void testOffsetOffsetPointingToLineSeparator_dos();
void testOffsetStartOfSecondLine();
void testOffsetMultiByteCodePoint1();
void testOffsetMultiByteCodePoint2();
private:
QString createFile(const QString &yamlFilePath, const QString &filePathToInject) const;
Utils::FilePath filePath(const QString &fileName) const;
CppEditor::Tests::TemporaryCopiedDir * const m_baseDir;
QString m_message;
};
} // namespace ClangTools::Internal

View File

@ -105,17 +105,17 @@ void ParserTreeItemPrivate::mergeSymbol(const CPlusPlus::Symbol *symbol)
// any symbol which does not contain :: in the name
//! \todo collect statistics and reorder to optimize
if (symbol->isForwardClassDeclaration()
if (symbol->asForwardClassDeclaration()
|| symbol->isExtern()
|| symbol->isFriend()
|| symbol->isGenerated()
|| symbol->isUsingNamespaceDirective()
|| symbol->isUsingDeclaration()
|| symbol->asUsingNamespaceDirective()
|| symbol->asUsingDeclaration()
)
return;
const CPlusPlus::Name *symbolName = symbol->name();
if (symbolName && symbolName->isQualifiedNameId())
if (symbolName && symbolName->asQualifiedNameId())
return;
QString name = g_overview.prettyName(symbolName).trimmed();
@ -139,7 +139,7 @@ void ParserTreeItemPrivate::mergeSymbol(const CPlusPlus::Symbol *symbol)
childItem->d->m_symbolLocations.insert(location);
// prevent showing a content of the functions
if (!symbol->isFunction()) {
if (!symbol->asFunction()) {
if (const CPlusPlus::Scope *scope = symbol->asScope()) {
CPlusPlus::Scope::iterator cur = scope->memberBegin();
CPlusPlus::Scope::iterator last = scope->memberEnd();
@ -155,7 +155,7 @@ void ParserTreeItemPrivate::mergeSymbol(const CPlusPlus::Symbol *symbol)
}
// if item is empty and has not to be added
if (!symbol->isNamespace() || childItem->childCount())
if (!symbol->asNamespace() || childItem->childCount())
m_symbolInformations.insert(information, childItem);
}

View File

@ -55,6 +55,7 @@
#include <projectexplorer/namedwidget.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h>

View File

@ -39,6 +39,7 @@
#include <projectexplorer/processparameters.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/target.h>
#include <projectexplorer/xcodebuildparser.h>

View File

@ -81,8 +81,9 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
const FilePath buildDirectory = parameters.buildDirectory.onDevice(cmakeExecutable);
if (!buildDirectory.exists()) {
QString msg = tr("The build directory \"%1\" does not exist")
.arg(buildDirectory.toUserOutput());
QString msg = ::CMakeProjectManager::Internal::CMakeProcess::tr(
"The build directory \"%1\" does not exist")
.arg(buildDirectory.toUserOutput());
BuildSystem::appendBuildSystemOutput(msg + '\n');
emit finished();
return;
@ -90,9 +91,11 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
if (buildDirectory.needsDevice()) {
if (cmake->cmakeExecutable().host() != buildDirectory.host()) {
QString msg = tr("CMake executable \"%1\" and build directory "
"\"%2\" must be on the same device.")
.arg(cmake->cmakeExecutable().toUserOutput(), buildDirectory.toUserOutput());
QString msg = ::CMakeProjectManager::Internal::CMakeProcess::tr(
"CMake executable \"%1\" and build directory "
"\"%2\" must be on the same device.")
.arg(cmake->cmakeExecutable().toUserOutput(),
buildDirectory.toUserOutput());
BuildSystem::appendBuildSystemOutput(msg + '\n');
emit finished();
return;
@ -131,12 +134,15 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
BuildSystem::startNewBuildSystemOutput(
tr("Running %1 in %2.").arg(commandLine.toUserOutput(), buildDirectory.toUserOutput()));
::CMakeProjectManager::Internal::CMakeProcess::tr("Running %1 in %2.")
.arg(commandLine.toUserOutput(), buildDirectory.toUserOutput()));
m_futureInterface = QFutureInterface<void>();
m_futureInterface.setProgressRange(0, 1);
Core::ProgressManager::addTimedTask(m_futureInterface,
tr("Configuring \"%1\"").arg(parameters.projectName),
::CMakeProjectManager::Internal::CMakeProcess::tr(
"Configuring \"%1\"")
.arg(parameters.projectName),
"CMake.Configure",
10);
m_futureWatcher.reset(new QFutureWatcher<void>);
@ -167,14 +173,17 @@ void CMakeProcess::handleProcessDone(const Utils::ProcessResultData &resultData)
QString msg;
if (resultData.m_error == QProcess::FailedToStart) {
msg = tr("CMake process failed to start.");
msg = ::CMakeProjectManager::Internal::CMakeProcess::tr("CMake process failed to start.");
} else if (resultData.m_exitStatus != QProcess::NormalExit) {
if (m_futureInterface.isCanceled() || code == USER_STOP_EXIT_CODE)
msg = tr("CMake process was canceled by the user.");
else
msg = tr("CMake process crashed.");
msg = ::CMakeProjectManager::Internal::CMakeProcess::tr(
"CMake process was canceled by the user.");
else
msg = ::CMakeProjectManager::Internal::CMakeProcess::tr("CMake process crashed.");
} else if (code != 0) {
msg = tr("CMake process exited with exit code %1.").arg(code);
msg = ::CMakeProjectManager::Internal::CMakeProcess::tr(
"CMake process exited with exit code %1.")
.arg(code);
}
m_lastExitCode = code;

View File

@ -109,7 +109,8 @@ static std::vector<std::unique_ptr<CMakeTool>> autoDetectCMakeTools()
for (const FilePath &command : qAsConst(suspects)) {
auto item = std::make_unique<CMakeTool>(CMakeTool::AutoDetection, CMakeTool::createId());
item->setFilePath(command);
item->setDisplayName(CMakeToolManager::tr("System CMake at %1").arg(command.toUserOutput()));
item->setDisplayName(::CMakeProjectManager::CMakeToolManager::tr("System CMake at %1")
.arg(command.toUserOutput()));
found.emplace_back(std::move(item));
}

View File

@ -30,11 +30,14 @@
#include <coreplugin/icore.h>
#include <cppeditor/cpptoolstestcase.h>
#include <cppeditor/projectinfo.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/toolchainmanager.h>
#include <utils/algorithm.h>
#include <utils/hostosinfo.h>

View File

@ -2533,7 +2533,8 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document)
if (absoluteFilePath.isEmpty())
return false;
if (absoluteFilePath != document->filePath()) {
if (DocumentManager::filePathKey(absoluteFilePath, DocumentManager::ResolveLinks)
!= DocumentManager::filePathKey(document->filePath(), DocumentManager::ResolveLinks)) {
// close existing editors for the new file name
IDocument *otherDocument = DocumentModel::documentForFilePath(absoluteFilePath);
if (otherDocument)

View File

@ -32,10 +32,11 @@
#include "cppcheckdiagnosticsmodel.h"
#include "cppcheckmanualrundialog.h"
#include <projectexplorer/session.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
#include <coreplugin/actionmanager/actioncontainer.h>

View File

@ -84,7 +84,7 @@ CppcheckTextMark::CppcheckTextMark (const Diagnostic &diagnostic)
// Copy to clipboard action
QAction *action = new QAction();
action->setIcon(QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon()));
action->setToolTip(tr("Copy to Clipboard"));
action->setToolTip(TextMark::tr("Copy to Clipboard"));
QObject::connect(action, &QAction::triggered, [diagnostic]() {
const QString text = QString("%1:%2: %3")
.arg(diagnostic.fileName.toUserOutput())

View File

@ -121,7 +121,7 @@ protected:
addType(q->base());
addType(q->name());
} else if (name->isNameId() || name->isTemplateNameId()) {
} else if (name->asNameId() || name->asTemplateNameId()) {
addType(name->identifier());
}
@ -132,7 +132,7 @@ protected:
if (!name) {
return;
} else if (name->isNameId()) {
} else if (name->asNameId()) {
const Identifier *id = name->identifier();
_fields.insert(QByteArray::fromRawData(id->chars(), id->size()));
@ -144,7 +144,7 @@ protected:
if (!name) {
return;
} else if (name->isNameId()) {
} else if (name->asNameId()) {
const Identifier *id = name->identifier();
_functions.insert(QByteArray::fromRawData(id->chars(), id->size()));
}
@ -155,7 +155,7 @@ protected:
if (!name) {
return;
} else if (name->isNameId() || name->isTemplateNameId()) {
} else if (name->asNameId() || name->asTemplateNameId()) {
const Identifier *id = name->identifier();
_statics.insert(QByteArray::fromRawData(id->chars(), id->size()));
@ -195,7 +195,7 @@ protected:
if (symbol->isTypedef())
addType(symbol->name());
else if (!symbol->type()->isFunctionType() && symbol->enclosingScope()->isClass())
else if (!symbol->type()->isFunctionType() && symbol->enclosingScope()->asClass())
addField(symbol->name());
return true;
@ -791,7 +791,7 @@ void CheckSymbols::checkNamespace(NameAST *name)
if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) {
const QList<Symbol *> symbols = b->symbols();
for (const Symbol *s : symbols) {
if (s->isNamespace())
if (s->asNamespace())
return;
}
}
@ -812,7 +812,7 @@ bool CheckSymbols::hasVirtualDestructor(Class *klass) const
for (Symbol *s = klass->find(id); s; s = s->next()) {
if (!s->name())
continue;
if (s->name()->isDestructorNameId()) {
if (s->name()->asDestructorNameId()) {
if (Function *funTy = s->type()->asFunctionType()) {
if (funTy->isVirtual() && id->match(s->identifier()))
return true;
@ -1229,7 +1229,7 @@ void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast)
Kind kind = SemanticHighlighter::TypeUse;
const QList<Symbol *> &symbols = b->symbols();
for (const Symbol * const s : symbols) {
if (s->isNamespace()) {
if (s->asNamespace()) {
kind = SemanticHighlighter::NamespaceUse;
break;
}
@ -1243,8 +1243,8 @@ bool CheckSymbols::isTemplateClass(Symbol *symbol) const
if (symbol) {
if (Template *templ = symbol->asTemplate()) {
if (Symbol *declaration = templ->declaration()) {
return declaration->isClass()
|| declaration->isForwardClassDeclaration()
return declaration->asClass()
|| declaration->asForwardClassDeclaration()
|| declaration->isTypedef();
}
}
@ -1264,14 +1264,14 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
for (const LookupItem &r : candidates) {
Symbol *c = r.declaration();
if (c->isUsingDeclaration()) // skip using declarations...
if (c->asUsingDeclaration()) // skip using declarations...
continue;
if (c->isUsingNamespaceDirective()) // ... and using namespace directives.
if (c->asUsingNamespaceDirective()) // ... and using namespace directives.
continue;
if (c->isTypedef() || c->isNamespace() ||
if (c->isTypedef() || c->asNamespace() ||
c->isStatic() || //consider also static variable
c->isClass() || c->isEnum() || isTemplateClass(c) ||
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum()) {
c->asClass() || c->asEnum() || isTemplateClass(c) ||
c->asForwardClassDeclaration() || c->asTypenameArgument() || c->enclosingEnum()) {
int line, column;
getTokenStartPosition(startToken, &line, &column);
const unsigned length = tok.utf16chars();
@ -1279,7 +1279,7 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
Kind kind = SemanticHighlighter::TypeUse;
if (c->enclosingEnum() != nullptr)
kind = SemanticHighlighter::EnumerationUse;
else if (c->isNamespace())
else if (c->asNamespace())
kind = SemanticHighlighter::NamespaceUse;
else if (c->isStatic())
// treat static variable as a field(highlighting)
@ -1309,9 +1309,9 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
Symbol *c = r.declaration();
if (!c)
continue;
if (!c->isDeclaration())
if (!c->asDeclaration())
return false;
if (!(c->enclosingScope() && c->enclosingScope()->isClass()))
if (!(c->enclosingScope() && c->enclosingScope()->asClass()))
return false; // shadowed
if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
return false; // shadowed
@ -1359,7 +1359,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
// In addition check for destructors, since the leading ~ is not taken into consideration.
// We don't want to compare destructors with something else or the other way around.
if (isDestructor != c->name()->isDestructorNameId())
if (isDestructor != (c->name()->asDestructorNameId() != nullptr))
continue;
isConstructor = isConstructorDeclaration(c);

View File

@ -951,7 +951,7 @@ QVariant SymbolsModel::data(const QModelIndex &index, int role) const
} else if (column == SymbolColumn) {
QString name = Overview().prettyName(symbol->name());
if (name.isEmpty())
name = QLatin1String(symbol->isBlock() ? "<block>" : "<no name>");
name = QLatin1String(symbol->asBlock() ? "<block>" : "<no name>");
return name;
}
}

View File

@ -232,7 +232,7 @@ void CppAssistProposalItem::applyContextualContent(TextDocumentManipulatorInterf
// except when it might take template parameters.
if (!function->hasReturnType()
&& (function->unqualifiedName()
&& !function->unqualifiedName()->isDestructorNameId())) {
&& !function->unqualifiedName()->asDestructorNameId())) {
// Don't insert any magic, since the user might have just wanted to select the class
/// ### port me
@ -488,7 +488,7 @@ public:
AssistProposalItem *operator()(Symbol *symbol)
{
//using declaration can be qualified
if (!symbol || !symbol->name() || (symbol->name()->isQualifiedNameId()
if (!symbol || !symbol->name() || (symbol->name()->asQualifiedNameId()
&& !symbol->asUsingDeclaration()))
return nullptr;
@ -526,7 +526,7 @@ protected:
void visit(const Identifier *name) override
{
_item = newCompletionItem(name);
if (!_symbol->isScope() || _symbol->isFunction())
if (!_symbol->asScope() || _symbol->asFunction())
_item->setDetail(overview.prettyType(_symbol->type(), name));
}
@ -1441,7 +1441,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
if (ClassOrNamespace *binding = context.lookupType(scope)) {
for (int i = 0; i < scope->memberCount(); ++i) {
Symbol *member = scope->memberAt(i);
if (member->isEnum()) {
if (member->asEnum()) {
if (ClassOrNamespace *b = binding->findBlock(block))
completeNamespace(b);
}
@ -1451,21 +1451,21 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
if (ClassOrNamespace *b = binding->lookupType(u->name()))
usingBindings.append(b);
} else if (Class *c = member->asClass()) {
if (c->name()->isAnonymousNameId()) {
if (c->name()->asAnonymousNameId()) {
if (ClassOrNamespace *b = binding->findBlock(block))
completeClass(b);
}
}
}
}
} else if (scope->isFunction() || scope->isClass() || scope->isNamespace()) {
} else if (scope->asFunction() || scope->asClass() || scope->asNamespace()) {
currentBinding = context.lookupType(scope);
break;
}
}
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
if (scope->isBlock()) {
if (scope->asBlock()) {
for (int i = 0; i < scope->memberCount(); ++i)
addCompletionItem(scope->memberAt(i), FunctionLocalsOrder);
} else if (Function *fun = scope->asFunction()) {
@ -1491,7 +1491,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
const QList<Symbol *> symbols = currentBinding->symbols();
if (!symbols.isEmpty()) {
if (symbols.first()->isClass())
if (symbols.first()->asClass())
completeClass(currentBinding);
else
completeNamespace(currentBinding);
@ -1567,7 +1567,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
}
// it can be class defined inside a block
if (classTy->enclosingScope()->isBlock()) {
if (classTy->enclosingScope()->asBlock()) {
if (ClassOrNamespace *b = context.lookupType(classTy->name(), classTy->enclosingScope())) {
completeClass(b);
break;
@ -1590,7 +1590,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
} else if (Enum *e = ty->asEnumType()) {
// it can be class defined inside a block
if (e->enclosingScope()->isBlock()) {
if (e->enclosingScope()->asBlock()) {
if (ClassOrNamespace *b = context.lookupType(e)) {
Block *block = e->enclosingScope()->asBlock();
if (ClassOrNamespace *bb = b->findBlock(block)) {
@ -1708,18 +1708,18 @@ void InternalCppCompletionAssistProcessor::addClassMembersToCompletion(Scope *sc
for (Scope::iterator it = scope->memberBegin(); it != scope->memberEnd(); ++it) {
Symbol *member = *it;
if (member->isFriend()
|| member->isQtPropertyDeclaration()
|| member->isQtEnum()) {
|| member->asQtPropertyDeclaration()
|| member->asQtEnum()) {
continue;
} else if (!staticLookup && (member->isTypedef() ||
member->isEnum() ||
member->isClass())) {
member->asEnum() ||
member->asClass())) {
continue;
} else if (member->isClass() && member->name()->isAnonymousNameId()) {
} else if (member->asClass() && member->name()->asAnonymousNameId()) {
nestedAnonymouses.insert(member->asClass());
} else if (member->isDeclaration()) {
} else if (member->asDeclaration()) {
Class *declTypeAsClass = member->asDeclaration()->type()->asClassType();
if (declTypeAsClass && declTypeAsClass->name()->isAnonymousNameId())
if (declTypeAsClass && declTypeAsClass->name()->asAnonymousNameId())
nestedAnonymouses.erase(declTypeAsClass);
}
@ -1924,7 +1924,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
if (!memberName)
continue; // skip anonymous member.
else if (memberName->isQualifiedNameId())
else if (memberName->asQualifiedNameId())
continue; // skip
if (Function *funTy = member->type()->asFunctionType()) {
@ -2015,7 +2015,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
Scope *sc = context.thisDocument()->scopeAt(line, column);
if (sc && (sc->isClass() || sc->isNamespace())) {
if (sc && (sc->asClass() || sc->asNamespace())) {
// It may still be a function call. If the whole line parses as a function
// declaration, we should be certain that it isn't.
bool autocompleteSignature = false;

View File

@ -124,10 +124,10 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration)
overview.showReturnTypes = true;
overview.showTemplateParameters = true;
name = overview.prettyName(declaration->name());
if (declaration->enclosingScope()->isClass() ||
declaration->enclosingScope()->isNamespace() ||
declaration->enclosingScope()->isEnum() ||
declaration->enclosingScope()->isTemplate()) {
if (declaration->enclosingScope()->asClass() ||
declaration->enclosingScope()->asNamespace() ||
declaration->enclosingScope()->asEnum() ||
declaration->enclosingScope()->asTemplate()) {
qualifiedName = overview.prettyName(LookupContext::fullyQualifiedName(declaration));
helpIdCandidates = stripName(qualifiedName);
} else {
@ -187,7 +187,7 @@ void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
for (ClassOrNamespace *baseClass : bases) {
const QList<Symbol *> &symbols = baseClass->symbols();
for (Symbol *symbol : symbols) {
if (symbol->isClass() && (
if (symbol->asClass() && (
clazz = context.lookupType(symbol)) &&
!visited.contains(clazz)) {
CppClass baseCppClass(symbol);
@ -345,16 +345,16 @@ public:
static bool isCppClass(Symbol *symbol)
{
return symbol->isClass() || symbol->isForwardClassDeclaration()
|| (symbol->isTemplate() && symbol->asTemplate()->declaration()
&& (symbol->asTemplate()->declaration()->isClass()
|| symbol->asTemplate()->declaration()->isForwardClassDeclaration()));
return symbol->asClass() || symbol->asForwardClassDeclaration()
|| (symbol->asTemplate() && symbol->asTemplate()->declaration()
&& (symbol->asTemplate()->declaration()->asClass()
|| symbol->asTemplate()->declaration()->asForwardClassDeclaration()));
}
static Symbol *followClassDeclaration(Symbol *symbol, const Snapshot &snapshot, SymbolFinder symbolFinder,
LookupContext *context = nullptr)
{
if (!symbol->isForwardClassDeclaration())
if (!symbol->asForwardClassDeclaration())
return symbol;
Symbol *classDeclaration = symbolFinder.findMatchingClassDeclaration(symbol, snapshot);
@ -422,7 +422,7 @@ static QSharedPointer<CppElement> handleLookupItemMatch(const Snapshot &snapshot
element = QSharedPointer<CppElement>(new Unknown(type));
} else {
const FullySpecifiedType &type = declaration->type();
if (declaration->isNamespace()) {
if (declaration->asNamespace()) {
element = QSharedPointer<CppElement>(new CppNamespace(declaration));
} else if (isCppClass(declaration)) {
LookupContext contextToUse = context;
@ -434,11 +434,11 @@ static QSharedPointer<CppElement> handleLookupItemMatch(const Snapshot &snapshot
element = QSharedPointer<CppElement>(new CppEnumerator(enumerator));
} else if (declaration->isTypedef()) {
element = QSharedPointer<CppElement>(new CppTypedef(declaration));
} else if (declaration->isFunction()
} else if (declaration->asFunction()
|| (type.isValid() && type->isFunctionType())
|| declaration->isTemplate()) {
|| declaration->asTemplate()) {
element = QSharedPointer<CppElement>(new CppFunction(declaration));
} else if (declaration->isDeclaration() && type.isValid()) {
} else if (declaration->asDeclaration() && type.isValid()) {
element = QSharedPointer<CppElement>(
new CppVariable(declaration, context, lookupItem.scope()));
} else {
@ -451,7 +451,7 @@ static QSharedPointer<CppElement> handleLookupItemMatch(const Snapshot &snapshot
// special case for bug QTCREATORBUG-4780
static bool shouldOmitElement(const LookupItem &lookupItem, const Scope *scope)
{
return !lookupItem.declaration() && scope && scope->isFunction()
return !lookupItem.declaration() && scope && scope->asFunction()
&& lookupItem.type().match(scope->asFunction()->returnType());
}
@ -484,8 +484,8 @@ static LookupItem findLookupItem(const CPlusPlus::Snapshot &snapshot, CPlusPlus:
return LookupItem();
auto isInteresting = [followTypedef](Symbol *symbol) {
return symbol && (!followTypedef || (symbol->isClass() || symbol->isTemplate()
|| symbol->isForwardClassDeclaration() || symbol->isTypedef()));
return symbol && (!followTypedef || (symbol->asClass() || symbol->asTemplate()
|| symbol->asForwardClassDeclaration() || symbol->isTypedef()));
};
for (const LookupItem &item : lookupItems) {
@ -749,7 +749,7 @@ Utils::Link CppElementEvaluator::linkFromExpression(const QString &expression, c
Symbol *symbol = item.declaration();
if (!symbol)
continue;
if (!symbol->isClass() && !symbol->isTemplate())
if (!symbol->asClass() && !symbol->asTemplate())
continue;
return symbol->toLink();
}

View File

@ -413,11 +413,11 @@ static void find_helper(QFutureInterface<CPlusPlus::Usage> &future,
symbol->fileNameLength());
Utils::FilePaths files{sourceFile};
if (symbol->isClass()
|| symbol->isForwardClassDeclaration()
if (symbol->asClass()
|| symbol->asForwardClassDeclaration()
|| (symbol->enclosingScope()
&& !symbol->isStatic()
&& symbol->enclosingScope()->isNamespace())) {
&& symbol->enclosingScope()->asNamespace())) {
const CPlusPlus::Snapshot snapshotFromContext = context.snapshot();
for (auto i = snapshotFromContext.begin(), ei = snapshotFromContext.end(); i != ei; ++i) {
if (i.key() == sourceFile)
@ -479,7 +479,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
parameters.symbolFileName = QByteArray(symbol->fileName());
parameters.categorize = codeModelSettings()->categorizeFindReferences();
if (symbol->isClass() || symbol->isForwardClassDeclaration()) {
if (symbol->asClass() || symbol->asForwardClassDeclaration()) {
CPlusPlus::Overview overview;
parameters.prettySymbolName =
overview.prettyName(CPlusPlus::LookupContext::path(symbol).constLast());

View File

@ -117,13 +117,13 @@ bool VirtualFunctionHelper::canLookupVirtualFunctionOverrides(Function *function
if (!m_document || m_snapshot.isEmpty() || !m_function || !m_scope)
return false;
if (m_scope->isClass() && m_function->isPureVirtual()) {
if (m_scope->asClass() && m_function->isPureVirtual()) {
m_staticClassOfFunctionCallExpression = m_scope->asClass();
return true;
}
if (!m_baseExpressionAST || !m_expressionDocument
|| m_scope->isClass() || m_scope->isFunction()) {
|| m_scope->asClass() || m_scope->asFunction()) {
return false;
}
@ -191,7 +191,7 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con
const QList<Symbol *> symbols = binding->symbols();
if (!symbols.isEmpty()) {
Symbol * const first = symbols.first();
if (first->isForwardClassDeclaration())
if (first->asForwardClassDeclaration())
result = m_finder->findMatchingClassDeclaration(first, m_snapshot);
}
}
@ -253,7 +253,7 @@ static bool isForwardClassDeclaration(Type *type)
return true;
} else if (Template *templ = type->asTemplateType()) {
if (Symbol *declaration = templ->declaration()) {
if (declaration->isForwardClassDeclaration())
if (declaration->asForwardClassDeclaration())
return true;
}
}
@ -384,7 +384,7 @@ Link attemptDeclDef(const QTextCursor &cursor, Snapshot snapshot,
Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *symbolFinder)
{
if (symbol->isFunction())
if (symbol->asFunction())
return nullptr; // symbol is a function definition.
if (!symbol->type()->isFunctionType())
@ -706,7 +706,7 @@ void FollowSymbolUnderCursor::findLink(
for (const LookupItem &r : resolvedSymbols) {
if (Symbol *d = r.declaration()) {
if (d->isDeclaration() || d->isFunction()) {
if (d->asDeclaration() || d->asFunction()) {
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
if (data.filePath().toString() == fileName) {
if (line == d->line() && positionInBlock >= d->column()) {
@ -715,7 +715,7 @@ void FollowSymbolUnderCursor::findLink(
break;
}
}
} else if (d->isUsingDeclaration()) {
} else if (d->asUsingDeclaration()) {
int tokenBeginLineNumber = 0;
int tokenBeginColumnNumber = 0;
Utils::Text::convertPosition(document, beginOfToken, &tokenBeginLineNumber,
@ -768,11 +768,11 @@ void FollowSymbolUnderCursor::findLink(
if (def == lastVisibleSymbol)
def = nullptr; // jump to declaration then.
if (symbol->isForwardClassDeclaration()) {
if (symbol->asForwardClassDeclaration()) {
def = symbolFinder->findMatchingClassDeclaration(symbol, snapshot);
} else if (Template *templ = symbol->asTemplate()) {
if (Symbol *declaration = templ->declaration()) {
if (declaration->isForwardClassDeclaration())
if (declaration->asForwardClassDeclaration())
def = symbolFinder->findMatchingClassDeclaration(declaration, snapshot);
}
}
@ -828,7 +828,7 @@ void FollowSymbolUnderCursor::switchDeclDef(
} else if (SimpleDeclarationAST *simpleDeclaration = ast->asSimpleDeclaration()) {
if (List<Symbol *> *symbols = simpleDeclaration->symbols) {
if (Symbol *symbol = symbols->value) {
if (symbol->isDeclaration()) {
if (symbol->asDeclaration()) {
declarationSymbol = symbol;
if (symbol->type()->isFunctionType()) {
functionDeclarationSymbol = symbol;

View File

@ -76,8 +76,8 @@ protected:
if (Symbol *member = scope->memberAt(i)) {
if (member->isTypedef())
continue;
if (!member->isGenerated() && (member->isDeclaration() || member->isArgument())) {
if (member->name() && member->name()->isNameId()) {
if (!member->isGenerated() && (member->asDeclaration() || member->asArgument())) {
if (member->name() && member->name()->asNameId()) {
const Token token = tokenAt(member->sourceLocation());
int line, column;
getPosition(token.utf16charsBegin(), &line, &column);
@ -99,10 +99,10 @@ protected:
const Identifier *id = identifier(simpleName->identifier_token);
for (int i = _scopeStack.size() - 1; i != -1; --i) {
if (Symbol *member = _scopeStack.at(i)->find(id)) {
if (member->isTypedef() || !(member->isDeclaration() || member->isArgument()))
if (member->isTypedef() || !(member->asDeclaration() || member->asArgument()))
continue;
if (!member->isGenerated() && (member->sourceLocation() < firstToken
|| member->enclosingScope()->isFunction())) {
|| member->enclosingScope()->asFunction())) {
int line, column;
getTokenStartPosition(simpleName->identifier_token, &line, &column);
localUses[member].append(

View File

@ -32,19 +32,16 @@
#include "cppcodemodelinspectordumper.h"
#include "cppcurrentdocumentfilter.h"
#include "cppeditorconstants.h"
#include "cppeditorplugin.h"
#include "cppfindreferences.h"
#include "cppincludesfilter.h"
#include "cppindexingsupport.h"
#include "cpplocatordata.h"
#include "cpplocatorfilter.h"
#include "cppbuiltinmodelmanagersupport.h"
#include "cpprefactoringchanges.h"
#include "cppsourceprocessor.h"
#include "cpptoolsjsextension.h"
#include "cpptoolsreuse.h"
#include "editordocumenthandle.h"
#include "stringtable.h"
#include "symbolfinder.h"
#include "symbolsfindfilter.h"
@ -57,13 +54,17 @@
#include <cplusplus/ASTPath.h>
#include <cplusplus/TypeOfExpression.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmacro.h>
#include <projectexplorer/session.h>
#include <texteditor/textdocument.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
@ -1485,13 +1486,13 @@ QSet<QString> CppModelManager::symbolsInFiles(const QSet<Utils::FilePath> &files
const CPlusPlus::Identifier *symId = sym->identifier();
// Add any class, function or namespace identifiers
if ((sym->isClass() || sym->isFunction() || sym->isNamespace()) && symId
if ((sym->asClass() || sym->asFunction() || sym->asNamespace()) && symId
&& symId->chars()) {
uniqueSymbols.insert(QString::fromUtf8(symId->chars()));
}
// Handle specific case : get "Foo" in "void Foo::function() {}"
if (sym->isFunction() && !sym->asFunction()->isDeclaration()) {
if (sym->asFunction() && !sym->asFunction()->asDeclaration()) {
const char *className = belongingClassName(sym->asFunction());
if (className)
uniqueSymbols.insert(QString::fromUtf8(className));

View File

@ -67,11 +67,11 @@ public:
QString name = overviewModel->_overview.prettyName(symbol->name());
if (name.isEmpty())
name = QLatin1String("anonymous");
if (symbol->isObjCForwardClassDeclaration())
if (symbol->asObjCForwardClassDeclaration())
name = QLatin1String("@class ") + name;
if (symbol->isObjCForwardProtocolDeclaration() || symbol->isObjCProtocol())
if (symbol->asObjCForwardProtocolDeclaration() || symbol->asObjCProtocol())
name = QLatin1String("@protocol ") + name;
if (symbol->isObjCClass()) {
if (symbol->asObjCClass()) {
ObjCClass *clazz = symbol->asObjCClass();
if (clazz->isInterface())
name = QLatin1String("@interface ") + name;
@ -83,7 +83,7 @@ public:
clazz->categoryName()));
}
}
if (symbol->isObjCPropertyDeclaration())
if (symbol->asObjCPropertyDeclaration())
name = QLatin1String("@property ") + name;
// if symbol is a template we might change it now - so, use a copy instead as we're const
Symbol *symbl = symbol;
@ -98,13 +98,13 @@ public:
name += QString("<%1>").arg(parameters.join(QLatin1String(", ")));
symbl = templateDeclaration;
}
if (symbl->isObjCMethod()) {
if (symbl->asObjCMethod()) {
ObjCMethod *method = symbl->asObjCMethod();
if (method->isStatic())
name = QLatin1Char('+') + name;
else
name = QLatin1Char('-') + name;
} else if (! symbl->isScope() || symbl->isFunction()) {
} else if (! symbl->asScope() || symbl->asFunction()) {
QString type = overviewModel->_overview.prettyType(symbl->type());
if (Function *f = symbl->type()->asFunctionType()) {
name += type;

Some files were not shown because too many files have changed in this diff Show More