Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tobias Hunger
qt-creator
Commits
7528c6d6
Commit
7528c6d6
authored
Oct 27, 2010
by
Leandro Melo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Snippets: Feature enhancement start...
Provide an interface so users can create/edit/remove snippets.
parent
27bab4e8
Changes
44
Hide whitespace changes
Inline
Side-by-side
Showing
44 changed files
with
2569 additions
and
388 deletions
+2569
-388
share/qtcreator/snippets/cpp.xml
share/qtcreator/snippets/cpp.xml
+0
-78
share/qtcreator/snippets/qml.xml
share/qtcreator/snippets/qml.xml
+0
-85
share/qtcreator/static.pro
share/qtcreator/static.pro
+0
-1
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+20
-16
src/plugins/cppeditor/cppeditor.h
src/plugins/cppeditor/cppeditor.h
+3
-0
src/plugins/cppeditor/cppeditor.pro
src/plugins/cppeditor/cppeditor.pro
+6
-2
src/plugins/cppeditor/cppplugin.cpp
src/plugins/cppeditor/cppplugin.cpp
+2
-0
src/plugins/cppeditor/cppsnippeteditordecorator.cpp
src/plugins/cppeditor/cppsnippeteditordecorator.cpp
+64
-0
src/plugins/cppeditor/cppsnippeteditordecorator.h
src/plugins/cppeditor/cppsnippeteditordecorator.h
+52
-0
src/plugins/cpptools/cppcodecompletion.cpp
src/plugins/cpptools/cppcodecompletion.cpp
+6
-5
src/plugins/cpptools/cppcodecompletion.h
src/plugins/cpptools/cppcodecompletion.h
+2
-2
src/plugins/qmljseditor/qmljscodecompletion.cpp
src/plugins/qmljseditor/qmljscodecompletion.cpp
+2
-2
src/plugins/qmljseditor/qmljscodecompletion.h
src/plugins/qmljseditor/qmljscodecompletion.h
+2
-2
src/plugins/qmljseditor/qmljseditor.cpp
src/plugins/qmljseditor/qmljseditor.cpp
+25
-21
src/plugins/qmljseditor/qmljseditor.h
src/plugins/qmljseditor/qmljseditor.h
+2
-0
src/plugins/qmljseditor/qmljseditor.pro
src/plugins/qmljseditor/qmljseditor.pro
+4
-2
src/plugins/qmljseditor/qmljseditorplugin.cpp
src/plugins/qmljseditor/qmljseditorplugin.cpp
+2
-0
src/plugins/qmljseditor/qmljssnippeteditordecorator.cpp
src/plugins/qmljseditor/qmljssnippeteditordecorator.cpp
+62
-0
src/plugins/qmljseditor/qmljssnippeteditordecorator.h
src/plugins/qmljseditor/qmljssnippeteditordecorator.h
+52
-0
src/plugins/texteditor/basetexteditor.cpp
src/plugins/texteditor/basetexteditor.cpp
+6
-5
src/plugins/texteditor/snippets/isnippeteditordecorator.cpp
src/plugins/texteditor/snippets/isnippeteditordecorator.cpp
+38
-0
src/plugins/texteditor/snippets/isnippeteditordecorator.h
src/plugins/texteditor/snippets/isnippeteditordecorator.h
+58
-0
src/plugins/texteditor/snippets/reuse.h
src/plugins/texteditor/snippets/reuse.h
+85
-0
src/plugins/texteditor/snippets/snippet.cpp
src/plugins/texteditor/snippets/snippet.cpp
+148
-0
src/plugins/texteditor/snippets/snippet.h
src/plugins/texteditor/snippets/snippet.h
+98
-0
src/plugins/texteditor/snippets/snippeteditor.cpp
src/plugins/texteditor/snippets/snippeteditor.cpp
+92
-0
src/plugins/texteditor/snippets/snippeteditor.h
src/plugins/texteditor/snippets/snippeteditor.h
+92
-0
src/plugins/texteditor/snippets/snippetprovider.cpp
src/plugins/texteditor/snippets/snippetprovider.cpp
+62
-0
src/plugins/texteditor/snippets/snippetprovider.h
src/plugins/texteditor/snippets/snippetprovider.h
+15
-16
src/plugins/texteditor/snippets/snippets.xml
src/plugins/texteditor/snippets/snippets.xml
+120
-0
src/plugins/texteditor/snippets/snippetscollection.cpp
src/plugins/texteditor/snippets/snippetscollection.cpp
+212
-0
src/plugins/texteditor/snippets/snippetscollection.h
src/plugins/texteditor/snippets/snippetscollection.h
+97
-0
src/plugins/texteditor/snippets/snippetsmanager.cpp
src/plugins/texteditor/snippets/snippetsmanager.cpp
+192
-0
src/plugins/texteditor/snippets/snippetsmanager.h
src/plugins/texteditor/snippets/snippetsmanager.h
+86
-0
src/plugins/texteditor/snippets/snippetssettings.cpp
src/plugins/texteditor/snippets/snippetssettings.cpp
+78
-0
src/plugins/texteditor/snippets/snippetssettings.h
src/plugins/texteditor/snippets/snippetssettings.h
+66
-0
src/plugins/texteditor/snippets/snippetssettingspage.cpp
src/plugins/texteditor/snippets/snippetssettingspage.cpp
+512
-0
src/plugins/texteditor/snippets/snippetssettingspage.h
src/plugins/texteditor/snippets/snippetssettingspage.h
+61
-0
src/plugins/texteditor/snippets/snippetssettingspage.ui
src/plugins/texteditor/snippets/snippetssettingspage.ui
+109
-0
src/plugins/texteditor/snippetsparser.cpp
src/plugins/texteditor/snippetsparser.cpp
+0
-144
src/plugins/texteditor/texteditor.pro
src/plugins/texteditor/texteditor.pro
+25
-7
src/plugins/texteditor/texteditor.qrc
src/plugins/texteditor/texteditor.qrc
+1
-0
src/plugins/texteditor/texteditorconstants.h
src/plugins/texteditor/texteditorconstants.h
+3
-0
src/plugins/texteditor/texteditorsettings.cpp
src/plugins/texteditor/texteditorsettings.cpp
+7
-0
No files found.
share/qtcreator/snippets/cpp.xml
deleted
100644 → 0
View file @
27bab4e8
<?xml version="1.0" encoding="utf-8"?>
<snippets>
<snippet>
class
<tab>
name
</tab>
{
public:
<tab>
name
</tab>
() {}
};
</snippet>
<snippet
description=
"derived from QObject"
>
class
<tab>
name
</tab>
: public QObject
{
Q_OBJECT
public:
<tab>
name
</tab>
() {}
virtual ~
<tab>
name
</tab>
() {}
};
</snippet>
<snippet
description=
"derived from QWidget"
>
class
<tab>
name
</tab>
: public QWidget
{
Q_OBJECT
public:
<tab>
name
</tab>
() {}
virtual ~
<tab>
name
</tab>
() {}
};
</snippet>
<snippet>
do {
} while (
<tab>
condition
</tab>
);
</snippet>
<snippet>
else {
}
</snippet>
<snippet
description=
"with if"
>
else if (
<tab>
condition
</tab>
) {
}
</snippet>
<snippet>
for (int
<tab>
var
</tab>
= 0;
<tab>
var
</tab>
<
<tab>
total
</tab>
; ++
<tab>
var
</tab>
) {
}
</snippet>
<snippet>
foreach (
<tab>
var
</tab>
,
<tab>
container
</tab>
) {
}
</snippet>
<snippet>
if (
<tab>
condition
</tab>
) {
}
</snippet>
<snippet
description=
"and else"
>
if (
<tab>
condition
</tab>
) {
} else {
}
</snippet>
<snippet>
namespace
<tab>
name
</tab>
{
}
</snippet>
<snippet>
template
<
typename
<tab>
T
</tab>
>
class
<tab>
name
</tab>
{
public:
<tab>
name
</tab>
() {}
};
</snippet>
<snippet>
try {
} catch (...) {
}
</snippet>
<snippet>
using namespace
<tab>
name
</tab>
;
</snippet>
<snippet>
while (
<tab>
condition
</tab>
) {
}
</snippet>
</snippets>
share/qtcreator/snippets/qml.xml
deleted
100644 → 0
View file @
27bab4e8
<?xml version="1.0" encoding="utf-8"?>
<snippets>
<snippet>
property
<tab>
type
</tab>
<tab>
name
</tab>
:
<tab>
value
</tab>
</snippet>
<snippet>
Item {
id:
<tab>
name
</tab>
}
</snippet>
<snippet>
BorderImage {
id:
<tab>
name
</tab>
source: "
<tab>
file
</tab>
"
width:
<tab>
100
</tab>
; height:
<tab>
100
</tab>
border.left:
<tab>
5
</tab>
; border.top:
<tab>
5
</tab>
border.right:
<tab>
5
</tab>
; border.bottom:
<tab>
5
</tab>
}
</snippet>
<snippet>
Image {
id:
<tab>
name
</tab>
source: "
<tab>
file
</tab>
"
}
</snippet>
<snippet>
Text {
id:
<tab>
name
</tab>
text: "
<tab>
text
</tab>
"
}
</snippet>
<snippet>
states: [
State {
name: "
<tab>
name
</tab>
"
PropertyChanges {
target:
<tab>
name
</tab>
<tab/>
}
}
]
</snippet>
<snippet>
State {
name: "
<tab>
name
</tab>
"
PropertyChanges {
target:
<tab>
name
</tab>
<tab/>
}
}
</snippet>
<snippet>
transitions: [
Transition {
from: "
<tab>
name
</tab>
"
to: "
<tab>
name
</tab>
"
<tab/>
}
]
</snippet>
<snippet>
Transition {
from: "
<tab>
name
</tab>
"
to: "
<tab>
name
</tab>
"
<tab/>
}
</snippet>
<snippet>
PropertyChanges {
target:
<tab>
name
</tab>
<tab/>
}
</snippet>
<snippet
description=
"with targets"
>
NumberAnimation { targets: [
<tab>
name
</tab>
]; properties: "
<tab>
name
</tab>
"; duration:
<tab>
200
</tab>
}
</snippet>
<snippet
description=
"with target"
>
NumberAnimation { target:
<tab>
name
</tab>
; property: "
<tab>
name
</tab>
"; to:
<tab>
value
</tab>
; duration:
<tab>
200
</tab>
}
</snippet>
<snippet
description=
"with targets"
>
PropertyAction { targets: [
<tab>
name
</tab>
]; properties: "
<tab>
name
</tab>
" }
</snippet>
<snippet
description=
"with target"
>
PropertyAction { target:
<tab>
name
</tab>
; property: "
<tab>
name
</tab>
"; value:
<tab>
value
</tab>
}
</snippet>
<snippet>
PauseAnimation { duration:
<tab>
200
</tab>
}
</snippet>
<snippet>
ColorAnimation { from:
<tab>
"white"
</tab>
; to:
<tab>
"black"
</tab>
; duration:
<tab>
200
</tab>
}
</snippet>
</snippets>
share/qtcreator/static.pro
View file @
7528c6d6
...
...
@@ -25,7 +25,6 @@ isEmpty(vcproj) {
DATA_DIRS
=
\
examplebrowser
\
snippets
\
templates
\
designer
\
schemes
\
...
...
src/plugins/cppeditor/cppeditor.cpp
View file @
7528c6d6
...
...
@@ -1735,22 +1735,7 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
if
(
!
highlighter
)
return
;
static
QVector
<
QString
>
categories
;
if
(
categories
.
isEmpty
())
{
categories
<<
QLatin1String
(
TextEditor
::
Constants
::
C_NUMBER
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_STRING
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_TYPE
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_KEYWORD
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_OPERATOR
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_PREPROCESSOR
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_LABEL
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_COMMENT
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_DOXYGEN_COMMENT
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_DOXYGEN_TAG
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_VISUAL_WHITESPACE
);
}
const
QVector
<
QTextCharFormat
>
formats
=
fs
.
toTextCharFormats
(
categories
);
const
QVector
<
QTextCharFormat
>
formats
=
fs
.
toTextCharFormats
(
highlighterFormatCategories
());
highlighter
->
setFormats
(
formats
.
constBegin
(),
formats
.
constEnd
());
m_occurrencesFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_OCCURRENCES
));
...
...
@@ -2175,4 +2160,23 @@ QModelIndex CPPEditor::indexForPosition(int line, int column, const QModelIndex
return
lastIndex
;
}
QVector
<
QString
>
CPPEditor
::
highlighterFormatCategories
()
{
static
QVector
<
QString
>
categories
;
if
(
categories
.
isEmpty
())
{
categories
<<
QLatin1String
(
TextEditor
::
Constants
::
C_NUMBER
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_STRING
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_TYPE
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_KEYWORD
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_OPERATOR
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_PREPROCESSOR
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_LABEL
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_COMMENT
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_DOXYGEN_COMMENT
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_DOXYGEN_TAG
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_VISUAL_WHITESPACE
);
}
return
categories
;
}
#include "cppeditor.moc"
src/plugins/cppeditor/cppeditor.h
View file @
7528c6d6
...
...
@@ -43,6 +43,7 @@
#include <QtCore/QWaitCondition>
#include <QtCore/QFutureWatcher>
#include <QtCore/QModelIndex>
#include <QtCore/QVector>
QT_BEGIN_NAMESPACE
class
QComboBox
;
...
...
@@ -184,6 +185,8 @@ public:
static
Link
linkToSymbol
(
CPlusPlus
::
Symbol
*
symbol
);
static
QVector
<
QString
>
highlighterFormatCategories
();
Q_SIGNALS:
void
outlineModelIndexChanged
(
const
QModelIndex
&
index
);
...
...
src/plugins/cppeditor/cppeditor.pro
View file @
7528c6d6
...
...
@@ -25,7 +25,9 @@ HEADERS += cppplugin.h \
cppquickfixcollector
.
h
\
cppqtstyleindenter
.
h
\
cppautocompleter
.
h
\
cppcompleteswitch
.
h
cppcompleteswitch
.
h
\
cppsnippeteditordecorator
.
h
SOURCES
+=
cppplugin
.
cpp
\
cppeditor
.
cpp
\
cpphighlighter
.
cpp
\
...
...
@@ -44,6 +46,8 @@ SOURCES += cppplugin.cpp \
cppquickfixcollector
.
cpp
\
cppqtstyleindenter
.
cpp
\
cppautocompleter
.
cpp
\
cppcompleteswitch
.
cpp
cppcompleteswitch
.
cpp
\
cppsnippeteditordecorator
.
cpp
RESOURCES
+=
cppeditor
.
qrc
OTHER_FILES
+=
CppEditor
.
mimetypes
.
xml
src/plugins/cppeditor/cppplugin.cpp
View file @
7528c6d6
...
...
@@ -38,6 +38,7 @@
#include "cppoutline.h"
#include "cppquickfixcollector.h"
#include "cpptypehierarchy.h"
#include "cppsnippeteditordecorator.h"
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
...
...
@@ -211,6 +212,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
addAutoReleasedObject
(
new
CppHoverHandler
);
addAutoReleasedObject
(
new
CppOutlineWidgetFactory
);
addAutoReleasedObject
(
new
CppTypeHierarchyFactory
);
addAutoReleasedObject
(
new
CppSnippetEditorDecorator
);
m_quickFixCollector
=
new
CppQuickFixCollector
;
addAutoReleasedObject
(
m_quickFixCollector
);
...
...
src/plugins/cppeditor/cppsnippeteditordecorator.cpp
0 → 100644
View file @
7528c6d6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "cppsnippeteditordecorator.h"
#include "cpphighlighter.h"
#include "cppeditor.h"
#include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/snippets/snippeteditor.h>
using
namespace
CppEditor
;
using
namespace
Internal
;
CppSnippetEditorDecorator
::
CppSnippetEditorDecorator
()
:
TextEditor
::
ISnippetEditorDecorator
()
{}
CppSnippetEditorDecorator
::~
CppSnippetEditorDecorator
()
{}
bool
CppSnippetEditorDecorator
::
supports
(
TextEditor
::
Snippet
::
Group
group
)
const
{
if
(
group
==
TextEditor
::
Snippet
::
Cpp
)
return
true
;
return
false
;
}
void
CppSnippetEditorDecorator
::
apply
(
TextEditor
::
SnippetEditor
*
editor
)
const
{
CppHighlighter
*
highlighter
=
new
CppHighlighter
;
const
TextEditor
::
FontSettings
&
fs
=
TextEditor
::
TextEditorSettings
::
instance
()
->
fontSettings
();
const
QVector
<
QTextCharFormat
>
&
formats
=
fs
.
toTextCharFormats
(
CPPEditor
::
highlighterFormatCategories
());
highlighter
->
setFormats
(
formats
.
constBegin
(),
formats
.
constEnd
());
editor
->
installSyntaxHighlighter
(
highlighter
);
}
src/plugins/cppeditor/cppsnippeteditordecorator.h
0 → 100644
View file @
7528c6d6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef CPPSNIPPETEDITORDECORATOR_H
#define CPPSNIPPETEDITORDECORATOR_H
#include <texteditor/snippets/isnippeteditordecorator.h>
namespace
CppEditor
{
namespace
Internal
{
class
CppSnippetEditorDecorator
:
public
TextEditor
::
ISnippetEditorDecorator
{
public:
CppSnippetEditorDecorator
();
virtual
~
CppSnippetEditorDecorator
();
public:
virtual
bool
supports
(
TextEditor
::
Snippet
::
Group
group
)
const
;
virtual
void
apply
(
TextEditor
::
SnippetEditor
*
editor
)
const
;
};
}
// Internal
}
// CppEditor
#endif // CPPSNIPPETEDITORDECORATOR_H
src/plugins/cpptools/cppcodecompletion.cpp
View file @
7528c6d6
...
...
@@ -59,6 +59,7 @@
#include <texteditor/itexteditor.h>
#include <texteditor/itexteditable.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/snippets/snippet.h>
#include <projectexplorer/projectexplorer.h>
#include <utils/faketooltip.h>
...
...
@@ -462,7 +463,8 @@ CppCodeCompletion::CppCodeCompletion(CppModelManager *manager)
m_automaticCompletion
(
false
),
m_completionOperator
(
T_EOF_SYMBOL
),
m_objcEnabled
(
true
),
m_snippetsParser
(
Core
::
ICore
::
instance
()
->
resourcePath
()
+
QLatin1String
(
"/snippets/cpp.xml"
))
m_snippetProvider
(
TextEditor
::
Snippet
::
Cpp
,
QIcon
(
QLatin1String
(
":/texteditor/images/snippet.png"
)))
{
}
...
...
@@ -751,12 +753,12 @@ void CppCodeCompletion::completeObjCMsgSend(ClassOrNamespace *binding,
Symbol
*
arg
=
method
->
argumentAt
(
i
);
text
+=
selectorName
->
nameAt
(
i
)
->
identifier
()
->
chars
();
text
+=
QLatin1Char
(
':'
);
text
+=
QChar
::
ObjectReplacementCharac
ter
;
text
+=
TextEditor
::
Snippet
::
kVariableDelimi
ter
;
text
+=
QLatin1Char
(
'('
);
text
+=
oo
(
arg
->
type
());
text
+=
QLatin1Char
(
')'
);
text
+=
oo
(
arg
->
name
());
text
+=
QChar
::
ObjectReplacementCharac
ter
;
text
+=
TextEditor
::
Snippet
::
kVariableDelimi
ter
;
}
}
else
{
text
=
selectorName
->
identifier
()
->
chars
();
...
...
@@ -2058,8 +2060,7 @@ bool CppCodeCompletion::objcKeywordsWanted() const
void
CppCodeCompletion
::
addSnippets
()
{
static
const
QIcon
icon
(
QLatin1String
(
":/texteditor/images/snippet.png"
));
m_completions
.
append
(
m_snippetsParser
.
execute
(
this
,
icon
));
m_completions
.
append
(
m_snippetProvider
.
getSnippets
(
this
));
}
#include "cppcodecompletion.moc"
src/plugins/cpptools/cppcodecompletion.h
View file @
7528c6d6
...
...
@@ -37,7 +37,7 @@
#include <cplusplus/TypeOfExpression.h>
#include <texteditor/icompletioncollector.h>
#include <texteditor/snippets
pars
er.h>
#include <texteditor/snippets
/snippetprovid
er.h>
#include <QtCore/QObject>
#include <QtCore/QPointer>
...
...
@@ -153,7 +153,7 @@ private:
unsigned
m_completionOperator
;
bool
m_objcEnabled
;
TextEditor
::
Snippet
sPars
er
m_snippet
sPars
er
;
TextEditor
::
Snippet
Provid
er
m_snippet
Provid
er
;
CPlusPlus
::
Icons
m_icons
;
CPlusPlus
::
Overview
overview
;
...
...
src/plugins/qmljseditor/qmljscodecompletion.cpp
View file @
7528c6d6
...
...
@@ -487,7 +487,7 @@ CodeCompletion::CodeCompletion(ModelManagerInterface *modelManager, QObject *par
m_editor
(
0
),
m_startPosition
(
0
),
m_restartCompletion
(
false
),
m_snippet
sParser
(
C
or
e
::
ICore
::
instance
()
->
resourcePath
()
+
QLatin1String
(
"/snippets/qml.xml"
)
)
m_snippet
Provider
(
TextEdit
or
::
Snippet
::
Qml
,
iconForColor
(
Qt
::
red
),
SnippetOrder
)
{
Q_ASSERT
(
modelManager
);
}
...
...
@@ -952,7 +952,7 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
}
if
(
isQmlFile
&&
(
completionOperator
.
isNull
()
||
completionOperator
.
isSpace
()
||
isDelimiter
(
completionOperator
)))
{
m_completions
.
append
(
m_snippet
sParser
.
execute
(
this
,
iconForColor
(
Qt
::
red
),
Snippet
Order
));
m_completions
.
append
(
m_snippet
Provider
.
get
Snippet
s
(
this
));
}
if
(
!
m_completions
.
isEmpty
())
...
...
src/plugins/qmljseditor/qmljscodecompletion.h
View file @
7528c6d6
...
...
@@ -32,7 +32,7 @@
#include <qmljs/qmljsdocument.h>
#include <texteditor/icompletioncollector.h>
#include <texteditor/snippets
pars
er.h>
#include <texteditor/snippets
/snippetprovid
er.h>
#include <QtCore/QDateTime>
#include <QtCore/QPointer>
...
...
@@ -97,7 +97,7 @@ private:
TextEditor
::
ITextEditable
*
m_editor
;
int
m_startPosition
;
bool
m_restartCompletion
;
TextEditor
::
Snippet
sPars
er
m_snippet
sPars
er
;
TextEditor
::
Snippet
Provid
er
m_snippet
Provid
er
;
QList
<
TextEditor
::
CompletionItem
>
m_completions
;
QPointer
<
FunctionArgumentWidget
>
m_functionArgumentWidget
;
};
...
...
src/plugins/qmljseditor/qmljseditor.cpp
View file @
7528c6d6
...
...
@@ -1187,27 +1187,7 @@ void QmlJSTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
if
(
!
highlighter
)
return
;
/*
NumberFormat,
StringFormat,
TypeFormat,
KeywordFormat,
LabelFormat,
CommentFormat,
VisualWhitespace,
*/
static
QVector
<
QString
>
categories
;
if
(
categories
.
isEmpty
())
{
categories
<<
QLatin1String
(
TextEditor
::
Constants
::
C_NUMBER
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_STRING
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_TYPE
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_KEYWORD
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_FIELD
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_COMMENT
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_VISUAL_WHITESPACE
);
}
highlighter
->
setFormats
(
fs
.
toTextCharFormats
(
categories
));
highlighter
->
setFormats
(
fs
.
toTextCharFormats
(
highlighterFormatCategories
()));
highlighter
->
rehighlight
();
m_occurrencesFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_OCCURRENCES
));
...
...
@@ -1571,6 +1551,30 @@ bool QmlJSTextEditor::hideContextPane()
return
b
;
}
QVector
<
QString
>
QmlJSTextEditor
::
highlighterFormatCategories
()
{
/*
NumberFormat,
StringFormat,
TypeFormat,
KeywordFormat,
LabelFormat,
CommentFormat,
VisualWhitespace,
*/
static
QVector
<
QString
>
categories
;
if
(
categories
.
isEmpty
())
{
categories
<<
QLatin1String
(
TextEditor
::
Constants
::
C_NUMBER
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_STRING
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_TYPE
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_KEYWORD
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_FIELD
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_COMMENT
)
<<
QLatin1String
(
TextEditor
::
Constants
::
C_VISUAL_WHITESPACE
);
}
return
categories
;
}
SemanticHighlighterSource
QmlJSTextEditor
::
currentSource
(
bool
force
)
{
int
line
=
0
,
column
=
0
;
...
...
src/plugins/qmljseditor/qmljseditor.h
View file @
7528c6d6
...
...
@@ -155,6 +155,8 @@ public:
void
renameId
(
const
QString
&
oldId
,
const
QString
&
newId
);
static
QVector
<
QString
>
highlighterFormatCategories
();
public
slots
:
void
followSymbolUnderCursor
();
void
findUsages
();
...
...
src/plugins/qmljseditor/qmljseditor.pro
View file @
7528c6d6
...
...
@@ -34,7 +34,8 @@ HEADERS += \
qmljssemantichighlighter
.
h
\
qmljsindenter
.
h
\
qmljsautocompleter
.
h
\
jsfilewizard
.
h
jsfilewizard
.
h
\
qmljssnippeteditordecorator
.
h
SOURCES
+=
\
qmljscodecompletion
.
cpp
\
...
...
@@ -62,7 +63,8 @@ SOURCES += \
qmljssemantichighlighter
.
cpp
\
qmljsindenter
.
cpp
\
qmljsautocompleter
.
cpp
\
jsfilewizard
.
cpp
jsfilewizard
.
cpp
\
qmljssnippeteditordecorator
.
cpp
RESOURCES
+=
qmljseditor
.
qrc
OTHER_FILES
+=
QmlJSEditor
.
mimetypes
.
xml
...
...
src/plugins/qmljseditor/qmljseditorplugin.cpp
View file @
7528c6d6
...
...
@@ -39,6 +39,7 @@
#include "qmljsoutline.h"
#include "qmljspreviewrunner.h"
#include "qmljsquickfix.h"
#include "qmljssnippeteditordecorator.h"
#include "qmltaskmanager.h"
#include "quicktoolbar.h"
#include "quicktoolbarsettingspage.h"
...
...
@@ -128,6 +129,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
return
false
;
m_modelManager
=
QmlJS
::
ModelManagerInterface
::
instance
();
addAutoReleasedObject
(
new
QmlJSSnippetEditorDecorator
);
Core
::
Context
context
(
QmlJSEditor
::
Constants
::
C_QMLJSEDITOR_ID
);
...
...
src/plugins/qmljseditor/qmljssnippeteditordecorator.cpp