summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libs/qmljs/qmljsscanner.cpp7
-rw-r--r--src/libs/qmljs/qmljsscanner.h7
-rw-r--r--src/plugins/qmljseditor/qmljshighlighter.cpp16
-rw-r--r--src/plugins/qmljseditor/qmljshighlighter.h1
4 files changed, 21 insertions, 10 deletions
diff --git a/src/libs/qmljs/qmljsscanner.cpp b/src/libs/qmljs/qmljsscanner.cpp
index 79f81509f2..9a629db9a9 100644
--- a/src/libs/qmljs/qmljsscanner.cpp
+++ b/src/libs/qmljs/qmljsscanner.cpp
@@ -77,7 +77,7 @@ const _Tp *end(const _Tp (&a)[N])
}
Scanner::Scanner()
- : _state(0),
+ : _state(Normal),
_scanComments(true)
{
}
@@ -122,11 +122,6 @@ static bool isNumberChar(QChar ch)
QList<Token> Scanner::operator()(const QString &text, int startState)
{
- enum {
- Normal = 0,
- MultiLineComment = 1
- };
-
_state = startState;
QList<Token> tokens;
diff --git a/src/libs/qmljs/qmljsscanner.h b/src/libs/qmljs/qmljsscanner.h
index 9141842cd7..611024d426 100644
--- a/src/libs/qmljs/qmljsscanner.h
+++ b/src/libs/qmljs/qmljsscanner.h
@@ -77,13 +77,18 @@ public:
class QMLJS_EXPORT Scanner
{
public:
+ enum {
+ Normal = 0,
+ MultiLineComment = 1
+ };
+
Scanner();
virtual ~Scanner();
bool scanComments() const;
void setScanComments(bool scanComments);
- QList<Token> operator()(const QString &text, int startState = 0);
+ QList<Token> operator()(const QString &text, int startState = Normal);
int state() const;
bool isKeyword(const QString &text) const;
diff --git a/src/plugins/qmljseditor/qmljshighlighter.cpp b/src/plugins/qmljseditor/qmljshighlighter.cpp
index 0e4cf833b0..a6412fc9a9 100644
--- a/src/plugins/qmljseditor/qmljshighlighter.cpp
+++ b/src/plugins/qmljseditor/qmljshighlighter.cpp
@@ -40,7 +40,8 @@ using namespace QmlJS;
Highlighter::Highlighter(QTextDocument *parent)
: QSyntaxHighlighter(parent),
- m_qmlEnabled(true)
+ m_qmlEnabled(true),
+ m_inMultilineComment(false)
{
m_currentBlockParentheses.reserve(20);
m_braceDepth = 0;
@@ -99,6 +100,15 @@ void Highlighter::highlightBlock(const QString &text)
break;
case Token::Comment:
+ if (m_inMultilineComment && text.midRef(token.end() - 2, 2) == QLatin1String("*/")) {
+ onClosingParenthesis('-', token.end() - 1, index == tokens.size()-1);
+ m_inMultilineComment = false;
+ } else if (!m_inMultilineComment
+ && m_scanner.state() == Scanner::MultiLineComment
+ && index == tokens.size() - 1) {
+ onOpeningParenthesis('+', token.offset, index == 0);
+ m_inMultilineComment = true;
+ }
setFormat(token.offset, token.length, m_formats[CommentFormat]);
break;
@@ -327,7 +337,7 @@ void Highlighter::onBlockEnd(int state)
void Highlighter::onOpeningParenthesis(QChar parenthesis, int pos, bool atStart)
{
- if (parenthesis == QLatin1Char('{') || parenthesis == QLatin1Char('[')) {
+ if (parenthesis == QLatin1Char('{') || parenthesis == QLatin1Char('[') || parenthesis == QLatin1Char('+')) {
++m_braceDepth;
// if a folding block opens at the beginning of a line, treat the entire line
// as if it were inside the folding block
@@ -339,7 +349,7 @@ void Highlighter::onOpeningParenthesis(QChar parenthesis, int pos, bool atStart)
void Highlighter::onClosingParenthesis(QChar parenthesis, int pos, bool atEnd)
{
- if (parenthesis == QLatin1Char('}') || parenthesis == QLatin1Char(']')) {
+ if (parenthesis == QLatin1Char('}') || parenthesis == QLatin1Char(']') || parenthesis == QLatin1Char('-')) {
--m_braceDepth;
if (atEnd)
TextEditor::BaseTextDocumentLayout::userData(currentBlock())->setFoldingEndIncluded(true);
diff --git a/src/plugins/qmljseditor/qmljshighlighter.h b/src/plugins/qmljseditor/qmljshighlighter.h
index cf59f5d613..69b1c684d0 100644
--- a/src/plugins/qmljseditor/qmljshighlighter.h
+++ b/src/plugins/qmljseditor/qmljshighlighter.h
@@ -95,6 +95,7 @@ private:
bool m_qmlEnabled;
int m_braceDepth;
int m_foldingIndent;
+ bool m_inMultilineComment;
QmlJS::Scanner m_scanner;
Parentheses m_currentBlockParentheses;