forked from qt-creator/qt-creator
QmlDesigner: move RewriterError to an extra file
Change-Id: I453b30f45e0bc447b05694eadda60d4613e88062 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
#include <variantproperty.h>
|
||||
#include <metainfo.h>
|
||||
#include <abstractview.h>
|
||||
#include <rewriterview.h>
|
||||
#include <invalididexception.h>
|
||||
#include <rewritingexception.h>
|
||||
#include <modelnodecontextmenu.h>
|
||||
|
@@ -39,7 +39,6 @@
|
||||
#include <bindingproperty.h>
|
||||
|
||||
#include <nodeabstractproperty.h>
|
||||
#include <rewriterview.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
@@ -16,6 +16,7 @@ include (../../../../share/qtcreator/qml/qmlpuppet/types/types.pri)
|
||||
|
||||
SOURCES += $$PWD/model/abstractview.cpp \
|
||||
$$PWD/model/rewriterview.cpp \
|
||||
$$PWD/model/rewritererror.cpp \
|
||||
$$PWD/metainfo/metainfo.cpp \
|
||||
$$PWD/metainfo/metainforeader.cpp \
|
||||
$$PWD/metainfo/nodemetainfo.cpp \
|
||||
@@ -83,6 +84,7 @@ HEADERS += $$PWD/include/qmldesignercorelib_global.h \
|
||||
$$PWD/include/abstractview.h \
|
||||
$$PWD/include/nodeinstanceview.h \
|
||||
$$PWD/include/rewriterview.h \
|
||||
$$PWD/include/rewritererror.h \
|
||||
$$PWD/include/metainfo.h \
|
||||
$$PWD/include/metainforeader.h \
|
||||
$$PWD/include/nodemetainfo.h \
|
||||
|
78
src/plugins/qmldesigner/designercore/include/rewritererror.h
Normal file
78
src/plugins/qmldesigner/designercore/include/rewritererror.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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 "exception.h"
|
||||
#include <QUrl>
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace QmlJS {
|
||||
class DiagnosticMessage;
|
||||
}
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class RewriterError {
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlDesigner::RewriterError)
|
||||
public:
|
||||
enum Type {
|
||||
NoError = 0,
|
||||
InternalError = 1,
|
||||
ParseError = 2
|
||||
};
|
||||
|
||||
public:
|
||||
RewriterError();
|
||||
RewriterError(const QmlJS::DiagnosticMessage &qmlError, const QUrl &document);
|
||||
RewriterError(const QString &shortDescription);
|
||||
RewriterError(Exception *exception);
|
||||
|
||||
Type type() const
|
||||
{ return m_type; }
|
||||
|
||||
int line() const
|
||||
{ return m_line; }
|
||||
|
||||
int column() const
|
||||
{ return m_column; }
|
||||
|
||||
QString description() const
|
||||
{ return m_description; }
|
||||
|
||||
QUrl url() const
|
||||
{ return m_url; }
|
||||
|
||||
QString toString() const;
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
int m_line;
|
||||
int m_column;
|
||||
QString m_description;
|
||||
QUrl m_url;
|
||||
};
|
||||
|
||||
} //QmlDesigner
|
@@ -28,13 +28,12 @@
|
||||
#include "qmldesignercorelib_global.h"
|
||||
#include "exception.h"
|
||||
#include "abstractview.h"
|
||||
#include "rewritererror.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QUrl>
|
||||
|
||||
namespace QmlJS {
|
||||
class DiagnosticMessage;
|
||||
class LookupContext;
|
||||
class Document;
|
||||
class ScopeChain;
|
||||
}
|
||||
@@ -51,45 +50,6 @@ class ModelNodePositionStorage;
|
||||
|
||||
} //Internal
|
||||
|
||||
class RewriterError {
|
||||
public:
|
||||
enum Type {
|
||||
NoError = 0,
|
||||
InternalError = 1,
|
||||
ParseError = 2
|
||||
};
|
||||
|
||||
public:
|
||||
RewriterError();
|
||||
RewriterError(const QmlJS::DiagnosticMessage &qmlError, const QUrl &document);
|
||||
RewriterError(const QString &shortDescription);
|
||||
RewriterError(Exception *exception);
|
||||
|
||||
Type type() const
|
||||
{ return m_type; }
|
||||
|
||||
int line() const
|
||||
{ return m_line; }
|
||||
|
||||
int column() const
|
||||
{ return m_column; }
|
||||
|
||||
QString description() const
|
||||
{ return m_description; }
|
||||
|
||||
QUrl url() const
|
||||
{ return m_url; }
|
||||
|
||||
QString toString() const;
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
int m_line;
|
||||
int m_column;
|
||||
QString m_description;
|
||||
QUrl m_url;
|
||||
};
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT RewriterView : public AbstractView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
102
src/plugins/qmldesigner/designercore/model/rewritererror.cpp
Normal file
102
src/plugins/qmldesigner/designercore/model/rewritererror.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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 <rewritererror.h>
|
||||
|
||||
#include <qmljs/parser/qmljsengine_p.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
RewriterError::RewriterError():
|
||||
m_type(NoError),
|
||||
m_line(-1),
|
||||
m_column(-1)
|
||||
{
|
||||
}
|
||||
|
||||
RewriterError::RewriterError(Exception *exception):
|
||||
m_type(InternalError),
|
||||
m_line(exception->line()),
|
||||
m_column(-1),
|
||||
m_description(exception->description()),
|
||||
m_url(exception->file())
|
||||
{
|
||||
}
|
||||
|
||||
RewriterError::RewriterError(const QmlJS::DiagnosticMessage &qmlError, const QUrl &document):
|
||||
m_type(ParseError),
|
||||
m_line(qmlError.loc.startLine),
|
||||
m_column(qmlError.loc.startColumn),
|
||||
m_description(qmlError.message),
|
||||
m_url(document)
|
||||
{
|
||||
}
|
||||
|
||||
RewriterError::RewriterError(const QString &shortDescription) :
|
||||
m_type(ParseError),
|
||||
m_line(1),
|
||||
m_column(0),
|
||||
m_description(shortDescription),
|
||||
m_url()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString RewriterError::toString() const
|
||||
{
|
||||
QString str;
|
||||
|
||||
if (m_type == ParseError)
|
||||
str += tr("Error parsing");
|
||||
else if (m_type == InternalError)
|
||||
str += tr("Internal error");
|
||||
|
||||
if (url().isValid()) {
|
||||
if (!str.isEmpty())
|
||||
str += QLatin1Char(' ');
|
||||
|
||||
str += QString("\"%1\"").arg(url().toString());
|
||||
}
|
||||
|
||||
if (line() != -1) {
|
||||
if (!str.isEmpty())
|
||||
str += QLatin1Char(' ');
|
||||
str += tr("line %1").arg(line());
|
||||
}
|
||||
|
||||
if (column() != -1) {
|
||||
if (!str.isEmpty())
|
||||
str += QLatin1Char(' ');
|
||||
|
||||
str += tr("column %1").arg(column());
|
||||
}
|
||||
|
||||
if (!str.isEmpty())
|
||||
QStringLiteral(": ");
|
||||
str += description();
|
||||
|
||||
return str;
|
||||
}
|
||||
} //QmlDesigner
|
@@ -45,77 +45,6 @@ using namespace QmlDesigner::Internal;
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
RewriterError::RewriterError():
|
||||
m_type(NoError),
|
||||
m_line(-1),
|
||||
m_column(-1)
|
||||
{
|
||||
}
|
||||
|
||||
RewriterError::RewriterError(Exception *exception):
|
||||
m_type(InternalError),
|
||||
m_line(exception->line()),
|
||||
m_column(-1),
|
||||
m_description(exception->description()),
|
||||
m_url(exception->file())
|
||||
{
|
||||
}
|
||||
|
||||
RewriterError::RewriterError(const QmlJS::DiagnosticMessage &qmlError, const QUrl &document):
|
||||
m_type(ParseError),
|
||||
m_line(qmlError.loc.startLine),
|
||||
m_column(qmlError.loc.startColumn),
|
||||
m_description(qmlError.message),
|
||||
m_url(document)
|
||||
{
|
||||
}
|
||||
|
||||
RewriterError::RewriterError(const QString &shortDescription) :
|
||||
m_type(ParseError),
|
||||
m_line(1),
|
||||
m_column(0),
|
||||
m_description(shortDescription),
|
||||
m_url()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString RewriterError::toString() const
|
||||
{
|
||||
QString str;
|
||||
|
||||
if (m_type == ParseError)
|
||||
str += RewriterView::tr("Error parsing");
|
||||
else if (m_type == InternalError)
|
||||
str += RewriterView::tr("Internal error");
|
||||
|
||||
if (url().isValid()) {
|
||||
if (!str.isEmpty())
|
||||
str += QLatin1Char(' ');
|
||||
|
||||
str += RewriterView::tr("\"%1\"").arg(url().toString());
|
||||
}
|
||||
|
||||
if (line() != -1) {
|
||||
if (!str.isEmpty())
|
||||
str += QLatin1Char(' ');
|
||||
str += RewriterView::tr("line %1").arg(line());
|
||||
}
|
||||
|
||||
if (column() != -1) {
|
||||
if (!str.isEmpty())
|
||||
str += QLatin1Char(' ');
|
||||
|
||||
str += RewriterView::tr("column %1").arg(column());
|
||||
}
|
||||
|
||||
if (!str.isEmpty())
|
||||
QStringLiteral(": ");
|
||||
str += description();
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
RewriterView::RewriterView(DifferenceHandling differenceHandling, QObject *parent):
|
||||
AbstractView(parent),
|
||||
m_differenceHandling(differenceHandling),
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "texttomodelmerger.h"
|
||||
|
||||
#include "rewritererror.h"
|
||||
#include "modelnodepositionstorage.h"
|
||||
#include "abstractproperty.h"
|
||||
#include "bindingproperty.h"
|
||||
|
@@ -24,12 +24,12 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "designmodewidget.h"
|
||||
|
||||
#include "styledoutputpaneplaceholder.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
#include "crumblebar.h"
|
||||
#include "documentwarningwidget.h"
|
||||
|
||||
#include <rewriterview.h>
|
||||
#include <nodeinstanceview.h>
|
||||
#include <itemlibrarywidget.h>
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utils/faketooltip.h>
|
||||
#include <rewriterview.h>
|
||||
#include <rewritererror.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
|
Reference in New Issue
Block a user