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() endif()
foreach(dependency ${_arg_DEPENDS}) foreach(dependency ${_arg_DEPENDS})
if (NOT TARGET ${dependency} AND NOT _arg_GTEST) if (NOT TARGET ${dependency})
if (WITH_DEBUG_CMAKE) if (WITH_DEBUG_CMAKE)
message(STATUS "'${dependency}' is not a target") message(STATUS "'${dependency}' is not a target")
endif() endif()

View File

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

View File

@ -28,35 +28,15 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Window 2.15
Item { Item {
id: root
width: 1024 width: 1024
height: 768 height: 768
visible: true 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 { Screen01 {
id: mainScreen id: mainScreen
anchors.fill: parent 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. 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. Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/ */
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import LandingPage import LandingPageApi
import QdsLandingPageTheme as Theme import LandingPage as Theme
Rectangle { Rectangle {
id: installQdsBlock id: root
color: Theme.Values.themeBackgroundColorNormal
border.width: 0
property alias installQdsBlockVisible: installQdsBlock.visible
property alias installButton: installButton
height: 200
Text { color: Theme.Colors.backgroundSecondary
id: statusText height: column.childrenRect.height + (2 * Theme.Values.spacing)
text: qsTr("No Qt Design Studio installation found")
font.family: Theme.Values.baseFont Connections {
font.pixelSize: Constants.fontSizeSubtitle target: installButton
anchors.top: parent.top function onClicked() { LandingPageApi.installQds() }
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
} }
Text { Column {
id: suggestionText id: column
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
}
PushButton { width: parent.width
id: installButton anchors.centerIn: parent
anchors.top: suggestionText.bottom
text: "Install" PageText {
anchors.topMargin: Constants.buttonDefaultMargin id: statusText
anchors.horizontalCenterOffset: 0 width: parent.width
anchors.horizontalCenter: parent.horizontalCenter 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. 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. Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/ */
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import LandingPage import QtQuick.Layouts 1.15
import QdsLandingPageTheme as Theme import LandingPageApi
import LandingPage as Theme
Rectangle { Rectangle {
id: projectInfo id: root
height: 300
color: Theme.Values.themeBackgroundColorNormal
border.color: Theme.Values.themeBackgroundColorNormal
border.width: 0
property bool qdsInstalled: qdsVersionText.text.length > 0 property bool qdsInstalled: qdsVersionText.text.length > 0
property bool projectFileExists: false property bool projectFileExists: false
property string qdsVersion: "UNKNOWN" property string qtVersion: qsTr("Unknown")
property string qtVersion: "UNKNOWN" property string qdsVersion: qsTr("Unknown")
property alias cmakeListText: cmakeList.text
property alias generateCmakeButton: generateCmakeButton
property alias generateProjectFileButton: generateProjectFileButton property alias generateProjectFileButton: generateProjectFileButton
Item { color: Theme.Colors.backgroundSecondary
id: projectFileInfoBox height: column.childrenRect.height + (2 * Theme.Values.spacing)
width: projectInfo.width
height: 150
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 30
Text { Connections {
target: generateProjectFileButton
function onClicked() { LandingPageApi.generateProjectFile() }
}
Column {
id: column
width: parent.width
anchors.centerIn: parent
spacing: Theme.Values.spacing
PageText {
id: projectFileInfoTitle id: projectFileInfoTitle
width: parent.width
text: qsTr("QML PROJECT FILE INFO") 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 id: projectFileInfoVersionBox
width: parent.width width: parent.width
height: 150 visible: root.projectFileExists
visible: projectFileExists
anchors.top: projectFileInfoTitle.bottom
anchors.topMargin: 0
anchors.horizontalCenter: parent.horizontalCenter
Text { PageText {
id: qtVersionText id: qtVersionText
text: qsTr("Qt Version - ") + qtVersion width: parent.width
font.family: Theme.Values.baseFont padding: Theme.Values.spacing
font.pixelSize: Constants.fontSizeSubtitle text: qsTr("Qt Version - ") + root.qtVersion
anchors.top: parent.top
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
} }
Text { PageText {
id: qdsVersionText id: qdsVersionText
text: qsTr("Qt Design Studio Version - ") + qdsVersion width: parent.width
font.family: Theme.Values.baseFont padding: Theme.Values.spacing
font.pixelSize: Constants.fontSizeSubtitle text: qsTr("Qt Design Studio Version - ") + root.qdsVersion
anchors.top: qtVersionText.bottom
horizontalAlignment: Text.AlignHCenter
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
} }
} }
Item { Column {
id: projectFileInfoMissingBox id: projectFileInfoMissingBox
width: parent.width width: parent.width
height: 200
visible: !projectFileInfoVersionBox.visible visible: !projectFileInfoVersionBox.visible
anchors.top: projectFileInfoTitle.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 0
Text { PageText {
id: projectFileInfoMissingText id: projectFileInfoMissingText
width: parent.width
padding: Theme.Values.spacing
text: qsTr("No QML project file found - Would you like to create one?") 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 { PushButton {
id: generateProjectFileButton id: generateProjectFileButton
anchors.top: projectFileInfoMissingText.bottom text: qsTr("Generate")
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
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
} }

View File

@ -1,5 +1,3 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2021 The Qt Company Ltd. ** Copyright (C) 2021 The Qt Company Ltd.
@ -24,49 +22,38 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Templates 2.15 import QtQuick.Templates 2.15
import QdsLandingPageTheme as Theme import LandingPage as Theme
Button { Button {
id: control id: control
implicitWidth: Math.max( implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
buttonBackground ? buttonBackground.implicitWidth : 0, implicitContentWidth + leftPadding + rightPadding)
textItem.implicitWidth + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitHeight: Math.max( implicitContentHeight + topPadding + bottomPadding)
buttonBackground ? buttonBackground.implicitHeight : 0,
textItem.implicitHeight + topPadding + bottomPadding)
leftPadding: 4 leftPadding: 4
rightPadding: 4 rightPadding: 4
text: "My Button"
property alias fontpixelSize: textItem.font.pixelSize
property bool forceHover: false
hoverEnabled: true hoverEnabled: true
state: "normal" font.family: Theme.Values.baseFont
font.pixelSize: 16
background: buttonBackground background: Rectangle {
Rectangle {
id: buttonBackground id: buttonBackground
color: Theme.Values.themeControlBackground color: Theme.Colors.backgroundPrimary
implicitWidth: 100 implicitWidth: 100
implicitHeight: 40 implicitHeight: 35
opacity: enabled ? 1 : 0.3 border.color: Theme.Colors.foregroundSecondary
radius: 2
border.color: Theme.Values.themeControlOutline
anchors.fill: parent anchors.fill: parent
} }
contentItem: textItem contentItem: Text {
Text {
id: textItem id: textItem
text: control.text text: control.text
font.pixelSize: 18 font: control.font
color: Theme.Colors.text
opacity: enabled ? 1.0 : 0.3
color: Theme.Values.themeTextColor
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
rightPadding: 5 rightPadding: 5
@ -75,46 +62,51 @@ Button {
states: [ states: [
State { State {
name: "normal" name: "default"
when: !control.down && !control.hovered && !control.forceHover when: control.enabled && !control.hovered && !control.pressed && !control.checked
PropertyChanges { PropertyChanges {
target: buttonBackground target: buttonBackground
color: Theme.Values.themeControlBackground color: Theme.Colors.backgroundPrimary
border.color: Theme.Values.themeControlOutline
} }
PropertyChanges { PropertyChanges {
target: textItem target: textItem
color: Theme.Values.themeTextColor color: Theme.Colors.text
} }
}, },
State { State {
name: "hover" name: "hover"
when: (control.hovered || control.forceHover) && !control.down extend: "default"
PropertyChanges { when: control.enabled && control.hovered && !control.pressed
target: textItem
color: Theme.Values.themeTextColor
}
PropertyChanges { PropertyChanges {
target: buttonBackground target: buttonBackground
color: Theme.Values.themeControlBackgroundHover color: Theme.Colors.hover
border.color: Theme.Values.themeControlBackgroundHover
} }
}, },
State { State {
name: "activeQds" name: "press"
when: control.down extend: "default"
PropertyChanges { when: control.hovered && control.pressed
target: textItem
color: Theme.Values.themeTextColor
}
PropertyChanges { PropertyChanges {
target: buttonBackground target: buttonBackground
color: Theme.Values.themeControlBackgroundInteraction color: Theme.Colors.accent
border.color: Theme.Values.themeControlOutlineInteraction 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. 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. Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/ */
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 6.2 import QtQuick.Controls 6.2
import LandingPage import QtQuick.Layouts 1.15
import LandingPageApi import LandingPageApi
import QdsLandingPageTheme as Theme import LandingPage as Theme
Rectangle { Rectangle {
id: rectangle2 id: root
width: 1024 width: 1024
height: 768 height: 768
color: Theme.Values.themeBackgroundColorNormal color: Theme.Colors.backgroundPrimary
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
Rectangle { Connections {
id: logoArea target: openQds
width: parent.width function onClicked() { LandingPageApi.openQds(rememberCheckbox.checkState === Qt.Checked) }
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
}
} }
Item { Connections {
id: statusBox target: openQtc
anchors.top: logoArea.bottom function onClicked() { LandingPageApi.openQtc(rememberCheckbox.checkState === Qt.Checked) }
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
}
} }
Rectangle { states: [
id: buttonBox State {
width: parent.width name: "large"
height: 220 when: root.width > Theme.Values.layoutBreakpointLG
anchors.bottom: parent.bottom PropertyChanges {
anchors.horizontalCenter: parent.horizontalCenter target: Theme.Values
color: Theme.Values.themeBackgroundColorNormal fontSizeTitle: Theme.Values.fontSizeTitleLG
fontSizeSubtitle: Theme.Values.fontSizeSubtitleLG
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
} }
PropertyChanges {
PushButton { target: buttonBoxGrid
id: openQds columns: 2
anchors.top: openQdsText.bottom }
anchors.horizontalCenter: parent.horizontalCenter },
text: "Open" State {
anchors.topMargin: Constants.buttonSmallMargin name: "medium"
enabled: qdsInstalled 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 { ScrollView {
id: openQtcBox id: scrollView
width: parent.width / 2 anchors.fill: root
height: parent.height
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.rightMargin: 0
Text { Column {
id: openQtcText id: layout
text: qsTr("Open with Qt Creator - Text Mode") spacing: 0
font.pixelSize: Constants.fontSizeSubtitle width: scrollView.width
font.family: Theme.Values.baseFont
anchors.horizontalCenter: parent.horizontalCenter Item {
anchors.top: parent.top width: layout.width
anchors.topMargin: 50 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 { InstallQdsStatusBlock {
id: openQtc id: installQdsStatusBlock
anchors.top: openQtcText.bottom width: parent.width
anchors.horizontalCenter: parent.horizontalCenter visible: !LandingPageApi.qdsInstalled
anchors.topMargin: Constants.buttonSmallMargin
text: "Open"
} }
}
CheckBox { ProjectInfoStatusBlock {
id: rememberCheckbox id: projectInfoStatusBlock
text: qsTr("Remember my choice") width: parent.width
font.family: Theme.Values.baseFont visible: !installQdsStatusBlock.visible
anchors.bottom: parent.bottom projectFileExists: LandingPageApi.projectFileExists
anchors.bottomMargin: 30 qtVersion: LandingPageApi.qtVersion
anchors.horizontalCenter: parent.horizontalCenter 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 pragma Singleton
import QtQuick 2.10 import QtQuick 2.15
QtObject { QtObject {
readonly property int buttonDefaultMargin: 30 readonly property color text: "#ffe7e7e7"
readonly property int buttonSmallMargin: 20 readonly property color foregroundPrimary: "#ffa3a3a3"
readonly property color foregroundSecondary: "#ff808080"
readonly property int fontSizeTitle: 55 readonly property color backgroundPrimary: "#ff333333"
readonly property int fontSizeSubtitle: 22 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/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** 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> QtObject {
readonly property color text: Theme.color(Theme.Welcome_TextColor)
inline readonly property color foregroundPrimary: Theme.color(Theme.Welcome_ForegroundPrimaryColor)
bool operator==(const CXSourceLocation &first, const CXSourceLocation &second) readonly property color foregroundSecondary: Theme.color(Theme.Welcome_ForegroundSecondaryColor)
{ readonly property color backgroundPrimary: Theme.color(Theme.Welcome_BackgroundPrimaryColor)
return clang_equalLocations(first, second); 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)
inline readonly property color link: Theme.color(Theme.Welcome_LinkColor)
bool operator==(const CXSourceRange &first, const CXSourceRange &second) readonly property color disabledLink: Theme.color(Theme.Welcome_DisabledLinkColor)
{
return clang_equalRanges(first, second);
} }

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/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** 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, "") property real scaleFactor: 1.0
{ property real checkBoxSize: Math.round(26 * values.scaleFactor)
if (arg.text != diagnosticContainer.text) { property real checkBoxIndicatorSize: Math.round(14 * values.scaleFactor)
*result_listener << "text is " + PrintToString(arg.text) property real checkBoxSpacing: Math.round(6 * values.scaleFactor)
+ " and not " + PrintToString(diagnosticContainer.text); property real border: 1
return false;
}
if (arg.location != diagnosticContainer.location) { property int fontSizeTitle: values.fontSizeTitleLG
*result_listener << "location is " + PrintToString(arg.location) property int fontSizeSubtitle: values.fontSizeSubtitleLG
+ " and not " + PrintToString(diagnosticContainer.location);
return false;
}
if (arg.children != diagnosticContainer.children) { readonly property int fontSizeTitleSM: 20
*result_listener << "children are " + PrintToString(arg.children) readonly property int fontSizeTitleMD: 32
+ " and not " + PrintToString(diagnosticContainer.children); readonly property int fontSizeTitleLG: 50
return false;
}
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" directory: "imports"
} }
QmlFiles {
directory: "mockimports"
}
JavaScriptFiles { JavaScriptFiles {
directory: "content" directory: "content"
} }
@ -69,11 +73,14 @@ Project {
*/ */
} }
/* List of plugin directories passed to QML runtime */ /* 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 qt6Project: true
qdsVersion: "3.2" 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/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
@ -23,23 +23,22 @@
** **
****************************************************************************/ ****************************************************************************/
void function() pragma Singleton
{ import QtQuick 2.15
import StudioFonts
}
class Foo;
void functionWithArguments(int i, char *c, const Foo &ref)
{
}
void otherFunction()
{
}
void f()
{
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 2.15
import QtQuick.Controls 2.15
import QdsLandingPageTheme as Theme
Rectangle { QtObject {}
color: Theme.Values.themeControlBackground
width: parent.width
height: 2
z: 10
anchors.horizontalCenter: parent.horizontalCenter
}

View File

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

View File

@ -37,4 +37,5 @@ else()
endif() endif()
@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}) 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}) 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} target_link_libraries(%{TargetName}
PRIVATE Qt6::Quick) 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 WIN32_EXECUTABLE TRUE
) )
install(TARGETS %{ProjectName} BUNDLE DESTINATION .) install(TARGETS %{ProjectName}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6) if(QT_VERSION_MAJOR EQUAL 6)
qt_import_qml_plugins(%{ProjectName}) qt_import_qml_plugins(%{ProjectName})

View File

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

View File

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

View File

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

View File

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

View File

@ -25,17 +25,18 @@
namespace CPlusPlus { namespace CPlusPlus {
class CPLUSPLUS_EXPORT FullySpecifiedType class CPLUSPLUS_EXPORT FullySpecifiedType final
{ {
public: public:
FullySpecifiedType(Type *type = nullptr); FullySpecifiedType();
~FullySpecifiedType(); FullySpecifiedType(Type *type);
~FullySpecifiedType() = default;
bool isValid() const; bool isValid() const;
explicit operator bool() const; explicit operator bool() const;
Type *type() const; Type *type() const { return _type; }
void setType(Type *type); void setType(Type *type) { _type = type; }
FullySpecifiedType qualifiedType() const; FullySpecifiedType qualifiedType() const;
@ -109,8 +110,8 @@ public:
FullySpecifiedType simplified() const; FullySpecifiedType simplified() const;
unsigned flags() const; unsigned flags() const { return _flags; }
void setFlags(unsigned flags); void setFlags(unsigned flags) { _flags = flags; }
private: private:
Type *_type; 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: public:
Identifier(const char *chars, int size) Identifier(const char *chars, int size)
@ -114,8 +114,7 @@ public:
const Identifier *identifier() const override { return this; } const Identifier *identifier() const override { return this; }
const Identifier *asNameId() const override const Identifier *asNameId() const override { return this; }
{ return this; }
protected: protected:
void accept0(NameVisitor *visitor) const override; void accept0(NameVisitor *visitor) const override;

View File

@ -35,30 +35,6 @@ Name::Name()
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 void Name::accept(NameVisitor *visitor) const
{ {
if (visitor->preVisit(this)) if (visitor->preVisit(this))

View File

@ -35,15 +35,6 @@ public:
virtual const Identifier *identifier() const = 0; 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 Identifier *asNameId() const { return nullptr; }
virtual const AnonymousNameId *asAnonymousNameId() const { return nullptr; } virtual const AnonymousNameId *asAnonymousNameId() const { return nullptr; }
virtual const TemplateNameId *asTemplateNameId() 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 OperatorNameId::Kind OperatorNameId::kind() const
{ return _kind; } { return _kind; }
const Identifier *OperatorNameId::identifier() const
{ return nullptr; }
ConversionNameId::ConversionNameId(const FullySpecifiedType &type) ConversionNameId::ConversionNameId(const FullySpecifiedType &type)
: _type(type) : _type(type)
{ } { }
@ -191,11 +188,7 @@ bool ConversionNameId::match0(const Name *otherName, Matcher *matcher) const
return false; return false;
} }
FullySpecifiedType ConversionNameId::type() const
{ return _type; }
const Identifier *ConversionNameId::identifier() const
{ return nullptr; }
SelectorNameId::~SelectorNameId() SelectorNameId::~SelectorNameId()
{ } { }
@ -249,5 +242,4 @@ bool AnonymousNameId::match0(const Name *otherName, Matcher *matcher) const
return false; return false;
} }
const Identifier *AnonymousNameId::identifier() const
{ return nullptr; }

View File

@ -234,10 +234,8 @@ public:
Kind kind() const; Kind kind() const;
const Identifier *identifier() const override; const Identifier *identifier() const override { return nullptr; }
const OperatorNameId *asOperatorNameId() const override { return this; }
const OperatorNameId *asOperatorNameId() const override
{ return this; }
protected: protected:
void accept0(NameVisitor *visitor) const override; void accept0(NameVisitor *visitor) const override;
@ -253,12 +251,9 @@ public:
ConversionNameId(const FullySpecifiedType &type); ConversionNameId(const FullySpecifiedType &type);
virtual ~ConversionNameId(); virtual ~ConversionNameId();
FullySpecifiedType type() const; FullySpecifiedType type() const { return _type; }
const Identifier *identifier() const override { return nullptr; }
const Identifier *identifier() const override; const ConversionNameId *asConversionNameId() const override { return this; }
const ConversionNameId *asConversionNameId() const override
{ return this; }
protected: protected:
void accept0(NameVisitor *visitor) const override; void accept0(NameVisitor *visitor) const override;
@ -300,7 +295,7 @@ private:
bool _hasArguments; bool _hasArguments;
}; };
class CPLUSPLUS_EXPORT AnonymousNameId: public Name class CPLUSPLUS_EXPORT AnonymousNameId final : public Name
{ {
public: public:
AnonymousNameId(int classTokenIndex); AnonymousNameId(int classTokenIndex);
@ -308,10 +303,9 @@ public:
int classTokenIndex() const; int classTokenIndex() const;
const Identifier *identifier() const override; const Identifier *identifier() const override { return nullptr; }
const AnonymousNameId *asAnonymousNameId() const override const AnonymousNameId *asAnonymousNameId() const override { return this; }
{ return this; }
protected: protected:
void accept0(NameVisitor *visitor) const override; 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()) { } else if (const DestructorNameId *d = identity->asDestructorNameId()) {
if (d->identifier()->match(id)) if (d->identifier()->match(id))
break; break;
} else if (identity->isQualifiedNameId()) { } else if (identity->asQualifiedNameId()) {
return nullptr; return nullptr;
} else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) { } else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
if (selectorNameId->identifier()->match(id)) if (selectorNameId->identifier()->match(id))

View File

@ -142,23 +142,7 @@ void Symbol::visitSymbol(Symbol *symbol, SymbolVisitor *visitor)
symbol->visitSymbol(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) 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 const char *Symbol::fileName() const
{ return _fileId ? _fileId->chars() : ""; } { return _fileId ? _fileId->chars() : ""; }
@ -208,9 +177,6 @@ const Name *Symbol::unqualifiedName() const
return _name; return _name;
} }
const Name *Symbol::name() const
{ return _name; }
void Symbol::setName(const Name *name) void Symbol::setName(const Name *name)
{ {
_name = name; _name = name;
@ -231,9 +197,6 @@ const Identifier *Symbol::identifier() const
return nullptr; return nullptr;
} }
Scope *Symbol::enclosingScope() const
{ return _enclosingScope; }
void Symbol::setEnclosingScope(Scope *scope) void Symbol::setEnclosingScope(Scope *scope)
{ {
CPP_CHECK(! _enclosingScope); CPP_CHECK(! _enclosingScope);
@ -299,126 +262,6 @@ Block *Symbol::enclosingBlock() const
return nullptr; 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) void Symbol::copy(Symbol *other)
{ {
_sourceLocation = other->_sourceLocation; _sourceLocation = other->_sourceLocation;

View File

@ -61,16 +61,16 @@ public:
virtual ~Symbol(); virtual ~Symbol();
/// Returns this Symbol's source location. /// 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. /// \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. /// \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. /// Returns this Symbol's file name.
const StringLiteral *fileId() const; const StringLiteral *fileId() const { return _fileId; }
/// Returns this Symbol's file name. /// Returns this Symbol's file name.
const char *fileName() const; const char *fileName() const;
@ -79,7 +79,7 @@ public:
int fileNameLength() const; int fileNameLength() const;
/// Returns this Symbol's name. /// Returns this Symbol's name.
const Name *name() const; const Name *name() const { return _name; }
/// Sets this Symbol's name. /// Sets this Symbol's name.
void setName(const Name *name); // ### dangerous void setName(const Name *name); // ### dangerous
@ -88,115 +88,46 @@ public:
const Identifier *identifier() const; const Identifier *identifier() const;
/// Returns this Symbol's storage class specifier. /// Returns this Symbol's storage class specifier.
int storage() const; int storage() const { return _storage; }
/// Sets this Symbol's storage class specifier. /// Sets this Symbol's storage class specifier.
void setStorage(int storage); void setStorage(int storage) { _storage = storage; }
/// Returns this Symbol's visibility. /// Returns this Symbol's visibility.
int visibility() const; int visibility() const { return _visibility; }
/// Sets this Symbol's visibility. /// Sets this Symbol's visibility.
void setVisibility(int visibility); void setVisibility(int visibility) { _visibility = visibility; }
/// Returns the next chained Symbol. /// Returns the next chained Symbol.
Symbol *next() const; Symbol *next() const { return _next; }
/// Returns true if this Symbol has friend storage specifier. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// Returns true if this Symbol's visibility is private.
bool isPrivate() const; bool isPrivate() const { return _visibility == Private; }
/// 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;
Utils::Link toLink() const; Utils::Link toLink() const;
@ -226,53 +157,98 @@ public:
virtual const ObjCMethod *asObjCMethod() const { return nullptr; } virtual const ObjCMethod *asObjCMethod() const { return nullptr; }
virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const { return nullptr; } virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const { return nullptr; }
/// Returns this Symbol as a Scope.
virtual Scope *asScope() { return nullptr; } virtual Scope *asScope() { return nullptr; }
/// Returns this Symbol as an Enum.
virtual Enum *asEnum() { return nullptr; } virtual Enum *asEnum() { return nullptr; }
/// Returns this Symbol as an Function.
virtual Function *asFunction() { return nullptr; } virtual Function *asFunction() { return nullptr; }
/// Returns this Symbol as a Namespace.
virtual Namespace *asNamespace() { return nullptr; } virtual Namespace *asNamespace() { return nullptr; }
/// Returns this Symbol as a Template.
virtual Template *asTemplate() { return nullptr; } virtual Template *asTemplate() { return nullptr; }
virtual NamespaceAlias *asNamespaceAlias() { return nullptr; } virtual NamespaceAlias *asNamespaceAlias() { return nullptr; }
/// Returns this Symbol as a Class.
virtual Class *asClass() { return nullptr; } virtual Class *asClass() { return nullptr; }
/// Returns this Symbol as a Block.
virtual Block *asBlock() { return nullptr; } virtual Block *asBlock() { return nullptr; }
/// Returns this Symbol as a UsingNamespaceDirective.
virtual UsingNamespaceDirective *asUsingNamespaceDirective() { return nullptr; } virtual UsingNamespaceDirective *asUsingNamespaceDirective() { return nullptr; }
/// Returns this Symbol as a UsingDeclaration.
virtual UsingDeclaration *asUsingDeclaration() { return nullptr; } virtual UsingDeclaration *asUsingDeclaration() { return nullptr; }
/// Returns this Symbol as a Declaration.
virtual Declaration *asDeclaration() { return nullptr; } virtual Declaration *asDeclaration() { return nullptr; }
/// Returns this Symbol as an Argument.
virtual Argument *asArgument() { return nullptr; } virtual Argument *asArgument() { return nullptr; }
/// Returns this Symbol as a Typename argument.
virtual TypenameArgument *asTypenameArgument() { return nullptr; } virtual TypenameArgument *asTypenameArgument() { return nullptr; }
/// Returns this Symbol as a BaseClass.
virtual BaseClass *asBaseClass() { return nullptr; } virtual BaseClass *asBaseClass() { return nullptr; }
/// Returns this Symbol as a ForwardClassDeclaration.
virtual ForwardClassDeclaration *asForwardClassDeclaration() { return nullptr; } virtual ForwardClassDeclaration *asForwardClassDeclaration() { return nullptr; }
/// Returns this Symbol as a QtPropertyDeclaration.
virtual QtPropertyDeclaration *asQtPropertyDeclaration() { return nullptr; } virtual QtPropertyDeclaration *asQtPropertyDeclaration() { return nullptr; }
/// Returns this Symbol as a QtEnum.
virtual QtEnum *asQtEnum() { return nullptr; } virtual QtEnum *asQtEnum() { return nullptr; }
virtual ObjCBaseClass *asObjCBaseClass() { return nullptr; } virtual ObjCBaseClass *asObjCBaseClass() { return nullptr; }
virtual ObjCBaseProtocol *asObjCBaseProtocol() { return nullptr; } virtual ObjCBaseProtocol *asObjCBaseProtocol() { return nullptr; }
/// Returns this Symbol as an Objective-C Class declaration.
virtual ObjCClass *asObjCClass() { return nullptr; } virtual ObjCClass *asObjCClass() { return nullptr; }
/// Returns this Symbol as an Objective-C Class forward declaration.
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() { return nullptr; } virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() { return nullptr; }
/// Returns this Symbol as an Objective-C Protocol declaration.
virtual ObjCProtocol *asObjCProtocol() { return nullptr; } virtual ObjCProtocol *asObjCProtocol() { return nullptr; }
/// Returns this Symbol as an Objective-C Protocol forward declaration.
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() { return nullptr; } virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() { return nullptr; }
/// Returns this Symbol as an Objective-C method declaration.
virtual ObjCMethod *asObjCMethod() { return nullptr; } virtual ObjCMethod *asObjCMethod() { return nullptr; }
/// Returns this Symbol as an Objective-C @property declaration.
virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration() { return nullptr; } virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration() { return nullptr; }
/// Returns this Symbol's type. /// Returns this Symbol's type.
virtual FullySpecifiedType type() const = 0; virtual FullySpecifiedType type() const = 0;
/// Returns this Symbol's hash value. /// Returns this Symbol's hash value.
unsigned hashCode() const; unsigned hashCode() const { return _hashCode; }
/// Returns this Symbol's index. /// Returns this Symbol's index.
unsigned index() const; unsigned index() const { return _index; }
const Name *unqualifiedName() const; const Name *unqualifiedName() const;
bool isGenerated() const; bool isGenerated() const { return _isGenerated; }
bool isDeprecated() const; bool isDeprecated() const { return _isDeprecated; }
void setDeprecated(bool isDeprecated); void setDeprecated(bool isDeprecated) { _isDeprecated = isDeprecated; }
bool isUnavailable() const; bool isUnavailable() const { return _isUnavailable; }
void setUnavailable(bool isUnavailable); void setUnavailable(bool isUnavailable) { _isUnavailable = isUnavailable; }
/// Returns this Symbol's eclosing scope. /// Returns this Symbol's eclosing scope.
Scope *enclosingScope() const; Scope *enclosingScope() const { return _enclosingScope; }
/// Returns the eclosing namespace scope. /// Returns the eclosing namespace scope.
Namespace *enclosingNamespace() const; Namespace *enclosingNamespace() const;

View File

@ -42,15 +42,13 @@ UsingNamespaceDirective::UsingNamespaceDirective(Clone *clone, Subst *subst, Usi
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
UsingNamespaceDirective::~UsingNamespaceDirective()
{ }
FullySpecifiedType UsingNamespaceDirective::type() const FullySpecifiedType UsingNamespaceDirective::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor) void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
NamespaceAlias::NamespaceAlias(TranslationUnit *translationUnit, NamespaceAlias::NamespaceAlias(TranslationUnit *translationUnit,
int sourceLocation, const Name *name) int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), _namespaceName(nullptr) : Symbol(translationUnit, sourceLocation, name), _namespaceName(nullptr)
@ -61,15 +59,6 @@ NamespaceAlias::NamespaceAlias(Clone *clone, Subst *subst, NamespaceAlias *origi
, _namespaceName(clone->name(original->_namespaceName, subst)) , _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 FullySpecifiedType NamespaceAlias::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@ -86,15 +75,13 @@ UsingDeclaration::UsingDeclaration(Clone *clone, Subst *subst, UsingDeclaration
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
UsingDeclaration::~UsingDeclaration()
{ }
FullySpecifiedType UsingDeclaration::type() const FullySpecifiedType UsingDeclaration::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor) void CPlusPlus::UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
Declaration::Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name) Declaration::Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
, _initializer(nullptr) , _initializer(nullptr)
@ -204,41 +191,16 @@ Declaration::Declaration(Clone *clone, Subst *subst, Declaration *original)
_type = newType; _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) void Declaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
EnumeratorDeclaration::EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name) EnumeratorDeclaration::EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Declaration(translationUnit, sourceLocation, name) : Declaration(translationUnit, sourceLocation, name)
, _constantValue(nullptr) , _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) Argument::Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), : Symbol(translationUnit, sourceLocation, name),
@ -251,27 +213,10 @@ Argument::Argument(Clone *clone, Subst *subst, Argument *original)
, _type(clone->type(original->_type, subst)) , _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) void Argument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
TypenameArgument::TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name) TypenameArgument::TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
, _isClassDeclarator(false) , _isClassDeclarator(false)
@ -283,18 +228,10 @@ TypenameArgument::TypenameArgument(Clone *clone, Subst *subst, TypenameArgument
, _isClassDeclarator(original->_isClassDeclarator) , _isClassDeclarator(original->_isClassDeclarator)
{ } { }
TypenameArgument::~TypenameArgument()
{ }
void TypenameArgument::setType(const FullySpecifiedType &type)
{ _type = type; }
FullySpecifiedType TypenameArgument::type() const
{ return _type; }
void TypenameArgument::visitSymbol0(SymbolVisitor *visitor) void TypenameArgument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
Function::Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name) Function::Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Scope(translationUnit, sourceLocation, name), : Scope(translationUnit, sourceLocation, name),
_flags(0) _flags(0)
@ -307,27 +244,6 @@ Function::Function(Clone *clone, Subst *subst, Function *original)
, _flags(original->_flags) , _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 bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const
{ {
if (! other) if (! other)
@ -409,12 +325,6 @@ FullySpecifiedType Function::type() const
return ty; return ty;
} }
FullySpecifiedType Function::returnType() const
{ return _returnType; }
void Function::setReturnType(const FullySpecifiedType &returnType)
{ _returnType = returnType; }
bool Function::hasReturnType() const bool Function::hasReturnType() const
{ {
const FullySpecifiedType ty = returnType(); const FullySpecifiedType ty = returnType();
@ -431,7 +341,7 @@ int Function::argumentCount() const
// arguments with a lambda as default argument will also have more blocks. // arguments with a lambda as default argument will also have more blocks.
int argc = 0; int argc = 0;
for (int it = 0; it < memCnt; ++it) for (int it = 0; it < memCnt; ++it)
if (memberAt(it)->isArgument()) if (memberAt(it)->asArgument())
++argc; ++argc;
return argc; return argc;
} }
@ -470,66 +380,6 @@ int Function::minimumArgumentCount() const
return index; 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) void Function::visitSymbol0(SymbolVisitor *visitor)
{ {
if (visitor->visit(this)) { if (visitor->visit(this)) {
@ -569,11 +419,6 @@ bool Function::maybeValidPrototype(int actualArgumentCount) const
return true; return true;
} }
const StringLiteral *Function::exceptionSpecification()
{ return _exceptionSpecification; }
void Function::setExceptionSpecification(const StringLiteral *spec)
{ _exceptionSpecification = spec; }
Block::Block(TranslationUnit *translationUnit, int sourceLocation) Block::Block(TranslationUnit *translationUnit, int sourceLocation)
: Scope(translationUnit, sourceLocation, /*name = */ nullptr) : Scope(translationUnit, sourceLocation, /*name = */ nullptr)
@ -583,9 +428,6 @@ Block::Block(Clone *clone, Subst *subst, Block *original)
: Scope(clone, subst, original) : Scope(clone, subst, original)
{ } { }
Block::~Block()
{ }
FullySpecifiedType Block::type() const FullySpecifiedType Block::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@ -608,21 +450,9 @@ Enum::Enum(Clone *clone, Subst *subst, Enum *original)
, _isScoped(original->isScoped()) , _isScoped(original->isScoped())
{ } { }
Enum::~Enum()
{ }
FullySpecifiedType Enum::type() const FullySpecifiedType Enum::type() const
{ return FullySpecifiedType(const_cast<Enum *>(this)); } { return FullySpecifiedType(const_cast<Enum *>(this)); }
bool Enum::isScoped() const
{
return _isScoped;
}
void Enum::setScoped(bool scoped)
{
_isScoped = scoped;
}
void Enum::accept0(TypeVisitor *visitor) void Enum::accept0(TypeVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@ -652,9 +482,6 @@ Template::Template(Clone *clone, Subst *subst, Template *original)
: Scope(clone, subst, original) : Scope(clone, subst, original)
{ } { }
Template::~Template()
{ }
int Template::templateParameterCount() const int Template::templateParameterCount() const
{ {
if (declaration() != nullptr) if (declaration() != nullptr)
@ -663,17 +490,14 @@ int Template::templateParameterCount() const
return 0; return 0;
} }
Symbol *Template::templateParameterAt(int index) const
{ return memberAt(index); }
Symbol *Template::declaration() const Symbol *Template::declaration() const
{ {
if (isEmpty()) if (isEmpty())
return nullptr; return nullptr;
if (Symbol *s = memberAt(memberCount() - 1)) { if (Symbol *s = memberAt(memberCount() - 1)) {
if (s->isClass() || s->isForwardClassDeclaration() || if (s->asClass() || s->asForwardClassDeclaration() ||
s->isTemplate() || s->isFunction() || s->isDeclaration()) s->asTemplate() || s->asFunction() || s->asDeclaration())
return s; return s;
} }
@ -712,9 +536,6 @@ Namespace::Namespace(Clone *clone, Subst *subst, Namespace *original)
, _isInline(original->_isInline) , _isInline(original->_isInline)
{ } { }
Namespace::~Namespace()
{ }
void Namespace::accept0(TypeVisitor *visitor) void Namespace::accept0(TypeVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@ -749,30 +570,10 @@ BaseClass::BaseClass(Clone *clone, Subst *subst, BaseClass *original)
, _type(clone->type(original->_type, subst)) , _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) void BaseClass::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit, ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit,
int sourceLocation, const Name *name) int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
@ -782,9 +583,6 @@ ForwardClassDeclaration::ForwardClassDeclaration(Clone *clone, Subst *subst, For
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ForwardClassDeclaration::~ForwardClassDeclaration()
{ }
FullySpecifiedType ForwardClassDeclaration::type() const FullySpecifiedType ForwardClassDeclaration::type() const
{ return FullySpecifiedType(const_cast<ForwardClassDeclaration *>(this)); } { 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()); 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) void Class::accept0(TypeVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@ -880,21 +660,6 @@ QtPropertyDeclaration::QtPropertyDeclaration(Clone *clone, Subst *subst, QtPrope
, _flags(original->_flags) , _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) void QtPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@ -907,12 +672,6 @@ QtEnum::QtEnum(Clone *clone, Subst *subst, QtEnum *original)
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
QtEnum::~QtEnum()
{ }
FullySpecifiedType QtEnum::type() const
{ return FullySpecifiedType(); }
void QtEnum::visitSymbol0(SymbolVisitor *visitor) void QtEnum::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@ -925,8 +684,6 @@ ObjCBaseClass::ObjCBaseClass(Clone *clone, Subst *subst, ObjCBaseClass *original
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ObjCBaseClass::~ObjCBaseClass()
{ }
FullySpecifiedType ObjCBaseClass::type() const FullySpecifiedType ObjCBaseClass::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@ -942,9 +699,6 @@ ObjCBaseProtocol::ObjCBaseProtocol(Clone *clone, Subst *subst, ObjCBaseProtocol
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ObjCBaseProtocol::~ObjCBaseProtocol()
{ }
FullySpecifiedType ObjCBaseProtocol::type() const FullySpecifiedType ObjCBaseProtocol::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@ -970,30 +724,6 @@ ObjCClass::ObjCClass(Clone *clone, Subst *subst, ObjCClass *original)
addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol()); 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 int ObjCClass::protocolCount() const
{ return int(_protocols.size()); } { 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()); addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol());
} }
ObjCProtocol::~ObjCProtocol()
{}
int ObjCProtocol::protocolCount() const int ObjCProtocol::protocolCount() const
{ return int(_protocols.size()); } { return int(_protocols.size()); }
@ -1087,9 +814,6 @@ ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(Clone *clone, Subst *su
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ObjCForwardClassDeclaration::~ObjCForwardClassDeclaration()
{}
FullySpecifiedType ObjCForwardClassDeclaration::type() const FullySpecifiedType ObjCForwardClassDeclaration::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@ -1117,9 +841,6 @@ ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(Clone *clone, Sub
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ObjCForwardProtocolDeclaration::~ObjCForwardProtocolDeclaration()
{}
FullySpecifiedType ObjCForwardProtocolDeclaration::type() const FullySpecifiedType ObjCForwardProtocolDeclaration::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@ -1148,9 +869,6 @@ ObjCMethod::ObjCMethod(Clone *clone, Subst *subst, ObjCMethod *original)
, _flags(original->_flags) , _flags(original->_flags)
{ } { }
ObjCMethod::~ObjCMethod()
{ }
void ObjCMethod::accept0(TypeVisitor *visitor) void ObjCMethod::accept0(TypeVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@ -1165,12 +883,6 @@ bool ObjCMethod::match0(const Type *otherType, Matcher *matcher) const
FullySpecifiedType ObjCMethod::type() const FullySpecifiedType ObjCMethod::type() const
{ return FullySpecifiedType(const_cast<ObjCMethod *>(this)); } { return FullySpecifiedType(const_cast<ObjCMethod *>(this)); }
FullySpecifiedType ObjCMethod::returnType() const
{ return _returnType; }
void ObjCMethod::setReturnType(const FullySpecifiedType &returnType)
{ _returnType = returnType; }
bool ObjCMethod::hasReturnType() const bool ObjCMethod::hasReturnType() const
{ {
const FullySpecifiedType ty = returnType(); const FullySpecifiedType ty = returnType();
@ -1180,7 +892,7 @@ bool ObjCMethod::hasReturnType() const
int ObjCMethod::argumentCount() const int ObjCMethod::argumentCount() const
{ {
const int c = memberCount(); const int c = memberCount();
if (c > 0 && memberAt(c - 1)->isBlock()) if (c > 0 && memberAt(c - 1)->asBlock())
return c - 1; return c - 1;
return c; return c;
} }
@ -1196,12 +908,6 @@ bool ObjCMethod::hasArguments() const
(argumentCount() == 1 && argumentAt(0)->type()->isVoidType())); (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) void ObjCMethod::visitSymbol0(SymbolVisitor *visitor)
{ {
if (visitor->visit(this)) { if (visitor->visit(this)) {
@ -1228,39 +934,6 @@ ObjCPropertyDeclaration::ObjCPropertyDeclaration(Clone *clone, Subst *subst, Obj
, _propertyAttributes(original->_propertyAttributes) , _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) void ObjCPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ {
if (visitor->visit(this)) { if (visitor->visit(this)) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -57,7 +57,7 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
} }
FullySpecifiedType symbolType = symbol->type(); FullySpecifiedType symbolType = symbol->type();
if (symbol->isFunction() || (symbol->isDeclaration() && symbolType && if (symbol->asFunction() || (symbol->asDeclaration() && symbolType &&
symbolType->isFunctionType())) symbolType->isFunctionType()))
{ {
const Function *function = symbol->asFunction(); const Function *function = symbol->asFunction();
@ -80,9 +80,9 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
} else if (symbol->isPrivate()) { } else if (symbol->isPrivate()) {
return symbol->isStatic() ? FuncPrivateStatic : FuncPrivate; return symbol->isStatic() ? FuncPrivateStatic : FuncPrivate;
} }
} else if (symbol->enclosingScope() && symbol->enclosingScope()->isEnum()) { } else if (symbol->enclosingScope() && symbol->enclosingScope()->asEnum()) {
return Enumerator; return Enumerator;
} else if (symbol->isDeclaration() || symbol->isArgument()) { } else if (symbol->asDeclaration() || symbol->asArgument()) {
if (symbol->isPublic()) { if (symbol->isPublic()) {
return symbol->isStatic() ? VarPublicStatic : VarPublic; return symbol->isStatic() ? VarPublicStatic : VarPublic;
} else if (symbol->isProtected()) { } else if (symbol->isProtected()) {
@ -90,26 +90,26 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
} else if (symbol->isPrivate()) { } else if (symbol->isPrivate()) {
return symbol->isStatic() ? VarPrivateStatic : VarPrivate; return symbol->isStatic() ? VarPrivateStatic : VarPrivate;
} }
} else if (symbol->isEnum()) { } else if (symbol->asEnum()) {
return Utils::CodeModelIcon::Enum; return Utils::CodeModelIcon::Enum;
} else if (symbol->isForwardClassDeclaration()) { } else if (symbol->asForwardClassDeclaration()) {
return Utils::CodeModelIcon::Class; // TODO: Store class key in ForwardClassDeclaration return Utils::CodeModelIcon::Class; // TODO: Store class key in ForwardClassDeclaration
} else if (const Class *klass = symbol->asClass()) { } else if (const Class *klass = symbol->asClass()) {
return klass->isStruct() ? Struct : Utils::CodeModelIcon::Class; return klass->isStruct() ? Struct : Utils::CodeModelIcon::Class;
} else if (symbol->isObjCClass() || symbol->isObjCForwardClassDeclaration()) { } else if (symbol->asObjCClass() || symbol->asObjCForwardClassDeclaration()) {
return Utils::CodeModelIcon::Class; return Utils::CodeModelIcon::Class;
} else if (symbol->isObjCProtocol() || symbol->isObjCForwardProtocolDeclaration()) { } else if (symbol->asObjCProtocol() || symbol->asObjCForwardProtocolDeclaration()) {
return Utils::CodeModelIcon::Class; return Utils::CodeModelIcon::Class;
} else if (symbol->isObjCMethod()) { } else if (symbol->asObjCMethod()) {
return FuncPublic; return FuncPublic;
} else if (symbol->isNamespace()) { } else if (symbol->asNamespace()) {
return Utils::CodeModelIcon::Namespace; return Utils::CodeModelIcon::Namespace;
} else if (symbol->isTypenameArgument()) { } else if (symbol->asTypenameArgument()) {
return Utils::CodeModelIcon::Class; return Utils::CodeModelIcon::Class;
} else if (symbol->isQtPropertyDeclaration() || symbol->isObjCPropertyDeclaration()) { } else if (symbol->asQtPropertyDeclaration() || symbol->asObjCPropertyDeclaration()) {
return Property; return Property;
} else if (symbol->isUsingNamespaceDirective() || } else if (symbol->asUsingNamespaceDirective() ||
symbol->isUsingDeclaration()) { symbol->asUsingDeclaration()) {
// TODO: Might be nice to have a different icons for these things // TODO: Might be nice to have a different icons for these things
return Utils::CodeModelIcon::Namespace; 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()) { if (const QualifiedNameId *q = name->asQualifiedNameId()) {
addNames(q->base(), names); addNames(q->base(), names);
addNames(q->name(), names, addAllNames); 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); names->append(name);
} }
} }
@ -71,7 +71,7 @@ static void path_helper(Symbol *symbol,
path_helper(symbol->enclosingScope(), names, policy); path_helper(symbol->enclosingScope(), names, policy);
if (symbol->name()) { if (symbol->name()) {
if (symbol->isClass() || symbol->isNamespace()) { if (symbol->asClass() || symbol->asNamespace()) {
if (policy == LookupContext::HideInlineNamespaces) { if (policy == LookupContext::HideInlineNamespaces) {
auto ns = symbol->asNamespace(); auto ns = symbol->asNamespace();
if (ns && ns->isInline()) if (ns && ns->isInline())
@ -79,12 +79,12 @@ static void path_helper(Symbol *symbol,
} }
addNames(symbol->name(), names); addNames(symbol->name(), names);
} else if (symbol->isObjCClass() || symbol->isObjCBaseClass() || symbol->isObjCProtocol() } else if (symbol->asObjCClass() || symbol->asObjCBaseClass() || symbol->asObjCProtocol()
|| symbol->isObjCForwardClassDeclaration() || symbol->isObjCForwardProtocolDeclaration() || symbol->asObjCForwardClassDeclaration() || symbol->asObjCForwardProtocolDeclaration()
|| symbol->isForwardClassDeclaration()) { || symbol->asForwardClassDeclaration()) {
addNames(symbol->name(), names); addNames(symbol->name(), names);
} else if (symbol->isFunction()) { } else if (symbol->asFunction()) {
if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId()) if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId())
addNames(q->base(), names); addNames(q->base(), names);
} else if (Enum *e = symbol->asEnum()) { } else if (Enum *e = symbol->asEnum()) {
@ -316,7 +316,7 @@ QList<LookupItem> LookupContext::lookupByUsing(const Name *name,
{ {
QList<LookupItem> candidates; QList<LookupItem> candidates;
// if it is a nameId there can be a using declaration for it // 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(); const QList<Symbol *> symbols = bindingScope->symbols();
for (Symbol *s : symbols) { for (Symbol *s : symbols) {
if (Scope *scope = s->asScope()) { if (Scope *scope = s->asScope()) {
@ -409,7 +409,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} }
} }
} else if (UsingDeclaration *ud = m->asUsingDeclaration()) { } else if (UsingDeclaration *ud = m->asUsingDeclaration()) {
if (name->isNameId()) { if (name->asNameId()) {
if (const Name *usingDeclarationName = ud->name()) { if (const Name *usingDeclarationName = ud->name()) {
if (const QualifiedNameId *q = usingDeclarationName->asQualifiedNameId()) { if (const QualifiedNameId *q = usingDeclarationName->asQualifiedNameId()) {
if (q->name() && q->name()->match(name)) 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)) { } else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) {
return b->lookupType(name); return b->lookupType(name);
} else if (Class *scopeAsClass = scope->asClass()) { } else if (Class *scopeAsClass = scope->asClass()) {
if (scopeAsClass->enclosingScope()->isBlock()) { if (scopeAsClass->enclosingScope()->asBlock()) {
if (ClassOrNamespace *b = lookupType(scopeAsClass->name(), if (ClassOrNamespace *b = lookupType(scopeAsClass->name(),
scopeAsClass->enclosingScope(), scopeAsClass->enclosingScope(),
enclosingBinding, enclosingBinding,
@ -460,13 +460,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
return candidates; return candidates;
for (; scope; scope = scope->enclosingScope()) { 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); bindings()->lookupInScope(name, scope, &candidates, /*templateId = */ nullptr, /*binding=*/ nullptr);
if (! candidates.isEmpty()) { if (! candidates.isEmpty()) {
// it's a local. // it's a local.
//for qualified it can be outside of the local scope //for qualified it can be outside of the local scope
if (name->isQualifiedNameId()) if (name->asQualifiedNameId())
continue; continue;
else else
break; break;
@ -502,13 +502,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty()) { if (! candidates.isEmpty()) {
// it's an argument or a template parameter. // it's an argument or a template parameter.
//for qualified it can be outside of the local scope //for qualified it can be outside of the local scope
if (name->isQualifiedNameId()) if (name->asQualifiedNameId())
continue; continue;
else else
break; break;
} }
if (fun->name() && fun->name()->isQualifiedNameId()) { if (fun->name() && fun->name()->asQualifiedNameId()) {
if (ClassOrNamespace *binding = bindings()->lookupType(fun)) { if (ClassOrNamespace *binding = bindings()->lookupType(fun)) {
candidates = binding->find(name); candidates = binding->find(name);
@ -540,7 +540,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty()) { if (! candidates.isEmpty()) {
// it's a template parameter. // it's a template parameter.
//for qualified it can be outside of the local scope //for qualified it can be outside of the local scope
if (name->isQualifiedNameId()) if (name->asQualifiedNameId())
continue; continue;
else else
break; break;
@ -572,7 +572,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty()) if (! candidates.isEmpty())
return candidates; return candidates;
} else if (scope->isObjCClass() || scope->isObjCProtocol()) { } else if (scope->asObjCClass() || scope->asObjCProtocol()) {
if (ClassOrNamespace *binding = bindings()->lookupType(scope)) if (ClassOrNamespace *binding = bindings()->lookupType(scope))
candidates = binding->find(name); candidates = binding->find(name);
@ -740,7 +740,7 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
for (Symbol *s : symbols) { for (Symbol *s : symbols) {
if (s->isFriend()) if (s->isFriend())
continue; continue;
else if (s->isUsingNamespaceDirective()) else if (s->asUsingNamespaceDirective())
continue; continue;
@ -825,11 +825,11 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
for (Symbol *s = scope->find(id); s; s = s->next()) { for (Symbol *s = scope->find(id); s; s = s->next()) {
if (s->isFriend()) if (s->isFriend())
continue; // skip friends continue; // skip friends
else if (s->isUsingNamespaceDirective()) else if (s->asUsingNamespaceDirective())
continue; // skip using namespace directives continue; // skip using namespace directives
else if (! id->match(s->identifier())) else if (! id->match(s->identifier()))
continue; continue;
else if (s->name() && s->name()->isQualifiedNameId()) else if (s->name() && s->name()->asQualifiedNameId())
continue; // skip qualified ids. continue; // skip qualified ids.
if (Q_UNLIKELY(debug)) { 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()); FullySpecifiedType ty = DeprecatedGenTemplateInstance::instantiate(templateId, s, control());
item.setType(ty); // override the type. item.setType(ty); // override the type.
} }
@ -991,7 +991,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
} else if (! processed->contains(this)) { } else if (! processed->contains(this)) {
processed->insert(this); processed->insert(this);
if (name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) { if (name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
flush(); flush();
const QList<Symbol *> symbolList = symbols(); const QList<Symbol *> symbolList = symbols();
@ -1136,7 +1136,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
ClassOrNamespace *origin) ClassOrNamespace *origin)
{ {
Q_ASSERT(name != nullptr); 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(); const_cast<ClassOrNamespace *>(this)->flush();
@ -1255,7 +1255,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
return reference; return reference;
} }
if (!name->isTemplateNameId()) if (!name->asTemplateNameId())
_alreadyConsideredClasses.insert(referenceClass); _alreadyConsideredClasses.insert(referenceClass);
QSet<ClassOrNamespace *> knownUsings = Utils::toSet(reference->usings()); QSet<ClassOrNamespace *> knownUsings = Utils::toSet(reference->usings());
@ -1270,7 +1270,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
instantiation->_templateId = templId; instantiation->_templateId = templId;
QSet<ClassOrNamespace *> otherProcessed; QSet<ClassOrNamespace *> otherProcessed;
while (!origin->_symbols.isEmpty() && origin->_symbols[0]->isBlock()) { while (!origin->_symbols.isEmpty() && origin->_symbols[0]->asBlock()) {
if (otherProcessed.contains(origin)) if (otherProcessed.contains(origin))
break; break;
otherProcessed.insert(origin); otherProcessed.insert(origin);
@ -1634,7 +1634,7 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name, ClassOrNa
return findOrCreateType(q->base(), origin)->findOrCreateType(q->name(), origin, clazz); 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; QSet<ClassOrNamespace *> processed;
ClassOrNamespace *e = nestedType(name, &processed, origin); ClassOrNamespace *e = nestedType(name, &processed, origin);
@ -1791,7 +1791,7 @@ bool CreateBindings::visit(Class *klass)
ClassOrNamespace *previous = _currentClassOrNamespace; ClassOrNamespace *previous = _currentClassOrNamespace;
ClassOrNamespace *binding = nullptr; ClassOrNamespace *binding = nullptr;
if (klass->name() && klass->name()->isQualifiedNameId()) if (klass->name() && klass->name()->asQualifiedNameId())
binding = _currentClassOrNamespace->lookupType(klass->name()); binding = _currentClassOrNamespace->lookupType(klass->name());
if (! binding) if (! binding)
@ -1956,7 +1956,7 @@ bool CreateBindings::visit(NamespaceAlias *a)
return false; return false;
} else if (ClassOrNamespace *e = _currentClassOrNamespace->lookupType(a->namespaceName())) { } 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); _currentClassOrNamespace->addNestedType(a->name(), e);
} else if (false) { } else if (false) {
@ -2042,12 +2042,12 @@ Symbol *CreateBindings::instantiateTemplateFunction(const Name *instantiationNam
Template *specialization) const Template *specialization) const
{ {
if (!specialization || !specialization->declaration() if (!specialization || !specialization->declaration()
|| !specialization->declaration()->isFunction()) || !specialization->declaration()->asFunction())
return nullptr; return nullptr;
int argumentCountOfInstantiation = 0; int argumentCountOfInstantiation = 0;
const TemplateNameId *instantiation = nullptr; const TemplateNameId *instantiation = nullptr;
if (instantiationName->isTemplateNameId()) { if (instantiationName->asTemplateNameId()) {
instantiation = instantiationName->asTemplateNameId(); instantiation = instantiationName->asTemplateNameId();
argumentCountOfInstantiation = instantiation->templateArgumentCount(); argumentCountOfInstantiation = instantiation->templateArgumentCount();
} else { } else {

View File

@ -1045,7 +1045,7 @@ ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &origina
ClassOrNamespace *binding = nullptr; ClassOrNamespace *binding = nullptr;
if (Class *klass = ty->asClassType()) { if (Class *klass = ty->asClassType()) {
if (scope->isBlock()) if (scope->asBlock())
binding = _context.lookupType(klass->name(), scope, enclosingBinding); binding = _context.lookupType(klass->name(), scope, enclosingBinding);
if (!binding) if (!binding)
binding = _context.lookupType(klass, enclosingBinding); binding = _context.lookupType(klass, enclosingBinding);
@ -1135,7 +1135,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
instantiatedFunction = overloadTy->asFunctionType(); instantiatedFunction = overloadTy->asFunctionType();
} else if (overloadType->isTemplateType() } else if (overloadType->isTemplateType()
&& overloadType->asTemplateType()->declaration() && overloadType->asTemplateType()->declaration()
&& overloadType->asTemplateType()->declaration()->isFunction()) { && overloadType->asTemplateType()->declaration()->asFunction()) {
instantiatedFunction = 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()) if (Scope *scope = symbol->enclosingScope())
accept(scope); accept(scope);
if (! symbol->isTemplate()) { if (! symbol->asTemplate()) {
if (const Name *name = symbol->name()) { if (const Name *name = symbol->name()) {
std::swap(_symbol, symbol); std::swap(_symbol, symbol);
accept(name); accept(name);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,6 +29,7 @@
#include "clangutils.h" #include "clangutils.h"
#ifdef WITH_TESTS #ifdef WITH_TESTS
# include "test/activationsequenceprocessortest.h"
# include "test/clangbatchfileprocessor.h" # include "test/clangbatchfileprocessor.h"
# include "test/clangdtests.h" # include "test/clangdtests.h"
# include "test/clangfixittest.h" # include "test/clangfixittest.h"
@ -46,6 +47,7 @@
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectpanelfactory.h> #include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
@ -203,6 +205,7 @@ void ClangCodeModelPlugin::maybeHandleBatchFileAndExit() const
QVector<QObject *> ClangCodeModelPlugin::createTestObjects() const QVector<QObject *> ClangCodeModelPlugin::createTestObjects() const
{ {
return { return {
new Tests::ActivationSequenceProcessorTest,
new Tests::ClangdTestCompletion, new Tests::ClangdTestCompletion,
new Tests::ClangdTestExternalChanges, new Tests::ClangdTestExternalChanges,
new Tests::ClangdTestFindReferences, new Tests::ClangdTestFindReferences,
@ -215,6 +218,5 @@ QVector<QObject *> ClangCodeModelPlugin::createTestObjects() const
} }
#endif #endif
} // namespace Internal } // namespace Internal
} // namespace Clang } // 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/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
@ -22,38 +22,38 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
** **
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#define TEST_DEFINE 1 #include <QObject>
namespace Fooish
namespace ClangCodeModel::Internal::Tests {
class ActivationSequenceProcessorTest : public QObject
{ {
float flvalue = 100.f; Q_OBJECT
class Bar; private slots:
void testCouldNotProcesseRandomCharacters();
class Bar { void testCouldNotProcesseEmptyString();
public: void testDot();
Bar(); void testComma();
void testLeftParenAsFunctionCall();
volatile int member = 0; 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 } // namespace ClangCodeModel::Internal::Tests
{
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);

View File

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

View File

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

View File

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

View File

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

View File

@ -28,16 +28,18 @@
#include "clangtool.h" #include "clangtool.h"
#include "clangtoolsdiagnostic.h" #include "clangtoolsdiagnostic.h"
#include "clangtoolssettings.h" #include "clangtoolssettings.h"
#include "clangtoolsutils.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <cppeditor/clangdiagnosticconfig.h> #include <cppeditor/clangdiagnosticconfig.h>
#include <cppeditor/cppmodelmanager.h> #include <cppeditor/cppmodelmanager.h>
#include <cppeditor/cpptoolsreuse.h> #include <cppeditor/cpptoolsreuse.h>
#include <cppeditor/cpptoolstestcase.h> #include <cppeditor/cpptoolstestcase.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h> #include <projectexplorer/kitmanager.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <qtsupport/qtkitinformation.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/clangtidy_clazy.pro</file>
<file>unit-tests/clangtidy_clazy/clazy_example.cpp</file> <file>unit-tests/clangtidy_clazy/clazy_example.cpp</file>
<file>unit-tests/clangtidy_clazy/tidy_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> </qresource>
</RCC> </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 // any symbol which does not contain :: in the name
//! \todo collect statistics and reorder to optimize //! \todo collect statistics and reorder to optimize
if (symbol->isForwardClassDeclaration() if (symbol->asForwardClassDeclaration()
|| symbol->isExtern() || symbol->isExtern()
|| symbol->isFriend() || symbol->isFriend()
|| symbol->isGenerated() || symbol->isGenerated()
|| symbol->isUsingNamespaceDirective() || symbol->asUsingNamespaceDirective()
|| symbol->isUsingDeclaration() || symbol->asUsingDeclaration()
) )
return; return;
const CPlusPlus::Name *symbolName = symbol->name(); const CPlusPlus::Name *symbolName = symbol->name();
if (symbolName && symbolName->isQualifiedNameId()) if (symbolName && symbolName->asQualifiedNameId())
return; return;
QString name = g_overview.prettyName(symbolName).trimmed(); QString name = g_overview.prettyName(symbolName).trimmed();
@ -139,7 +139,7 @@ void ParserTreeItemPrivate::mergeSymbol(const CPlusPlus::Symbol *symbol)
childItem->d->m_symbolLocations.insert(location); childItem->d->m_symbolLocations.insert(location);
// prevent showing a content of the functions // prevent showing a content of the functions
if (!symbol->isFunction()) { if (!symbol->asFunction()) {
if (const CPlusPlus::Scope *scope = symbol->asScope()) { if (const CPlusPlus::Scope *scope = symbol->asScope()) {
CPlusPlus::Scope::iterator cur = scope->memberBegin(); CPlusPlus::Scope::iterator cur = scope->memberBegin();
CPlusPlus::Scope::iterator last = scope->memberEnd(); 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 item is empty and has not to be added
if (!symbol->isNamespace() || childItem->childCount()) if (!symbol->asNamespace() || childItem->childCount())
m_symbolInformations.insert(information, childItem); m_symbolInformations.insert(information, childItem);
} }

View File

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

View File

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

View File

@ -109,7 +109,8 @@ static std::vector<std::unique_ptr<CMakeTool>> autoDetectCMakeTools()
for (const FilePath &command : qAsConst(suspects)) { for (const FilePath &command : qAsConst(suspects)) {
auto item = std::make_unique<CMakeTool>(CMakeTool::AutoDetection, CMakeTool::createId()); auto item = std::make_unique<CMakeTool>(CMakeTool::AutoDetection, CMakeTool::createId());
item->setFilePath(command); 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)); found.emplace_back(std::move(item));
} }

View File

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

View File

@ -2533,7 +2533,8 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document)
if (absoluteFilePath.isEmpty()) if (absoluteFilePath.isEmpty())
return false; 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 // close existing editors for the new file name
IDocument *otherDocument = DocumentModel::documentForFilePath(absoluteFilePath); IDocument *otherDocument = DocumentModel::documentForFilePath(absoluteFilePath);
if (otherDocument) if (otherDocument)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -413,11 +413,11 @@ static void find_helper(QFutureInterface<CPlusPlus::Usage> &future,
symbol->fileNameLength()); symbol->fileNameLength());
Utils::FilePaths files{sourceFile}; Utils::FilePaths files{sourceFile};
if (symbol->isClass() if (symbol->asClass()
|| symbol->isForwardClassDeclaration() || symbol->asForwardClassDeclaration()
|| (symbol->enclosingScope() || (symbol->enclosingScope()
&& !symbol->isStatic() && !symbol->isStatic()
&& symbol->enclosingScope()->isNamespace())) { && symbol->enclosingScope()->asNamespace())) {
const CPlusPlus::Snapshot snapshotFromContext = context.snapshot(); const CPlusPlus::Snapshot snapshotFromContext = context.snapshot();
for (auto i = snapshotFromContext.begin(), ei = snapshotFromContext.end(); i != ei; ++i) { for (auto i = snapshotFromContext.begin(), ei = snapshotFromContext.end(); i != ei; ++i) {
if (i.key() == sourceFile) if (i.key() == sourceFile)
@ -479,7 +479,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
parameters.symbolFileName = QByteArray(symbol->fileName()); parameters.symbolFileName = QByteArray(symbol->fileName());
parameters.categorize = codeModelSettings()->categorizeFindReferences(); parameters.categorize = codeModelSettings()->categorizeFindReferences();
if (symbol->isClass() || symbol->isForwardClassDeclaration()) { if (symbol->asClass() || symbol->asForwardClassDeclaration()) {
CPlusPlus::Overview overview; CPlusPlus::Overview overview;
parameters.prettySymbolName = parameters.prettySymbolName =
overview.prettyName(CPlusPlus::LookupContext::path(symbol).constLast()); 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) if (!m_document || m_snapshot.isEmpty() || !m_function || !m_scope)
return false; return false;
if (m_scope->isClass() && m_function->isPureVirtual()) { if (m_scope->asClass() && m_function->isPureVirtual()) {
m_staticClassOfFunctionCallExpression = m_scope->asClass(); m_staticClassOfFunctionCallExpression = m_scope->asClass();
return true; return true;
} }
if (!m_baseExpressionAST || !m_expressionDocument if (!m_baseExpressionAST || !m_expressionDocument
|| m_scope->isClass() || m_scope->isFunction()) { || m_scope->asClass() || m_scope->asFunction()) {
return false; return false;
} }
@ -191,7 +191,7 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con
const QList<Symbol *> symbols = binding->symbols(); const QList<Symbol *> symbols = binding->symbols();
if (!symbols.isEmpty()) { if (!symbols.isEmpty()) {
Symbol * const first = symbols.first(); Symbol * const first = symbols.first();
if (first->isForwardClassDeclaration()) if (first->asForwardClassDeclaration())
result = m_finder->findMatchingClassDeclaration(first, m_snapshot); result = m_finder->findMatchingClassDeclaration(first, m_snapshot);
} }
} }
@ -253,7 +253,7 @@ static bool isForwardClassDeclaration(Type *type)
return true; return true;
} else if (Template *templ = type->asTemplateType()) { } else if (Template *templ = type->asTemplateType()) {
if (Symbol *declaration = templ->declaration()) { if (Symbol *declaration = templ->declaration()) {
if (declaration->isForwardClassDeclaration()) if (declaration->asForwardClassDeclaration())
return true; return true;
} }
} }
@ -384,7 +384,7 @@ Link attemptDeclDef(const QTextCursor &cursor, Snapshot snapshot,
Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *symbolFinder) Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *symbolFinder)
{ {
if (symbol->isFunction()) if (symbol->asFunction())
return nullptr; // symbol is a function definition. return nullptr; // symbol is a function definition.
if (!symbol->type()->isFunctionType()) if (!symbol->type()->isFunctionType())
@ -706,7 +706,7 @@ void FollowSymbolUnderCursor::findLink(
for (const LookupItem &r : resolvedSymbols) { for (const LookupItem &r : resolvedSymbols) {
if (Symbol *d = r.declaration()) { if (Symbol *d = r.declaration()) {
if (d->isDeclaration() || d->isFunction()) { if (d->asDeclaration() || d->asFunction()) {
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength()); const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
if (data.filePath().toString() == fileName) { if (data.filePath().toString() == fileName) {
if (line == d->line() && positionInBlock >= d->column()) { if (line == d->line() && positionInBlock >= d->column()) {
@ -715,7 +715,7 @@ void FollowSymbolUnderCursor::findLink(
break; break;
} }
} }
} else if (d->isUsingDeclaration()) { } else if (d->asUsingDeclaration()) {
int tokenBeginLineNumber = 0; int tokenBeginLineNumber = 0;
int tokenBeginColumnNumber = 0; int tokenBeginColumnNumber = 0;
Utils::Text::convertPosition(document, beginOfToken, &tokenBeginLineNumber, Utils::Text::convertPosition(document, beginOfToken, &tokenBeginLineNumber,
@ -768,11 +768,11 @@ void FollowSymbolUnderCursor::findLink(
if (def == lastVisibleSymbol) if (def == lastVisibleSymbol)
def = nullptr; // jump to declaration then. def = nullptr; // jump to declaration then.
if (symbol->isForwardClassDeclaration()) { if (symbol->asForwardClassDeclaration()) {
def = symbolFinder->findMatchingClassDeclaration(symbol, snapshot); def = symbolFinder->findMatchingClassDeclaration(symbol, snapshot);
} else if (Template *templ = symbol->asTemplate()) { } else if (Template *templ = symbol->asTemplate()) {
if (Symbol *declaration = templ->declaration()) { if (Symbol *declaration = templ->declaration()) {
if (declaration->isForwardClassDeclaration()) if (declaration->asForwardClassDeclaration())
def = symbolFinder->findMatchingClassDeclaration(declaration, snapshot); def = symbolFinder->findMatchingClassDeclaration(declaration, snapshot);
} }
} }
@ -828,7 +828,7 @@ void FollowSymbolUnderCursor::switchDeclDef(
} else if (SimpleDeclarationAST *simpleDeclaration = ast->asSimpleDeclaration()) { } else if (SimpleDeclarationAST *simpleDeclaration = ast->asSimpleDeclaration()) {
if (List<Symbol *> *symbols = simpleDeclaration->symbols) { if (List<Symbol *> *symbols = simpleDeclaration->symbols) {
if (Symbol *symbol = symbols->value) { if (Symbol *symbol = symbols->value) {
if (symbol->isDeclaration()) { if (symbol->asDeclaration()) {
declarationSymbol = symbol; declarationSymbol = symbol;
if (symbol->type()->isFunctionType()) { if (symbol->type()->isFunctionType()) {
functionDeclarationSymbol = symbol; functionDeclarationSymbol = symbol;

View File

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

View File

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

View File

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

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