mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-20 19:47:44 -04:00
add unique id of component tip Signed-off-by: yfwang6 <wangyongfei6@huawei.com> Change-Id: Ie45d3210ef8277a37da466d982fc9da93478c61d
This commit is contained in:
@@ -47,7 +47,7 @@ export const GESTURE_ATTRS: Set<string> = new Set([
|
||||
'gesture', 'parallelGesture', 'priorityGesture'
|
||||
]);
|
||||
|
||||
export const ID_ATTRS: Map<string, Set<string | number>> = new Map();
|
||||
export const ID_ATTRS: Map<string, Map<string, string | number>> = new Map();
|
||||
|
||||
export const forbiddenUseStateType: Set<string> = new Set(['Scroller', 'SwiperScroller',
|
||||
'VideoController', 'WebController', 'CustomDialogController', 'SwiperController',
|
||||
|
||||
@@ -987,36 +987,25 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any,
|
||||
statements: ts.Statement[], identifierNode: ts.Identifier, log: LogInfo[],
|
||||
isStylesAttr: boolean, isGlobalStyles: boolean): void {
|
||||
const propName: string = node.getText();
|
||||
let posOfNode: ts.LineAndCharacter;
|
||||
let curFileName: string;
|
||||
let line: number = 1;
|
||||
let col: number = 1;
|
||||
if (newsupplement.isAcceleratePreview) {
|
||||
posOfNode = sourceNode.getLineAndCharacterOfPosition(getRealNodePos(node));
|
||||
curFileName = newsupplement.fileName;
|
||||
if (posOfNode.line === 0) {
|
||||
col = newsupplement.column - 15;
|
||||
}
|
||||
line = newsupplement.line;
|
||||
} else {
|
||||
posOfNode = transformLog.sourceFile.getLineAndCharacterOfPosition(getRealNodePos(node));
|
||||
curFileName = transformLog.sourceFile.fileName.replace(/\.ts$/, '');
|
||||
}
|
||||
|
||||
if (propName === 'id') {
|
||||
const literalString: string = temp.arguments[0].text;
|
||||
const rLine: number = posOfNode.line + line;
|
||||
const rCol: number = posOfNode.character + col;
|
||||
const projectPath: string = projectConfig.projectPath;
|
||||
const rPath: string = path.resolve(projectPath, curFileName).replace(/\\+/g, '/');
|
||||
const posOfNode: ts.LineAndCharacter = transformLog.sourceFile
|
||||
.getLineAndCharacterOfPosition(getRealNodePos(node));
|
||||
const curFileName: string = transformLog.sourceFile.fileName.replace(/\.ts$/, '');
|
||||
const rLine: number = posOfNode.line + 1;
|
||||
const rCol: number = posOfNode.character + 1;
|
||||
const rPath: string = path.resolve(projectConfig.projectPath, curFileName).replace(/\\+/g, '/');
|
||||
if (ID_ATTRS.has(literalString)) {
|
||||
const errInfo: Map<string, string | number> = ID_ATTRS.get(literalString);
|
||||
log.push({
|
||||
type: LogType.ERROR,
|
||||
message: `There should have a unique id at ${rPath} ${rLine}:${rCol}.`,
|
||||
message: `The current component id at ${rPath}:${rLine}:${rCol} is duplicate with ` +
|
||||
`${errInfo.get('path')}:${errInfo.get('line')}:${errInfo.get('col')}.`,
|
||||
pos: node.pos
|
||||
});
|
||||
} else {
|
||||
ID_ATTRS.set(literalString, new Set([rLine, rCol, rPath]));
|
||||
ID_ATTRS.set(literalString, new Map().set('path', rPath).set('line', rLine).set('col', rCol));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user