mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-20 19:47:44 -04:00
componentid be compatible preview mode incremental compilation Signed-off-by: yfwang6 <wangyongfei6@huawei.com> Change-Id: If2722ad6b95bd8edc496f47998d910e0b16368bb
This commit is contained in:
@@ -944,24 +944,30 @@ function updateArgumentFor$$(argument: any): ts.Expression {
|
||||
function verifyComponentId(temp: any, node: ts.Identifier, propName: string,
|
||||
log: LogInfo[]): void {
|
||||
if (!newsupplement.isAcceleratePreview && propName === ATTRIBUTE_ID) {
|
||||
const literalString: string = temp.arguments[0].text;
|
||||
if (ID_ATTRS.has(literalString)) {
|
||||
const errInfo: Map<string, string | number> = ID_ATTRS.get(literalString);
|
||||
log.push({
|
||||
type: LogType.ERROR,
|
||||
message: `The current component id "${literalString}" is duplicate with ` +
|
||||
`${errInfo.get('path')}:${errInfo.get('line')}:${errInfo.get('col')}.`,
|
||||
pos: node.pos
|
||||
});
|
||||
const id: string = temp.arguments[0].text;
|
||||
const posOfNode: ts.LineAndCharacter = transformLog.sourceFile
|
||||
.getLineAndCharacterOfPosition(getRealNodePos(node));
|
||||
const curFileName: string = transformLog.sourceFile.fileName.replace(/\.ts$/, '');
|
||||
const rPath: string = path.resolve(projectConfig.projectPath, curFileName)
|
||||
.replace(/\\+/g, '/');
|
||||
const rLine: number = posOfNode.line + 1;
|
||||
const rCol: number = posOfNode.character + 1;
|
||||
if (ID_ATTRS.has(id)) {
|
||||
const idInfo: Map<string, string | number> = ID_ATTRS.get(id);
|
||||
if (!(idInfo.get('path') === rPath &&
|
||||
idInfo.get('line') === rLine &&
|
||||
idInfo.get('col') === rCol)) {
|
||||
log.push({
|
||||
type: LogType.WARN,
|
||||
message: `The current component id "${id}" is duplicate with ` +
|
||||
`${idInfo.get('path')}:${idInfo.get('line')}:${idInfo.get('col')}.`,
|
||||
pos: node.pos
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const posOfNode: ts.LineAndCharacter = transformLog.sourceFile
|
||||
.getLineAndCharacterOfPosition(getRealNodePos(node));
|
||||
const curFileName: string = transformLog.sourceFile.fileName.replace(/\.ts$/, '');
|
||||
const rPath: string = path.resolve(projectConfig.projectPath, curFileName)
|
||||
.replace(/\\+/g, '/');
|
||||
ID_ATTRS.set(literalString, new Map().set('path', rPath)
|
||||
.set('line', posOfNode.line + 1)
|
||||
.set('col', posOfNode.character + 1));
|
||||
ID_ATTRS.set(id, new Map().set('path', rPath)
|
||||
.set('line', rLine)
|
||||
.set('col', rCol));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,8 @@ import {
|
||||
EXTEND_ATTRIBUTE,
|
||||
INNER_STYLE_FUNCTION,
|
||||
GLOBAL_STYLE_FUNCTION,
|
||||
INTERFACE_NODE_SET
|
||||
INTERFACE_NODE_SET,
|
||||
ID_ATTRS
|
||||
} from './component_map';
|
||||
import {
|
||||
localStorageLinkCollection,
|
||||
@@ -98,6 +99,7 @@ export function processUISyntax(program: ts.Program, ut = false): Function {
|
||||
pagesDir = path.resolve(path.dirname(node.fileName));
|
||||
if (process.env.compiler === BUILD_ON) {
|
||||
transformLog.sourceFile = node;
|
||||
preprocessIdAttrs(node.fileName);
|
||||
if (!ut && (path.basename(node.fileName) === 'app.ets' || /\.ts$/.test(node.fileName))) {
|
||||
node = ts.visitEachChild(node, processResourceNode, context);
|
||||
if (projectConfig.compileMode === ESMODULE && projectConfig.processTs === true
|
||||
@@ -216,6 +218,14 @@ function generateId(statements: ts.Statement[], node: ts.SourceFile): void {
|
||||
)
|
||||
}
|
||||
|
||||
function preprocessIdAttrs(fileName: string): void {
|
||||
for (const [id, idInfo] of ID_ATTRS) {
|
||||
if (fileName === idInfo.get('path')) {
|
||||
ID_ATTRS.delete(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isCustomDialogController(node: ts.Expression) {
|
||||
const tempParent: ts.Node = node.parent;
|
||||
// @ts-ignore
|
||||
|
||||
Reference in New Issue
Block a user