QQmlSA::ElementPass Class
class QQmlSA::ElementPass요소에 대한 모든 정적 분석 단계의 기본 클래스입니다. 더 보기...
| 헤더: | #include <qqmlsa.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS QmlCompiler) target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler) |
| 상속: | QQmlSA::GenericPass |
| 상태: | 기술 미리보기 |
이 클래스는 기술 미리보기 단계에 있으며 변경될 수 있습니다.
공개 함수
| ElementPass(QQmlSA::PassManager *manager) | |
| virtual void | run(const QQmlSA::Element &element) = 0 |
| virtual bool | shouldRun(const QQmlSA::Element &element) |
상세 설명
ElementPass는 두 가지 분석 단계 중 더 간단한 단계입니다. 이 단계에서는 파일 내의 모든 요소를 고려합니다. shouldRun() 메서드를 사용하여 관련 없는 요소를 걸러낼 수 있으며, run() 메서드가 초기 작업을 수행합니다.
ElementPass에 적합한 일반적인 작업은 다음과 같습니다.
- 요소의 속성이 무의미한 방식으로 결합되지 않았는지 확인
- 속성 값 검증(예: 속성이 특정 열거형 값만 취하는지 확인)
- Element의 부모에 따라 달라지는 동작 확인(예: 부모 요소가
Layout인 경우 Item::width 를 사용하지 않음).
아래 코드 조각에서 볼 수 있듯이, 정적 분석의 성능을 유지하기 위해 ElementPass의 생성자에서 필요한 타입 해결을 수행하고 이를 로컬 멤버에 캐시하며, ` shouldRun()`를 통해 일부 필터링을 구현하는 것이 권장됩니다.
using namespace QQmlSA;
class MyElementPass : public ElementPass
{
Element myType;
public:
MyElementPass(QQmlSA::PassManager *manager)
: myType(resolveType("MyModule", "MyType")) {}
bool shouldRun(const Element &element) override
{
return element.inherits(myType);
}
void run(const Element &element) override
{
// actual pass logic
}
}ElementPass는 요소의 속성이 어떻게 사용되는지에 대한 정보를 제한적으로만 파악할 수 있습니다. 해당 정보가 필요한 경우, 대신 PropertyPass 를 사용하는 것을 고려하십시오.
참고: ElementPass는 인스턴스화 가능한 타입만 고려합니다. 따라서 부착된 타입(attached types) 및 싱글톤(singletons)을 분석하는 데는 적합하지 않습니다. 이러한 경우 PropertyPass 를 통해 처리해야 합니다.
멤버 함수 문서
ElementPass::ElementPass(QQmlSA::PassManager *manager)
ElementPass 객체를 생성하고, ` manager `를 사용하여 패스 관리자를 참조합니다.
[pure virtual] void ElementPass::run(const QQmlSA::Element &element)
shouldRun() 가 true 를 반환할 경우 실행됩니다. element 에서 해당 패스의 실제 계산을 수행합니다. 이 메서드는 오버라이드되도록 설계되었습니다. 기본 메서드를 호출할 필요는 없습니다.
[virtual] bool ElementPass::shouldRun(const QQmlSA::Element &element)
지정된 element 에 대해 run() 함수를 실행할지 여부를 제어합니다. 하위 클래스는 이 메서드를 재정의하여 관련이 없는 요소를 필터링함으로써 분석 성능을 향상시킬 수 있습니다.
기본 구현은 조건 없이 ` true`을 반환합니다.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.