forked from qt-creator/qt-creator
QmlDesigner: Import only mandatory libraries or directories
Only mandatory files are imported by the newly created component. In the case that the import data is empty, All parent imports would be included. Task-number: QDS-9829 Change-Id: Ie96e2bc04a10e00b15ae12c5e58b5dc2392886ae Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -136,6 +136,18 @@ Document::Ptr QmlJSRefactoringFile::qmljsDocument() const
|
||||
return m_qmljsDocument;
|
||||
}
|
||||
|
||||
QString QmlJSRefactoringFile::qmlImports() const
|
||||
{
|
||||
QString imports;
|
||||
QmlJS::AST::UiProgram *prog = qmljsDocument()->qmlProgram();
|
||||
if (prog && prog->headers) {
|
||||
const unsigned int start = startOf(prog->headers->firstSourceLocation());
|
||||
const unsigned int end = startOf(prog->members->member->firstSourceLocation());
|
||||
imports = textOf(start, end);
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
|
||||
unsigned QmlJSRefactoringFile::startOf(const SourceLocation &loc) const
|
||||
{
|
||||
return position(loc.startLine, loc.startColumn);
|
||||
|
||||
Reference in New Issue
Block a user