qmljs: improve handling of qml dialects

Language::Enum -> QmlDialect
 * class instead of enum
 * moved Language specific operations to it (from Document)
 * nicer handling
QStringList -> PathsAndLanguages
 * store language along with path, to perform a correct scan and improve
   path handling

Change-Id: If69d35c63cfeb48aa670b51870916cd0c40f1916
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Fawzi Mohamed
2014-07-22 19:06:44 +02:00
parent faa0e5b96c
commit 02bdf30f45
40 changed files with 752 additions and 319 deletions

View File

@@ -134,7 +134,7 @@ QmlJS::AST::ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCurs
_text = expressionUnderCursor(cursor);
Document::MutablePtr newDoc = Document::create(
QLatin1String("<expression>"), Language::JavaScript);
QLatin1String("<expression>"), Dialect::JavaScript);
newDoc->setSource(_text);
newDoc->parseExpression();
exprDoc = newDoc;

View File

@@ -232,7 +232,7 @@ void QmlJSTextEditorWidget::updateCodeWarnings(QmlJS::Document::Ptr doc)
{
if (doc->ast()) {
setExtraSelections(CodeWarningsSelection, QList<QTextEdit::ExtraSelection>());
} else if (Document::isFullySupportedLanguage(doc->language())) {
} else if (doc->language().isFullySupportedLanguage()) {
// show parsing errors
QList<QTextEdit::ExtraSelection> selections;
appendExtraSelectionsForMessages(&selections, doc->diagnosticMessages(), document());

View File

@@ -812,14 +812,14 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
if (oldDoc && oldDoc->editorRevision() == it.value().second)
continue;
Language::Enum language;
Dialect language;
if (oldDoc)
language = oldDoc->language();
else
language = ModelManagerInterface::guessLanguageOfFile(fileName);
if (language == Language::NoLanguage) {
if (language == Dialect::NoLanguage) {
qCDebug(qmljsLog) << "NoLanguage in qmljsfindreferences.cpp find_helper for " << fileName;
language = Language::AnyLanguage;
language = Dialect::AnyLanguage;
}
Document::MutablePtr newDoc = snapshot.documentFromSource(

View File

@@ -434,7 +434,7 @@ private:
void run()
{
int nMessages = 0;
if (Document::isFullySupportedLanguage(m_scopeChain.document()->language())) {
if (m_scopeChain.document()->language().isFullySupportedLanguage()) {
nMessages = m_scopeChain.document()->diagnosticMessages().size()
+ m_semanticInfo.semanticMessages.size()
+ m_semanticInfo.staticAnalysisMessages.size();

View File

@@ -128,7 +128,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D
ScopeChain *scopeChain = new ScopeChain(doc, semanticInfo.context);
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
if (doc->language() == Language::Json) {
if (doc->language() == Dialect::Json) {
Utils::JsonSchema *schema =
QmlJSEditorPlugin::instance()->jsonManager()->schemaForFile(doc->fileName());
if (schema) {

View File

@@ -109,7 +109,7 @@ void QmlTaskManager::collectMessages(
FileErrorMessages result;
result.fileName = fileName;
if (Document::isFullySupportedLanguage(document->language())) {
if (document->language().isFullySupportedLanguage()) {
result.tasks = convertToTasks(document->diagnosticMessages(),
Utils::FileName::fromString(fileName),
Core::Id(Constants::TASK_CATEGORY_QML));
@@ -161,7 +161,7 @@ void QmlTaskManager::updateMessagesNow(bool updateSemantic)
QFuture<FileErrorMessages> future =
QtConcurrent::run<FileErrorMessages>(
&collectMessages, modelManager->newestSnapshot(), modelManager->projectInfos(),
modelManager->defaultVContext(Language::AnyLanguage), updateSemantic);
modelManager->defaultVContext(Dialect::AnyLanguage), updateSemantic);
m_messageCollector.setFuture(future);
}