mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-20 19:47:44 -04:00
!741 fixed resource not support bug
Merge pull request !741 from laibo102/master
This commit is contained in:
@@ -175,7 +175,8 @@ export const RESOURCE_TYPE = {
|
||||
pattern: 10008,
|
||||
strarray: 10009,
|
||||
media: 20000,
|
||||
rawfile: 30000
|
||||
rawfile: 30000,
|
||||
graphic: 40000
|
||||
};
|
||||
|
||||
export const WORKERS_DIR: string = 'workers';
|
||||
|
||||
@@ -294,19 +294,31 @@ function processResourceData(node: ts.CallExpression): ts.Node {
|
||||
if (node.expression.getText() === RESOURCE_RAWFILE) {
|
||||
return createResourceParam(0, RESOURCE_TYPE.rawfile, [node.arguments[0]]);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
const resourceData: string[] = node.arguments[0].text.trim().split('.');
|
||||
if (validateResourceData(resourceData, resources, node.arguments[0].getStart())) {
|
||||
const resourceType: number = RESOURCE_TYPE[resourceData[1]];
|
||||
const resourceValue: number = resources[resourceData[0]][resourceData[1]][resourceData[2]];
|
||||
return createResourceParam(resourceValue, resourceType,
|
||||
Array.from(node.arguments).slice(1));
|
||||
}
|
||||
return getResourceDataNode(node);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function getResourceDataNode(node: ts.CallExpression): ts.Node {
|
||||
const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.');
|
||||
if (validateResourceData(resourceData, resources, node.arguments[0].getStart())) {
|
||||
const resourceType: number = RESOURCE_TYPE[resourceData[1]];
|
||||
if (resourceType === undefined) {
|
||||
transformLog.errors.push({
|
||||
type: LogType.ERROR,
|
||||
message: `The resource type ${resourceData[1]} is not supported.`,
|
||||
pos: node.getStart()
|
||||
});
|
||||
return node;
|
||||
}
|
||||
const resourceValue: number = resources[resourceData[0]][resourceData[1]][resourceData[2]];
|
||||
return createResourceParam(resourceValue, resourceType,
|
||||
Array.from(node.arguments).slice(1));
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function createResourceParam(resourceValue: number, resourceType: number, argsArr: ts.Expression[]):
|
||||
ts.ObjectLiteralExpression {
|
||||
const propertyArray: Array[ts.PropertyAssignment] = [
|
||||
|
||||
Reference in New Issue
Block a user