summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-07-05 11:04:26 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2013-07-05 11:44:57 +0200
commit1d09ab7c4161153cccf04b64272f41f36b8596d4 (patch)
tree6b3f22793777205dfb0748bc91133e1c97aa89d9
parentb1a00e08b97fdfde0bb18599f8bbbb775462e016 (diff)
downloadqbs-1d09ab7c4161153cccf04b64272f41f36b8596d4.tar.gz
Remove the requirement for an "as" specifier in URI imports.
We just use the last URI component by default. Change-Id: I0b8bf29a84a61ff6772805e538928b5078dfa2f9 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--src/lib/language/itemreaderastvisitor.cpp20
-rw-r--r--src/lib/language/tst_language.cpp2
2 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/language/itemreaderastvisitor.cpp b/src/lib/language/itemreaderastvisitor.cpp
index efb1171a2..b5a3ef846 100644
--- a/src/lib/language/itemreaderastvisitor.cpp
+++ b/src/lib/language/itemreaderastvisitor.cpp
@@ -152,19 +152,27 @@ bool ItemReaderASTVisitor::visit(AST::UiImportList *uiImportList)
}
}
- if (Q_UNLIKELY(import->importId.isNull())) {
- throw ErrorInfo(Tr::tr("Imports require 'as <Name>'"),
- toCodeLocation(import->importToken));
+ if (import->importId.isNull()) {
+ if (!import->fileName.isNull()) {
+ throw ErrorInfo(Tr::tr("File imports require 'as <Name>'"),
+ toCodeLocation(import->importToken));
+ }
+ if (importUri.isEmpty()) {
+ throw ErrorInfo(Tr::tr("Invalid import URI."),
+ toCodeLocation(import->importToken));
+ }
+ as = importUri.last();
+ } else {
+ as = import->importId.toString();
}
- as = import->importId.toString();
if (Q_UNLIKELY(importAsNames.contains(as))) {
throw ErrorInfo(Tr::tr("Can't import into the same name more than once."),
toCodeLocation(import->importIdToken));
}
if (Q_UNLIKELY(JsExtensions::hasExtension(as))) {
- throw ErrorInfo(Tr::tr("Cannot use the name of built-in extension '%1' in an 'as' "
- "specifier.").arg(as));
+ throw ErrorInfo(Tr::tr("Cannot reuse the name of built-in extension '%1'.")
+ .arg(as));
}
importAsNames.insert(as);
}
diff --git a/src/lib/language/tst_language.cpp b/src/lib/language/tst_language.cpp
index 56fb75311..225892070 100644
--- a/src/lib/language/tst_language.cpp
+++ b/src/lib/language/tst_language.cpp
@@ -295,7 +295,7 @@ void TestLanguage::erroneousFiles_data()
QTest::newRow("invalid_property_type")
<< "Unknown type 'nonsense' in property declaration.";
QTest::newRow("reserved_name_in_import")
- << "Cannot use the name of built-in extension 'TextFile' in an 'as' specifier.";
+ << "Cannot reuse the name of built-in extension 'TextFile'.";
QTest::newRow("throw_in_property_binding")
<< "something is wrong";
}