import { GenericType, Type } from '../base/Type'; import { ViewTree } from '../graph/ViewTree'; import { ArkField } from './ArkField'; import { ArkFile, Language } from './ArkFile'; import { ArkMethod } from './ArkMethod'; import { ArkNamespace } from './ArkNamespace'; import { ClassSignature, FieldSignature, FileSignature, MethodSignature, NamespaceSignature } from './ArkSignature'; import { Local } from '../base/Local'; import { ArkExport, ExportType } from './ArkExport'; import { FullPosition } from '../base/Position'; import { ArkBaseModel } from './ArkBaseModel'; import { ArkError } from '../common/ArkError'; export declare enum ClassCategory { CLASS = 0, STRUCT = 1, INTERFACE = 2, ENUM = 3, TYPE_LITERAL = 4, OBJECT = 5, UNION = 6 } /** * Shift amount for class category encoding in ArkClass tags field. * Uses CLASS_SPECIFIC_TAG_SHIFT as the base offset for class-specific properties. */ export declare const CLASS_CATEGORY_SHIFT = 16; /** * Mask for extracting class category from ArkClass tags field. * Covers 3 bits for up to 8 class category values. */ export declare const CLASS_CATEGORY_MASK: number; export interface heritageClassWithInfo { baseClass: ArkClass | undefined | null; isVirtual: boolean; access: string; } /** * @category core/model */ export declare class ArkClass extends ArkBaseModel implements ArkExport { private sourceCode?; /** The full position (start/end line/col) of this class in the source file. * Undefined when this class is an automatically generated default class during IR construction. */ private originFullPosition?; private declaringArkFile; private declaringArkNamespace; private classSignature; /** * The keys of the `heritageClasses` map represent the names of superclass and interfaces. * The superclass name is placed first; if it does not exist, an empty string `''` will occupy this position. * The values of the `heritageClasses` map will be replaced with `ArkClass` or `null` during type inference. */ private heritageClasses; private genericsTypes?; private realTypes?; private defaultMethod; private methods; private fields; private extendedClasses; private staticMethods; private staticFields; private instanceInitMethod; private staticInitMethod; private anonymousMethodNumber; private indexSignatureNumber; private viewTree?; private ts2cxxFuncMap; private classDeclareSignature?; constructor(); /** * Returns the program language of the file where this class defined. */ getLanguage(): Language; /** * Returns the **string**name of this class. * @returns The name of this class. */ getName(): string; /** * Returns the source text of the class extracted from the declaring ArkFile * using the class's origin position. * @returns the source text of the class, or undefined if unavailable. */ getCode(): string | undefined; /** * @deprecated Source text is now stored on ArkFile only. This method has no effect. * @param _code - The source code (ignored). */ setCode(_code: string): void; /** * Returns the full position (start/end line/col) of this class in the source file. * @returns The full position of this class in the source code, or undefined if this class * is an automatically generated default class during IR construction. */ getOriginFullPosition(): FullPosition | undefined; /** * Sets the full position of this class in the source file. * @param position - The full position in the source code to set. */ setOriginFullPosition(position: FullPosition): void; /** * @deprecated Use getOriginFullPosition()?.getFirstLine() instead. * @returns The line number of this class in the source code, or INVALID_LINE if this class * is an automatically generated default class during IR construction. */ getLine(): number; /** * @deprecated Use setOriginFullPosition() instead. * @param line - The line number in the source code to set. */ setLine(line: number): void; /** * @deprecated Use getOriginFullPosition()?.getFirstCol() instead. * @returns The column number of this class in the source code, or INVALID_LINE if this class * is an automatically generated default class during IR construction. */ getColumn(): number; /** * @deprecated Use setOriginFullPosition() instead. * @param column - The column number in the source code to set. */ setColumn(column: number): void; getCategory(): ClassCategory; setCategory(category: ClassCategory): void; /** * Returns the declaring file. * @returns A file defined by ArkAnalyzer. * @example * 1. Get the {@link ArkFile} which the ArkClass is in. ```typescript const arkFile = arkClass.getDeclaringArkFile(); ``` */ getDeclaringArkFile(): ArkFile; setDeclaringArkFile(declaringArkFile: ArkFile): void; /** * Returns the declaring namespace of this class, which may also be an **undefined**. * @returns The declaring namespace (may be **undefined**) of this class. */ getDeclaringArkNamespace(): ArkNamespace | undefined; setDeclaringArkNamespace(declaringArkNamespace: ArkNamespace | undefined): void; isDefaultArkClass(): boolean; isAnonymousClass(): boolean; isLibraryClass(): boolean; /** * Returns the signature of current class (i.e., {@link ClassSignature}). * The {@link ClassSignature} can uniquely identify a class, according to which we can find the class from the scene. * @returns The class signature. */ getSignature(): ClassSignature; setSignature(classSig: ClassSignature): void; getSuperClassName(): string; addHeritageClassName(className: string): void; addHeritageClassNameWithInfo(className: string, classInfo: heritageClassWithInfo): void; /** * Returns the superclass of this class. * If the superclass is defined in this project, then its category must not be INTERFACE. * If the superclass is from the 3rd party library, then its category could be INTERFACE. * @returns The superclass of this class. */ getSuperClass(): ArkClass | null; getHeritageClass(heritageClassName: string): ArkClass | null; getAllHeritageClasses(): ArkClass[]; getExtendedClasses(): Map; addExtendedClass(extendedClass: ArkClass): void; getImplementedInterfaceNames(): string[]; hasImplementedInterface(interfaceName: string): boolean; getImplementedInterface(interfaceName: string): ArkClass | null; /** * Get the field according to its field signature. * If no field cound be found, **null**will be returned. * @param fieldSignature - the field's signature. * @returns A field. If there is no field in this class, the return will be a **null**. */ getField(fieldSignature: FieldSignature): ArkField | null; getFieldWithName(fieldName: string): ArkField | null; getStaticFieldWithName(fieldName: string): ArkField | null; /** * Returns an **array** of fields in the class. * @returns an **array** of fields in the class. */ getFields(): ArkField[]; addField(field: ArkField): void; addFields(fields: ArkField[]): void; getRealTypes(): Type[] | undefined; getGenericsTypes(): GenericType[] | undefined; addGenericType(gType: GenericType): void; /** * Returns all methods defined in the specific class in the form of an array. * @param generated - indicating whether this API returns the methods that are dynamically * generated at runtime. If it is not specified as true or false, the return will not include the generated method. * @returns An array of all methods in this class. * @example * 1. Get methods defined in class `BookService`. ```typescript let classes: ArkClass[] = scene.getClasses(); let serviceClass : ArkClass = classes[1]; let methods: ArkMethod[] = serviceClass.getMethods(); let methodNames: string[] = methods.map(mthd => mthd.name); console.log(methodNames); ``` */ getMethods(generated?: boolean): ArkMethod[]; getMethod(methodSignature: MethodSignature): ArkMethod | null; /** * Find a method that matches the specified signature * @ param mtd - Ark method object to check * @ param methodSignature - the method signature to match * @ returns If a matching method is found, the method object will be returned; otherwise, null will be returned */ private findMatchingMethod; getMethodWithName(methodName: string): ArkMethod | null; getStaticMethodWithName(methodName: string): ArkMethod | null; /** * add a method in class. * when a nested method with declare name, add both the declare origin name and signature name * %${declare name}$${outer method name} in class. */ addMethod(method: ArkMethod, originName?: string): void; /** * Update the new method to the corresponding Map. * * @param newMethod - the new method * @param methodName - name of new method */ private updateMethodMap; /** * Get all non-static methods with the same name. * * @param methodName - name of method * @returns an **array** of methods in the class. */ getMethodsWithName(methodName: string): ArkMethod[]; /** * Get all static methods with the same name. * * @param methodName - name of method * @returns an **array** of methods in the class. */ getStaticMethodsWithName(methodName: string): ArkMethod[]; /** * Get all non-static and static methods with the same name. * * @param methodName - name of method * @returns an **array** of methods in the class. */ getAllMethodsWithName(methodName: string): ArkMethod[]; setDefaultArkMethod(defaultMethod: ArkMethod): void; getDefaultArkMethod(): ArkMethod | null; setViewTree(viewTree: ViewTree): void; /** * Returns the view tree of the ArkClass. * @returns The view tree of the ArkClass. * @example * 1. get viewTree of ArkClass. ```typescript for (let arkFiles of scene.getFiles()) { for (let arkClasss of arkFiles.getClasses()) { if (arkClasss.hasViewTree()) { arkClasss.getViewTree(); } } } ``` */ getViewTree(): ViewTree | undefined; /** * Check whether the view tree is defined. * If it is defined, the return value is true, otherwise it is false. * @returns True if the view tree is defined; false otherwise. * @example * 1. Judge viewTree of ArkClass. ```typescript for (let arkFiles of scene.getFiles()) { for (let arkClasss of arkFiles.getClasses()) { if (arkClasss.hasViewTree()) { arkClasss.getViewTree(); } } } ``` */ hasViewTree(): boolean; getStaticFields(_classMap: Map): ArkField[]; getGlobalVariable(globalMap: Map): Local[]; getAnonymousMethodNumber(): number; getIndexSignatureNumber(): number; getExportType(): ExportType; getInstanceInitMethod(): ArkMethod; getStaticInitMethod(): ArkMethod; setInstanceInitMethod(arkMethod: ArkMethod): void; setStaticInitMethod(arkMethod: ArkMethod): void; removeField(field: ArkField): boolean; removeMethod(method: ArkMethod): boolean; validate(): ArkError; addTs2cxxFuncMapElement(funcName: string, methods: ArkMethod[]): void; getTs2cxxFuncMap(): Map; getDeclareSignature(): ClassSignature | undefined; setDeclareSignature(classSig: ClassSignature): void; clearAllReferences(): void; } //# sourceMappingURL=ArkClass.d.ts.map