mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-11-23 07:10:52 +00:00
fix code check
Signed-off-by: wangcaoyu <wangcaoyu@huawei.com>
This commit is contained in:
parent
92cfffaff4
commit
aa98aa6ea1
@ -42,7 +42,6 @@ describe('diffSingleFile', function () {
|
|||||||
const resultFileContent = fs.readFileSync(resultFilePath, 'utf-8').replace(/\n|\r|\s/g, '');
|
const resultFileContent = fs.readFileSync(resultFilePath, 'utf-8').replace(/\n|\r|\s/g, '');
|
||||||
const expectContent = fs.readFileSync(expectFilePath, 'utf-8').replace(/\n|\r|\s/g, '');
|
const expectContent = fs.readFileSync(expectFilePath, 'utf-8').replace(/\n|\r|\s/g, '');
|
||||||
expect(resultFileContent).to.be.equal(expectContent);
|
expect(resultFileContent).to.be.equal(expectContent);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
});
|
||||||
})
|
|
||||||
|
@ -52,7 +52,7 @@ function getMdFiles(url, isTestCase) {
|
|||||||
if (!pathElements.has('build-tools') || isTestCase) {
|
if (!pathElements.has('build-tools') || isTestCase) {
|
||||||
mdFiles.push(filePath);
|
mdFiles.push(filePath);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return mdFiles;
|
return mdFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,16 +176,13 @@ function checkCurrentJSDocChange(newNodeJSDocs, statusCode, node) {
|
|||||||
checkJSDocChange('permission', currentJSDoc, lastJSDoc, (newTagValue, oldTagValue, addTags) => {
|
checkJSDocChange('permission', currentJSDoc, lastJSDoc, (newTagValue, oldTagValue, addTags) => {
|
||||||
let checkResult = true;
|
let checkResult = true;
|
||||||
// 从无到有新增权限
|
// 从无到有新增权限
|
||||||
if (newTagValue.length === 1 && oldTagValue.length === 0) {
|
checkResult = !(newTagValue.length === 1 && oldTagValue.length === 0);
|
||||||
checkResult = false;
|
|
||||||
}
|
|
||||||
// 权限值变更
|
// 权限值变更
|
||||||
if (newTagValue.length === 1 && oldTagValue.length === 1) {
|
if (newTagValue.length === 1 && oldTagValue.length === 1) {
|
||||||
const newPermission = newTagValue[0];
|
const newPermission = newTagValue[0];
|
||||||
const oldPermission = oldTagValue[0];
|
const oldPermission = oldTagValue[0];
|
||||||
if (newPermission !== oldPermission && checkPermissionChange(newPermission, oldPermission)) {
|
checkResult = checkResult &&
|
||||||
checkResult = false;
|
!(newPermission !== oldPermission && checkPermissionChange(newPermission, oldPermission));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkResult) {
|
if (!checkResult) {
|
||||||
@ -305,15 +302,7 @@ function checkHistoryParameters(currentParameters, lastParameters, change) {
|
|||||||
});
|
});
|
||||||
// 变更后参数范围大于等于变更前
|
// 变更后参数范围大于等于变更前
|
||||||
} else if (currentParamType.length >= historyParamType.length) {
|
} else if (currentParamType.length >= historyParamType.length) {
|
||||||
for (let j = 0; j < historyParamType.length; j++) {
|
checkHistoryParametersType(historyParamType, currentParamType, changeErrors, change);
|
||||||
if (!new Set(currentParamType).has(historyParamType[j])) {
|
|
||||||
changeErrors.push({
|
|
||||||
node: change.newNode,
|
|
||||||
errorInfo: ErrorValueInfo.ERROR_CHANGES_API_HISTORY_PARAM_TYPE_CHANGE,
|
|
||||||
LogType: LogType.LOG_API,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 变更后参数范围小于变更前
|
// 变更后参数范围小于变更前
|
||||||
} else {
|
} else {
|
||||||
changeErrors.push({
|
changeErrors.push({
|
||||||
@ -341,6 +330,18 @@ function checkHistoryParameters(currentParameters, lastParameters, change) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkHistoryParametersType(historyParamType, currentParamType, changeErrors, change) {
|
||||||
|
for (let j = 0; j < historyParamType.length; j++) {
|
||||||
|
if (!new Set(currentParamType).has(historyParamType[j])) {
|
||||||
|
changeErrors.push({
|
||||||
|
node: change.newNode,
|
||||||
|
errorInfo: ErrorValueInfo.ERROR_CHANGES_API_HISTORY_PARAM_TYPE_CHANGE,
|
||||||
|
LogType: LogType.LOG_API,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查API接口新增参数
|
* 检查API接口新增参数
|
||||||
* @param {array} parameters 新增参数列表
|
* @param {array} parameters 新增参数列表
|
||||||
|
@ -172,12 +172,11 @@ function checkEventSubscription(node, sourcefile, fileName) {
|
|||||||
// if the node is method or function
|
// if the node is method or function
|
||||||
if (ts.isFunctionDeclaration(childNode) || ts.isMethodDeclaration(childNode) || ts.isMethodSignature(childNode)) {
|
if (ts.isFunctionDeclaration(childNode) || ts.isMethodDeclaration(childNode) || ts.isMethodSignature(childNode)) {
|
||||||
// if the version needed to be check
|
// if the version needed to be check
|
||||||
let childNodeName = '';
|
let childNodeName = (childNode.name && ts.isIdentifier(childNode.name)) ?
|
||||||
if (childNode.name && ts.isIdentifier(childNode.name)) {
|
childNode.name.getText() :
|
||||||
childNodeName = childNode.name.getText();
|
'';
|
||||||
}
|
handleVariousEventSubscriptionAPI(childNode, childNodeName, sourcefile, fileName, onEventAllNames,
|
||||||
handleVariousEventSubscriptionAPI(childNode, childNodeName, sourcefile, fileName, onEventAllNames, onEventCheckNames, offEventAllNames,
|
onEventCheckNames, offEventAllNames, offEventCheckNames, offEventNodes);
|
||||||
offEventCheckNames, offEventNodes);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// check the callback parameter of off function is optional
|
// check the callback parameter of off function is optional
|
||||||
|
@ -44,12 +44,13 @@ function checkAllUppercaseHump(word) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getName(node) {
|
function getName(node) {
|
||||||
|
let str = '';
|
||||||
if (node.name.escapedText) {
|
if (node.name.escapedText) {
|
||||||
return node.name.escapedText.toString();
|
str = node.name.escapedText.toString();
|
||||||
} else if (node.name.text) {
|
} else if (node.name.text) {
|
||||||
return node.name.text.toString();
|
str = node.name.text.toString();
|
||||||
}
|
}
|
||||||
return;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isConstantDecorator(node, name) {
|
function isConstantDecorator(node, name) {
|
||||||
|
@ -48,7 +48,7 @@ function checkApiNaming(node, sourcefile, fileName) {
|
|||||||
const lowIdentifier = node.getText().toLowerCase();
|
const lowIdentifier = node.getText().toLowerCase();
|
||||||
const apiParentKind = [];
|
const apiParentKind = [];
|
||||||
getParentkind(node, apiParentKind);
|
getParentkind(node, apiParentKind);
|
||||||
if (node.parent.kind === ts.SyntaxKind.TypeReference|| apiParentKind.includes('JSDoc')) {
|
if (node.parent.kind === ts.SyntaxKind.TypeReference || apiParentKind.includes('JSDoc')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
checkApiNamingWords(node, sourcefile, fileName, lowIdentifier);
|
checkApiNamingWords(node, sourcefile, fileName, lowIdentifier);
|
||||||
|
@ -99,11 +99,11 @@ function checkMarkError(node, errorMessage, baseFileName) {
|
|||||||
|
|
||||||
function getParentkind(node, parentkindArr) {
|
function getParentkind(node, parentkindArr) {
|
||||||
if (ts.isSourceFile(node)) {
|
if (ts.isSourceFile(node)) {
|
||||||
return parentkindArr;
|
return;
|
||||||
}
|
}
|
||||||
if (ts.isSourceFile(node.parent)) {
|
if (ts.isSourceFile(node.parent)) {
|
||||||
parentkindArr.push(Object.keys(ts.SyntaxKind).find(k => ts.SyntaxKind[k] === node.parent.kind));
|
parentkindArr.push(Object.keys(ts.SyntaxKind).find(k => ts.SyntaxKind[k] === node.parent.kind));
|
||||||
return parentkindArr;
|
return;
|
||||||
}
|
}
|
||||||
if (!ts.isModuleBlock(node.parent)) {
|
if (!ts.isModuleBlock(node.parent)) {
|
||||||
parentkindArr.push(Object.keys(ts.SyntaxKind).find(k => ts.SyntaxKind[k] === node.parent.kind));
|
parentkindArr.push(Object.keys(ts.SyntaxKind).find(k => ts.SyntaxKind[k] === node.parent.kind));
|
||||||
@ -116,39 +116,41 @@ exports.getParentkind = getParentkind;
|
|||||||
|
|
||||||
function parseUnicodeConfig() {
|
function parseUnicodeConfig() {
|
||||||
let maskInfos = '';
|
let maskInfos = '';
|
||||||
if (fs.existsSync(path.resolve(__dirname, '../config/errorMaskWhiteList.txt'))) {
|
if (!fs.existsSync(path.resolve(__dirname, '../config/errorMaskWhiteList.txt'))) {
|
||||||
const maskInformations = fs.readFileSync(path.resolve(__dirname, '../config/errorMaskWhiteList.txt'), 'utf-8');
|
return maskInfos;
|
||||||
let maskInfoString = '';
|
|
||||||
if (maskInformations && maskInformations.indexOf("\\u") !== -1) {
|
|
||||||
let valArr = maskInformations.split("\\u");
|
|
||||||
for (var j = 0; j < valArr.length; j++) {
|
|
||||||
if (valArr[j] === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
maskInfoString += String.fromCharCode(parseInt(valArr[j], 16));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maskInfos = JSON.parse(maskInfoString);
|
|
||||||
}
|
}
|
||||||
|
const maskInformations = fs.readFileSync(path.resolve(__dirname, '../config/errorMaskWhiteList.txt'), 'utf-8');
|
||||||
|
let maskInfoString = '';
|
||||||
|
if (maskInformations && maskInformations.indexOf('\\u') === -1) {
|
||||||
|
return JSON.parse(maskInfoString);
|
||||||
|
}
|
||||||
|
let valArr = maskInformations.split('\\u');
|
||||||
|
for (let j = 0; j < valArr.length; j++) {
|
||||||
|
if (valArr[j] === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
maskInfoString += String.fromCharCode(parseInt(valArr[j], 16));
|
||||||
|
}
|
||||||
|
maskInfos = JSON.parse(maskInfoString);
|
||||||
return maskInfos;
|
return maskInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
function string2unicode() {
|
function string2unicode() {
|
||||||
const str = fs.readFileSync('../test/errorlist.json', 'utf-8');
|
const str = fs.readFileSync('../test/errorlist.json', 'utf-8');
|
||||||
var ret = "";
|
let ret = '';
|
||||||
var ustr = "";
|
let ustr = '';
|
||||||
|
|
||||||
for (var i = 0; i < str.length; i++) {
|
for (let i = 0; i < str.length; i++) {
|
||||||
var code = str.charCodeAt(i);
|
let code = str.charCodeAt(i);
|
||||||
var code16 = code.toString(16);
|
let code16 = code.toString(16);
|
||||||
if (code < 0xf) {
|
if (code < 0xf) {
|
||||||
ustr = "\\u" + "000" + code16;
|
ustr = '\\u' + '000' + code16;
|
||||||
} else if (code < 0xff) {
|
} else if (code < 0xff) {
|
||||||
ustr = "\\u" + "00" + code16;
|
ustr = '\\u' + '00' + code16;
|
||||||
} else if (code < 0xfff) {
|
} else if (code < 0xfff) {
|
||||||
ustr = "\\u" + "0" + code16;
|
ustr = '\\u' + '0' + code16;
|
||||||
} else {
|
} else {
|
||||||
ustr = "\\u" + code16;
|
ustr = '\\u' + code16;
|
||||||
}
|
}
|
||||||
ret += ustr;
|
ret += ustr;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ const commentNodeWhiteList = [
|
|||||||
exports.commentNodeWhiteList = commentNodeWhiteList;
|
exports.commentNodeWhiteList = commentNodeWhiteList;
|
||||||
|
|
||||||
const tagsArrayOfOrder = [
|
const tagsArrayOfOrder = [
|
||||||
'namespace', 'struct', 'extends', "implements", 'typedef', 'interface', 'permission', 'enum', 'constant', 'type',
|
'namespace', 'struct', 'extends', 'implements', 'typedef', 'interface', 'permission', 'enum', 'constant', 'type',
|
||||||
'param', 'default', 'returns', 'readonly', 'throws', 'static', 'fires', 'syscap', 'systemapi', 'famodelonly',
|
'param', 'default', 'returns', 'readonly', 'throws', 'static', 'fires', 'syscap', 'systemapi', 'famodelonly',
|
||||||
'FAModelOnly', 'stagemodelonly', 'StageModelOnly', 'crossplatform', 'form', 'atomicservice', 'since', 'deprecated',
|
'FAModelOnly', 'stagemodelonly', 'StageModelOnly', 'crossplatform', 'form', 'atomicservice', 'since', 'deprecated',
|
||||||
'useinstead', 'test', 'form', 'example'
|
'useinstead', 'test', 'form', 'example'
|
||||||
|
@ -98,13 +98,17 @@ function collectAllApiDiffs(newApiMap, oldApiMap, diffReporter, oldDir, newDir)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
newApiMap.forEach((newPackageMap, _) => {
|
newApiMap.forEach((newPackageMap, _) => {
|
||||||
newPackageMap.forEach((newClassMap, _) => {
|
collectAllApiDiffFromPackageMap(newPackageMap, diffReporter);
|
||||||
newClassMap.children.forEach((apisMap, _) => {
|
});
|
||||||
apisMap.forEach((apis, _) => {
|
}
|
||||||
diffReporter.addNewApi(apis[0], getSycap(apis[0]));
|
|
||||||
const diffInfo = formatDiffInfo(apis[0], StatusCode.NEW_API, '', apis[0].getRawText(), '', apis[0].node, getSycap(apis[0]));
|
function collectAllApiDiffFromPackageMap(newPackageMap, diffReporter) {
|
||||||
diffReporter.addDiffInfo(diffInfo);
|
newPackageMap.forEach((newClassMap, _) => {
|
||||||
});
|
newClassMap.children.forEach((apisMap, _) => {
|
||||||
|
apisMap.forEach((apis, _) => {
|
||||||
|
diffReporter.addNewApi(apis[0], getSyscap(apis[0]));
|
||||||
|
const diffInfo = formatDiffInfo(apis[0], StatusCode.NEW_API, '', apis[0].getRawText(), '', apis[0].node, getSyscap(apis[0]));
|
||||||
|
diffReporter.addDiffInfo(diffInfo);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -123,14 +127,7 @@ function collectApiDiffFromPackageMap(oldPackageMap, packageName, newApiMap, ext
|
|||||||
// dts文件删除
|
// dts文件删除
|
||||||
let dtsPath;
|
let dtsPath;
|
||||||
oldPackageMap.forEach((classNameMap, _) => {
|
oldPackageMap.forEach((classNameMap, _) => {
|
||||||
classNameMap.children.forEach((apisMap, _) => {
|
collectApiDiffFromPackageMapClass(classNameMap, ext);
|
||||||
apisMap.forEach((apis, _) => {
|
|
||||||
ext.diffReporter.addDeletedApi(apis[0], getSycap(apis[0]));
|
|
||||||
const diffInfo = formatDiffInfo(apis[0], StatusCode.DELETE, apis[0].getRawText(), '',
|
|
||||||
apis[0].node, '', getSycap(apis[0]));
|
|
||||||
ext.diffReporter.addDiffInfo(diffInfo);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
dtsPath = classNameMap.type.path;
|
dtsPath = classNameMap.type.path;
|
||||||
});
|
});
|
||||||
ext.diffReporter.addDeletedPackage(packageName, dtsPath);
|
ext.diffReporter.addDeletedPackage(packageName, dtsPath);
|
||||||
@ -143,7 +140,18 @@ function collectApiDiffFromPackageMap(oldPackageMap, packageName, newApiMap, ext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSycap(api) {
|
function collectApiDiffFromPackageMapClass(classNameMap, ext) {
|
||||||
|
classNameMap.children.forEach((apisMap, _) => {
|
||||||
|
apisMap.forEach((apis, _) => {
|
||||||
|
ext.diffReporter.addDeletedApi(apis[0], getSyscap(apis[0]));
|
||||||
|
const diffInfo = formatDiffInfo(apis[0], StatusCode.DELETE, apis[0].getRawText(), '',
|
||||||
|
apis[0].node, '', getSyscap(apis[0]));
|
||||||
|
ext.diffReporter.addDiffInfo(diffInfo);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSyscap(api) {
|
||||||
let curApi = api;
|
let curApi = api;
|
||||||
let syscap = '';
|
let syscap = '';
|
||||||
if (api.packageName === 'ArkUI') {
|
if (api.packageName === 'ArkUI') {
|
||||||
@ -175,10 +183,10 @@ function getSycap(api) {
|
|||||||
if (/\@syscap\s*((\w|\.|\/|\{|\@|\}|\s)+)/g.test(fileContent)) {
|
if (/\@syscap\s*((\w|\.|\/|\{|\@|\}|\s)+)/g.test(fileContent)) {
|
||||||
fileContent.replace(/\@syscap\s*((\w|\.|\/|\{|\@|\}|\s)+)/g, sysCapInfo => {
|
fileContent.replace(/\@syscap\s*((\w|\.|\/|\{|\@|\}|\s)+)/g, sysCapInfo => {
|
||||||
syscap = sysCapInfo.replace(/\@syscap/g, '').trim();
|
syscap = sysCapInfo.replace(/\@syscap/g, '').trim();
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return syscap;
|
|
||||||
}
|
}
|
||||||
|
return syscap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,13 +209,13 @@ function collectApiDiffFromClassMap(oldClassApi, className, newPackageMap, ext)
|
|||||||
newMessage: '',
|
newMessage: '',
|
||||||
oldNode: '',
|
oldNode: '',
|
||||||
newNode: '',
|
newNode: '',
|
||||||
syscap: getSycap(oldClassApi.type),
|
syscap: getSyscap(oldClassApi.type),
|
||||||
});
|
});
|
||||||
oldClassApi.children.forEach((apisMap, _) => {
|
oldClassApi.children.forEach((apisMap, _) => {
|
||||||
apisMap.forEach((apis, _) => {
|
apisMap.forEach((apis, _) => {
|
||||||
ext.diffReporter.addDeletedApi(apis[0], getSycap(apis[0]));
|
ext.diffReporter.addDeletedApi(apis[0], getSyscap(apis[0]));
|
||||||
const diffInfo = formatDiffInfo(apis[0], StatusCode.DELETE, apis[0].getRawText(), '',
|
const diffInfo = formatDiffInfo(apis[0], StatusCode.DELETE, apis[0].getRawText(), '',
|
||||||
apis[0].node, '', getSycap(apis[0]));
|
apis[0].node, '', getSyscap(apis[0]));
|
||||||
ext.diffReporter.addDiffInfo(diffInfo);
|
ext.diffReporter.addDiffInfo(diffInfo);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -232,7 +240,7 @@ function collectApiDiffFromApiNameMap(oldSignatureMap, apiName, newClassMap, ext
|
|||||||
if (!newClassMap.has(apiName)) {
|
if (!newClassMap.has(apiName)) {
|
||||||
// 方法被删除
|
// 方法被删除
|
||||||
oldSignatureMap.forEach((oldApis, _) => {
|
oldSignatureMap.forEach((oldApis, _) => {
|
||||||
ext.diffReporter.addDeletedApi(oldApis[0], getSycap(oldApis[0]));
|
ext.diffReporter.addDeletedApi(oldApis[0], getSyscap(oldApis[0]));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const newSignatureMap = newClassMap.get(apiName);
|
const newSignatureMap = newClassMap.get(apiName);
|
||||||
@ -244,12 +252,12 @@ function collectApiDiffFromApiNameMap(oldSignatureMap, apiName, newClassMap, ext
|
|||||||
|
|
||||||
sameSignatureSet.forEach(sameSignature => {
|
sameSignatureSet.forEach(sameSignature => {
|
||||||
oldSignatureMap.delete(sameSignature);
|
oldSignatureMap.delete(sameSignature);
|
||||||
})
|
});
|
||||||
|
|
||||||
oldSignatureMap.forEach((oldApis, _) => {
|
oldSignatureMap.forEach((oldApis, _) => {
|
||||||
if (newSignatureMap.size === 0) {
|
if (newSignatureMap.size === 0) {
|
||||||
// 同名函数,方法被删除
|
// 同名函数,方法被删除
|
||||||
ext.diffReporter.addDeletedApi(oldApis[0], getSycap(oldApis[0]));
|
ext.diffReporter.addDeletedApi(oldApis[0], getSyscap(oldApis[0]));
|
||||||
} else {
|
} else {
|
||||||
getFunctionDiff(oldApis, newSignatureMap, ext, sameApiNameNumber);
|
getFunctionDiff(oldApis, newSignatureMap, ext, sameApiNameNumber);
|
||||||
}
|
}
|
||||||
@ -306,7 +314,7 @@ function getFunctionDiff(oldApis, newClassMap, ext, sameApiNameNumber) {
|
|||||||
if (sameApiNameNumber === 1) {
|
if (sameApiNameNumber === 1) {
|
||||||
newClassMap.forEach((apiDigestInfo, apiSignautre) => {
|
newClassMap.forEach((apiDigestInfo, apiSignautre) => {
|
||||||
const diffInfo = formatDiffInfo(oldApis[0], StatusCode.FUNCTION_CHANGES, oldApis[0].getRawText(), apiDigestInfo[0].getRawText(),
|
const diffInfo = formatDiffInfo(oldApis[0], StatusCode.FUNCTION_CHANGES, oldApis[0].getRawText(), apiDigestInfo[0].getRawText(),
|
||||||
oldApis[0].node, apiDigestInfo[0].node, getSycap(apiDigestInfo[0]));
|
oldApis[0].node, apiDigestInfo[0].node, getSyscap(apiDigestInfo[0]));
|
||||||
ext.diffReporter.addChangedApi(diffInfo);
|
ext.diffReporter.addChangedApi(diffInfo);
|
||||||
ext.diffReporter.addDiffInfo(diffInfo);
|
ext.diffReporter.addDiffInfo(diffInfo);
|
||||||
collectJSDocDiffs(oldApis[0], apiDigestInfo[0], ext.diffReporter);
|
collectJSDocDiffs(oldApis[0], apiDigestInfo[0], ext.diffReporter);
|
||||||
@ -317,16 +325,16 @@ function getFunctionDiff(oldApis, newClassMap, ext, sameApiNameNumber) {
|
|||||||
let newApiTypeMap = new Map();
|
let newApiTypeMap = new Map();
|
||||||
getEveryNewApiType(newClassMap, newApiTypeMap);
|
getEveryNewApiType(newClassMap, newApiTypeMap);
|
||||||
if (newApiTypeMap.get(oldApiType) !== undefined && newApiTypeMap.get(oldApiType).size > 1) {
|
if (newApiTypeMap.get(oldApiType) !== undefined && newApiTypeMap.get(oldApiType).size > 1) {
|
||||||
ext.diffReporter.addDeletedApi(oldApis[0], getSycap(oldApis[0]));
|
ext.diffReporter.addDeletedApi(oldApis[0], getSyscap(oldApis[0]));
|
||||||
const diffInfo = formatDiffInfo(oldApis[0], StatusCode.DELETE, oldApis[0].getRawText(), '',
|
const diffInfo = formatDiffInfo(oldApis[0], StatusCode.DELETE, oldApis[0].getRawText(), '',
|
||||||
oldApis[0].node, '', getSycap(oldApis[0]));
|
oldApis[0].node, '', getSyscap(oldApis[0]));
|
||||||
ext.diffReporter.addDiffInfo(diffInfo);
|
ext.diffReporter.addDiffInfo(diffInfo);
|
||||||
} else if (newApiTypeMap.get(oldApiType) !== undefined && newApiTypeMap.get(oldApiType).size === 1) {
|
} else if (newApiTypeMap.get(oldApiType) !== undefined && newApiTypeMap.get(oldApiType).size === 1) {
|
||||||
const oldMessage = oldApis[0].getRawText();
|
const oldMessage = oldApis[0].getRawText();
|
||||||
const newApi = newClassMap.get(...newApiTypeMap.get(oldApiType))[0];
|
const newApi = newClassMap.get(...newApiTypeMap.get(oldApiType))[0];
|
||||||
const newMessage = newApi.getRawText();
|
const newMessage = newApi.getRawText();
|
||||||
const newNode = newApi.node;
|
const newNode = newApi.node;
|
||||||
const syscap = getSycap(newClassMap.get(...newApiTypeMap.get(oldApiType))[0]);
|
const syscap = getSyscap(newClassMap.get(...newApiTypeMap.get(oldApiType))[0]);
|
||||||
const diffInfo = formatDiffInfo(oldApis[0], StatusCode.FUNCTION_CHANGES, oldMessage, newMessage, oldApis[0].node, newNode, syscap);
|
const diffInfo = formatDiffInfo(oldApis[0], StatusCode.FUNCTION_CHANGES, oldMessage, newMessage, oldApis[0].node, newNode, syscap);
|
||||||
ext.diffReporter.addChangedApi(diffInfo);
|
ext.diffReporter.addChangedApi(diffInfo);
|
||||||
ext.diffReporter.addDiffInfo(diffInfo);
|
ext.diffReporter.addDiffInfo(diffInfo);
|
||||||
|
@ -265,19 +265,20 @@ function mergeDiffsAndChangelogs(changelogs, diffs) {
|
|||||||
if (diffsData) {
|
if (diffsData) {
|
||||||
diffs.set(dataSignature, addChangelogLink(data, diffsData, diffs));
|
diffs.set(dataSignature, addChangelogLink(data, diffsData, diffs));
|
||||||
changelogs.delete(dataSignature);
|
changelogs.delete(dataSignature);
|
||||||
} else {
|
return;
|
||||||
data.forEach(changelogData => {
|
}
|
||||||
const newApiSignature = getSignature(changelogData.newDtsName, changelogData.newApi);
|
data.forEach(changelogData => {
|
||||||
const diffsData = diffs.get(newApiSignature);
|
const newApiSignature = getSignature(changelogData.newDtsName, changelogData.newApi);
|
||||||
if (!diffsData) {
|
const diffsData = diffs.get(newApiSignature);
|
||||||
return;
|
if (!diffsData) {
|
||||||
}
|
return;
|
||||||
diffsData.forEach(diffData => {
|
}
|
||||||
diffData.changelog.add(changelogData.changelog);
|
diffsData.forEach(diffData => {
|
||||||
});
|
diffData.changelog.add(changelogData.changelog);
|
||||||
changelogs.delete(dataSignature);
|
|
||||||
});
|
});
|
||||||
}
|
changelogs.delete(dataSignature);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
changelogs.forEach((changelogData, signature) => {
|
changelogs.forEach((changelogData, signature) => {
|
||||||
|
@ -17,7 +17,7 @@ const ts = require('typescript');
|
|||||||
const { ApiDigestInfo } = require('./api_data');
|
const { ApiDigestInfo } = require('./api_data');
|
||||||
const { DiffReporter } = require('./reporter');
|
const { DiffReporter } = require('./reporter');
|
||||||
const { StatusCode } = require('./reporter');
|
const { StatusCode } = require('./reporter');
|
||||||
const { getCheckApiVersion } = require('../../api_check_plugin/src/utils')
|
const { getCheckApiVersion } = require('../../api_check_plugin/src/utils');
|
||||||
|
|
||||||
class TagItem {
|
class TagItem {
|
||||||
constructor() { }
|
constructor() { }
|
||||||
@ -266,16 +266,16 @@ function compareJSDocs(oldApi, newApi, diffReporter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLatestVersion(jsdocs) {
|
function getLatestVersion(jsdocs) {
|
||||||
|
let apiLatestVersion = '';
|
||||||
if (!jsdocs || jsdocs.length === 0) {
|
if (!jsdocs || jsdocs.length === 0) {
|
||||||
return;
|
return apiLatestVersion;
|
||||||
}
|
}
|
||||||
const jsdoc = jsdocs[jsdocs.length - 1];
|
const jsdoc = jsdocs[jsdocs.length - 1];
|
||||||
let apiLatestVersion = '';
|
|
||||||
jsdoc.tags?.forEach(tagObject => {
|
jsdoc.tags?.forEach(tagObject => {
|
||||||
if (tagObject.tag === 'since') {
|
if (tagObject.tag === 'since') {
|
||||||
apiLatestVersion = tagObject.name;
|
apiLatestVersion = tagObject.name;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return apiLatestVersion;
|
return apiLatestVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ describe('diffSingleFile', function () {
|
|||||||
const expectContent = fs.readFileSync(expectFilePath, 'utf-8').replace(/\n|\r|\s/g, '');
|
const expectContent = fs.readFileSync(expectFilePath, 'utf-8').replace(/\n|\r|\s/g, '');
|
||||||
expect(resultFileContent).to.be.equal(expectContent);
|
expect(resultFileContent).to.be.equal(expectContent);
|
||||||
|
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
});
|
||||||
})
|
|
||||||
|
@ -83,25 +83,32 @@ class ProgramFactory {
|
|||||||
return (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
|
return (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
|
||||||
const resolvedModules = [];
|
const resolvedModules = [];
|
||||||
for (const moduleName of moduleNames) {
|
for (const moduleName of moduleNames) {
|
||||||
const moduleLookupLocaton = ts.resolveModuleName(moduleName, containingFile, options, {
|
const moduleLookupLocaton = ts.resolveModuleName(moduleName, containingFile, options,
|
||||||
fileExists: (fileName) => {
|
moduleLookupResolutionHost);
|
||||||
return fileName && ts.sys.fileExists(fileName);
|
|
||||||
},
|
|
||||||
readFile: (fileName) => {
|
|
||||||
ts.sys.readFile(fileName);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (moduleLookupLocaton.resolvedModule) {
|
if (moduleLookupLocaton.resolvedModule) {
|
||||||
resolvedModules.push(moduleLookupLocaton.resolvedModule);
|
resolvedModules.push(moduleLookupLocaton.resolvedModule);
|
||||||
} else {
|
} else {
|
||||||
const modulePath = moduleResolver.resolveModuleName(moduleName);
|
const modulePath = moduleResolver.resolveModuleName(moduleName);
|
||||||
const resolved = modulePath && ts.sys.fileExists(modulePath) ? { resolvedFileName: modulePath } : undefined;
|
const resolved = modulePath && ts.sys.fileExists(modulePath) ?
|
||||||
|
{ resolvedFileName: modulePath } :
|
||||||
|
undefined;
|
||||||
resolvedModules.push(resolved);
|
resolvedModules.push(resolved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resolvedModules;
|
return resolvedModules;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moduleLookupResolutionHost() {
|
||||||
|
return {
|
||||||
|
fileExists: (fileName) => {
|
||||||
|
return fileName && ts.sys.fileExists(fileName);
|
||||||
|
},
|
||||||
|
readFile: (fileName) => {
|
||||||
|
ts.sys.readFile(fileName);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApiCollector {
|
class ApiCollector {
|
||||||
|
@ -208,8 +208,9 @@ class SystemApiRecognizer {
|
|||||||
* @returns {ApiDeclarationInformation | undefined} apiDecInfo
|
* @returns {ApiDeclarationInformation | undefined} apiDecInfo
|
||||||
*/
|
*/
|
||||||
recognizeApiWithNode(node, fileName, positionCallback, useDeclarations) {
|
recognizeApiWithNode(node, fileName, positionCallback, useDeclarations) {
|
||||||
|
let finallySymbol = undefined;
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return undefined;
|
return finallySymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -217,11 +218,11 @@ class SystemApiRecognizer {
|
|||||||
if (symbol && symbol.flags === ts.SymbolFlags.Alias) {
|
if (symbol && symbol.flags === ts.SymbolFlags.Alias) {
|
||||||
symbol = this.typeChecker.getAliasedSymbol(symbol);
|
symbol = this.typeChecker.getAliasedSymbol(symbol);
|
||||||
}
|
}
|
||||||
return this.recognizeApiWithNodeAndSymbol(node, symbol, fileName, positionCallback, useDeclarations);
|
finallySymbol = this.recognizeApiWithNodeAndSymbol(node, symbol, fileName, positionCallback, useDeclarations);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('UNKNOW NODE', error);
|
Logger.error('UNKNOW NODE', error);
|
||||||
}
|
}
|
||||||
|
return finallySymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
recognizeApiWithNodeAndSymbol(node, symbol, fileName, positionCallback, useDeclarations) {
|
recognizeApiWithNodeAndSymbol(node, symbol, fileName, positionCallback, useDeclarations) {
|
||||||
@ -300,18 +301,19 @@ class SystemApiRecognizer {
|
|||||||
const parameters = apiDecInfo ? apiDecInfo.apiNode.parameters : undefined;
|
const parameters = apiDecInfo ? apiDecInfo.apiNode.parameters : undefined;
|
||||||
args.forEach((arg, index) => {
|
args.forEach((arg, index) => {
|
||||||
// interface 定义作为函数入参时, 统计为API
|
// interface 定义作为函数入参时, 统计为API
|
||||||
if (parameters && parameters[index] && parameters[index].type) {
|
this.recognizeArgument(arg, fileName);
|
||||||
const paramType = parameters[index].type;
|
if (!(parameters && parameters[index] && parameters[index].type)) {
|
||||||
if (ts.isTypeReferenceNode(paramType)) {
|
return;
|
||||||
const paramTypeApiDecInfo = this.recognizeApiWithNode(paramType.typeName, fileName, (node) => node.getStart(), true);
|
}
|
||||||
if (paramTypeApiDecInfo) {
|
const paramType = parameters[index].type;
|
||||||
this.modifyTypeReferenceSourceFileName(paramType.typeName, paramTypeApiDecInfo);
|
if (ts.isTypeReferenceNode(paramType)) {
|
||||||
paramTypeApiDecInfo.setApiType('interface');
|
const paramTypeApiDecInfo = this.recognizeApiWithNode(paramType.typeName, fileName, (node) => node.getStart(), true);
|
||||||
paramTypeApiDecInfo.setPosition(ts.getLineAndCharacterOfPosition(arg.getSourceFile(), arg.getStart()));
|
if (paramTypeApiDecInfo) {
|
||||||
}
|
this.modifyTypeReferenceSourceFileName(paramType.typeName, paramTypeApiDecInfo);
|
||||||
|
paramTypeApiDecInfo.setApiType('interface');
|
||||||
|
paramTypeApiDecInfo.setPosition(ts.getLineAndCharacterOfPosition(arg.getSourceFile(), arg.getStart()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.recognizeArgument(arg, fileName);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,23 +691,31 @@ class SystemApiRecognizer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!typeSymbol && childSymbol.members) {
|
if (!typeSymbol && childSymbol.members) {
|
||||||
childSymbol.members.forEach((memberSymbol, memberName) => {
|
setHeritageMembersFroMmembers(heritageMembers, childSymbol.members);
|
||||||
heritageMembers.set(memberName, memberSymbol);
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const valueDeclaration = typeSymbol.valueDeclaration;
|
const valueDeclaration = typeSymbol.valueDeclaration;
|
||||||
if (!valueDeclaration || !this.isSdkApi(valueDeclaration.getSourceFile().fileName)) {
|
if (!valueDeclaration || !this.isSdkApi(valueDeclaration.getSourceFile().fileName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
typeSymbol.members.forEach((memberSymbol, memberName) => {
|
setHeritageMembersFroMmembers(heritageMembers, typeSymbol.members);
|
||||||
heritageMembers.set(memberName, memberSymbol);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return heritageMembers;
|
return heritageMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜集所有父类(属于SDK中的API)的方法和属性。
|
||||||
|
*
|
||||||
|
* @param {Map} heritageMembers
|
||||||
|
* @param {ts.NodeArray} members
|
||||||
|
*/
|
||||||
|
setHeritageMembersFroMmembers(heritageMembers, members) {
|
||||||
|
members.forEach((memberSymbol, memberName) => {
|
||||||
|
heritageMembers.set(memberName, memberSymbol);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析属性访问
|
* 解析属性访问
|
||||||
*
|
*
|
||||||
|
@ -235,7 +235,7 @@ class Sdk {
|
|||||||
listDtsFiles(dir, dest) {
|
listDtsFiles(dir, dest) {
|
||||||
const sdkRoot = this.getPath();
|
const sdkRoot = this.getPath();
|
||||||
if (!sdkRoot) {
|
if (!sdkRoot) {
|
||||||
return new Set();
|
return;
|
||||||
}
|
}
|
||||||
const subDir = path.resolve(sdkRoot, dir);
|
const subDir = path.resolve(sdkRoot, dir);
|
||||||
FileSystem.listFiles(subDir, (filePath) => path.basename(filePath).endsWith('.d.ts'), dest);
|
FileSystem.listFiles(subDir, (filePath) => path.basename(filePath).endsWith('.d.ts'), dest);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"ets": {
|
"ets": {
|
||||||
"render": {
|
"render": {
|
||||||
"method": ["build", "pageTransition"],
|
"method": ["build", "pageTransition"],
|
||||||
"decorator": "Builder"
|
"decorator": "Builder"
|
||||||
|
@ -184,7 +184,7 @@ function processKitImportDeclaration(statement, needDeleteMap, needDeleteExportN
|
|||||||
*/
|
*/
|
||||||
function hasFileByImportPath(importPath) {
|
function hasFileByImportPath(importPath) {
|
||||||
let fileDir = path.resolve(apiSourcePath);
|
let fileDir = path.resolve(apiSourcePath);
|
||||||
if (importPath.startsWith("@arkts")) {
|
if (importPath.startsWith('@arkts')) {
|
||||||
fileDir = path.resolve(apiSourcePath, '../arkts');
|
fileDir = path.resolve(apiSourcePath, '../arkts');
|
||||||
}
|
}
|
||||||
const flag = ['.d.ts', '.d.ets'].some(ext => {
|
const flag = ['.d.ts', '.d.ets'].some(ext => {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
import ExcelJS from 'exceljs';
|
import ExcelJS from 'exceljs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { execSync } from "child_process";
|
import { execSync } from 'child_process';
|
||||||
import { EnumUtils } from '../utils/EnumUtils';
|
import { EnumUtils } from '../utils/EnumUtils';
|
||||||
import { FileUtils } from '../utils/FileUtils';
|
import { FileUtils } from '../utils/FileUtils';
|
||||||
import { LogUtil } from '../utils/logUtil';
|
import { LogUtil } from '../utils/logUtil';
|
||||||
@ -263,26 +263,10 @@ function collectApiCallback(apiData: ApiStatisticsInfo[], sheet: ExcelJS.Workshe
|
|||||||
const subsystemMap: Map<string, string> = FunctionUtils.readSubsystemFile().subsystemMap;
|
const subsystemMap: Map<string, string> = FunctionUtils.readSubsystemFile().subsystemMap;
|
||||||
sheet.name = 'JsApi';
|
sheet.name = 'JsApi';
|
||||||
sheet.views = [{ xSplit: 1 }];
|
sheet.views = [{ xSplit: 1 }];
|
||||||
sheet.getRow(1).values = [
|
sheet.getRow(1).values = ['模块名', '类名', '方法名', '函数', '类型',
|
||||||
'模块名',
|
'起始版本', '废弃版本', 'syscap', '错误码', '是否为系统API',
|
||||||
'类名',
|
'模型限制', '权限', '是否支持跨平台', '是否支持卡片应用', '是否为高阶API',
|
||||||
'方法名',
|
'装饰器', 'kit', '文件路径', '子系统',
|
||||||
'函数',
|
|
||||||
'类型',
|
|
||||||
'起始版本',
|
|
||||||
'废弃版本',
|
|
||||||
'syscap',
|
|
||||||
'错误码',
|
|
||||||
'是否为系统API',
|
|
||||||
'模型限制',
|
|
||||||
'权限',
|
|
||||||
'是否支持跨平台',
|
|
||||||
'是否支持卡片应用',
|
|
||||||
'是否为高阶API',
|
|
||||||
'装饰器',
|
|
||||||
'kit',
|
|
||||||
'文件路径',
|
|
||||||
'子系统',
|
|
||||||
];
|
];
|
||||||
let lineNumber = 2;
|
let lineNumber = 2;
|
||||||
apiData.forEach((apiInfo: ApiStatisticsInfo) => {
|
apiData.forEach((apiInfo: ApiStatisticsInfo) => {
|
||||||
@ -290,7 +274,6 @@ function collectApiCallback(apiData: ApiStatisticsInfo[], sheet: ExcelJS.Workshe
|
|||||||
if (apiRelationsSet.has(apiRelations)) {
|
if (apiRelationsSet.has(apiRelations)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet.getRow(lineNumber).values = [
|
sheet.getRow(lineNumber).values = [
|
||||||
apiInfo.getPackageName(),
|
apiInfo.getPackageName(),
|
||||||
apiInfo.getParentModuleName(),
|
apiInfo.getParentModuleName(),
|
||||||
@ -328,7 +311,7 @@ function checkApi(options: OptionObjType): ToolNameValueType {
|
|||||||
let fileContent: ApiResultMessage[] = [];
|
let fileContent: ApiResultMessage[] = [];
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
|
||||||
fileContent = LocalEntry.checkEntryLocal([], [], "", 'false');
|
fileContent = LocalEntry.checkEntryLocal([], [], '', 'false');
|
||||||
} else if (process.env.NODE_ENV === 'production') {
|
} else if (process.env.NODE_ENV === 'production') {
|
||||||
}
|
}
|
||||||
let finalData: (string | ApiResultMessage)[] = [];
|
let finalData: (string | ApiResultMessage)[] = [];
|
||||||
@ -355,7 +338,7 @@ function checkApi(options: OptionObjType): ToolNameValueType {
|
|||||||
* @return { ToolNameValueType }
|
* @return { ToolNameValueType }
|
||||||
*/
|
*/
|
||||||
function checkOnline(options: OptionObjType): ToolNameValueType {
|
function checkOnline(options: OptionObjType): ToolNameValueType {
|
||||||
options.format = formatType.NULL
|
options.format = formatType.NULL;
|
||||||
try {
|
try {
|
||||||
LocalEntry.checkEntryLocal(options.path.split(','), options.checker.split(','), options.output, options.excel);
|
LocalEntry.checkEntryLocal(options.path.split(','), options.checker.split(','), options.output, options.excel);
|
||||||
return {
|
return {
|
||||||
@ -365,10 +348,10 @@ function checkOnline(options: OptionObjType): ToolNameValueType {
|
|||||||
const error = exception as Error;
|
const error = exception as Error;
|
||||||
LogUtil.e('error check', error.stack ? error.stack : error.message);
|
LogUtil.e('error check', error.stack ? error.stack : error.message);
|
||||||
} finally {
|
} finally {
|
||||||
return {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -412,8 +395,8 @@ function diffApi(options: OptionObjType): ToolNameValueType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function detectionApi(options: OptionObjType): ToolNameValueType {
|
function detectionApi(options: OptionObjType): ToolNameValueType {
|
||||||
process.env.NEED_DETECTION = "true";
|
process.env.NEED_DETECTION = 'true';
|
||||||
options.format = formatType.NULL
|
options.format = formatType.NULL;
|
||||||
const fileDir: string = path.resolve(FileUtils.getBaseDirName(), options.collectPath);
|
const fileDir: string = path.resolve(FileUtils.getBaseDirName(), options.collectPath);
|
||||||
let collectFile: string = '';
|
let collectFile: string = '';
|
||||||
if (options.collectFile !== '') {
|
if (options.collectFile !== '') {
|
||||||
@ -447,11 +430,10 @@ function detectionApi(options: OptionObjType): ToolNameValueType {
|
|||||||
const error = exception as Error;
|
const error = exception as Error;
|
||||||
LogUtil.e(`error collect`, error.stack ? error.stack : error.message);
|
LogUtil.e(`error collect`, error.stack ? error.stack : error.message);
|
||||||
} finally {
|
} finally {
|
||||||
return {
|
|
||||||
data: []
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2351,11 +2351,6 @@
|
|||||||
"androgenic",
|
"androgenic",
|
||||||
"androgynous",
|
"androgynous",
|
||||||
"androgyny",
|
"androgyny",
|
||||||
"android",
|
|
||||||
"androidhive",
|
|
||||||
"androidmanifest",
|
|
||||||
"androidruntime",
|
|
||||||
"androidx",
|
|
||||||
"andromache",
|
"andromache",
|
||||||
"andromeda",
|
"andromeda",
|
||||||
"andropov",
|
"andropov",
|
||||||
@ -3901,6 +3896,7 @@
|
|||||||
"astaire",
|
"astaire",
|
||||||
"astarte",
|
"astarte",
|
||||||
"astatine",
|
"astatine",
|
||||||
|
"astc",
|
||||||
"aster",
|
"aster",
|
||||||
"asteria",
|
"asteria",
|
||||||
"asterisk",
|
"asterisk",
|
||||||
@ -10705,9 +10701,6 @@
|
|||||||
"chromatograph",
|
"chromatograph",
|
||||||
"chromatographic",
|
"chromatographic",
|
||||||
"chromatography",
|
"chromatography",
|
||||||
"chrome",
|
|
||||||
"chromedriver",
|
|
||||||
"chromeoptions",
|
|
||||||
"chromic",
|
"chromic",
|
||||||
"chromite",
|
"chromite",
|
||||||
"chromium",
|
"chromium",
|
||||||
@ -14782,7 +14775,6 @@
|
|||||||
"cystic",
|
"cystic",
|
||||||
"cython",
|
"cython",
|
||||||
"cytochemistry",
|
"cytochemistry",
|
||||||
"cytochrome",
|
|
||||||
"cytologist",
|
"cytologist",
|
||||||
"cytology",
|
"cytology",
|
||||||
"cytolysis",
|
"cytolysis",
|
||||||
@ -19124,7 +19116,6 @@
|
|||||||
"eked",
|
"eked",
|
||||||
"ekg",
|
"ekg",
|
||||||
"ekstrom",
|
"ekstrom",
|
||||||
"ektachrome",
|
|
||||||
"el",
|
"el",
|
||||||
"elaborate",
|
"elaborate",
|
||||||
"elaborateness",
|
"elaborateness",
|
||||||
@ -25798,7 +25789,6 @@
|
|||||||
"glyphicon",
|
"glyphicon",
|
||||||
"glyphs",
|
"glyphs",
|
||||||
"gm",
|
"gm",
|
||||||
"gmail",
|
|
||||||
"gmap",
|
"gmap",
|
||||||
"gmaps",
|
"gmaps",
|
||||||
"gmp",
|
"gmp",
|
||||||
@ -25983,15 +25973,6 @@
|
|||||||
"goofiness",
|
"goofiness",
|
||||||
"goofy",
|
"goofy",
|
||||||
"goog",
|
"goog",
|
||||||
"google",
|
|
||||||
"googleapiclient",
|
|
||||||
"googleapis",
|
|
||||||
"googlecode",
|
|
||||||
"googled",
|
|
||||||
"googlemap",
|
|
||||||
"googlemaps",
|
|
||||||
"googlesource",
|
|
||||||
"googleusercontent",
|
|
||||||
"googling",
|
"googling",
|
||||||
"gooier",
|
"gooier",
|
||||||
"gooiest",
|
"gooiest",
|
||||||
@ -34195,7 +34176,6 @@
|
|||||||
"kobe",
|
"kobe",
|
||||||
"koch",
|
"koch",
|
||||||
"kochab",
|
"kochab",
|
||||||
"kodachrome",
|
|
||||||
"kodak",
|
"kodak",
|
||||||
"kodaly",
|
"kodaly",
|
||||||
"kodiak",
|
"kodiak",
|
||||||
@ -34602,7 +34582,6 @@
|
|||||||
"landowner",
|
"landowner",
|
||||||
"landownership",
|
"landownership",
|
||||||
"landowning",
|
"landowning",
|
||||||
"landroid",
|
|
||||||
"landry",
|
"landry",
|
||||||
"lands",
|
"lands",
|
||||||
"landsat",
|
"landsat",
|
||||||
@ -38693,7 +38672,6 @@
|
|||||||
"merck",
|
"merck",
|
||||||
"mercurial",
|
"mercurial",
|
||||||
"mercuric",
|
"mercuric",
|
||||||
"mercurochrome",
|
|
||||||
"mercury",
|
"mercury",
|
||||||
"mercy",
|
"mercy",
|
||||||
"mere",
|
"mere",
|
||||||
@ -38962,7 +38940,6 @@
|
|||||||
"mg",
|
"mg",
|
||||||
"mgm",
|
"mgm",
|
||||||
"mgmt",
|
"mgmt",
|
||||||
"mgoogleapiclient",
|
|
||||||
"mgr",
|
"mgr",
|
||||||
"mh",
|
"mh",
|
||||||
"mhandler",
|
"mhandler",
|
||||||
@ -41920,7 +41897,6 @@
|
|||||||
"nichole",
|
"nichole",
|
||||||
"nicholle",
|
"nicholle",
|
||||||
"nicholson",
|
"nicholson",
|
||||||
"nichrome",
|
|
||||||
"nick",
|
"nick",
|
||||||
"nickel",
|
"nickel",
|
||||||
"nickelodeon",
|
"nickelodeon",
|
||||||
@ -47567,7 +47543,6 @@
|
|||||||
"polybutene",
|
"polybutene",
|
||||||
"polycarbonate",
|
"polycarbonate",
|
||||||
"polychemicals",
|
"polychemicals",
|
||||||
"polychrome",
|
|
||||||
"polyclinic",
|
"polyclinic",
|
||||||
"polycrystalline",
|
"polycrystalline",
|
||||||
"polyelectrolytes",
|
"polyelectrolytes",
|
||||||
@ -48385,6 +48360,8 @@
|
|||||||
"prescription",
|
"prescription",
|
||||||
"prescriptive",
|
"prescriptive",
|
||||||
"preselect",
|
"preselect",
|
||||||
|
"preselected",
|
||||||
|
"preselecteduris",
|
||||||
"presence",
|
"presence",
|
||||||
"present",
|
"present",
|
||||||
"presentable",
|
"presentable",
|
||||||
@ -68781,7 +68758,6 @@
|
|||||||
"youths",
|
"youths",
|
||||||
"youtrack",
|
"youtrack",
|
||||||
"youtu",
|
"youtu",
|
||||||
"youtube",
|
|
||||||
"yovonnda",
|
"yovonnda",
|
||||||
"yow",
|
"yow",
|
||||||
"yowl",
|
"yowl",
|
||||||
@ -69069,4 +69045,4 @@
|
|||||||
"zz",
|
"zz",
|
||||||
"zzz"
|
"zzz"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ export class LocalEntry {
|
|||||||
return allResult;
|
return allResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
static maskAlarm(allResultInfo: ApiResultSimpleInfo[], fileRuleArr: string[]) {
|
static maskAlarm(allResultInfo: ApiResultSimpleInfo[], fileRuleArr: string[]): void {
|
||||||
const localScan: boolean = (fileRuleArr.length === 1 && fileRuleArr[0] === 'all') ? true : false;
|
const localScan: boolean = (fileRuleArr.length === 1 && fileRuleArr[0] === 'all') ? true : false;
|
||||||
const apiCheckInfos: Map<string, string> = new Map(Object.entries({ ...DOC, ...DEFINE, ...CHANEGE }));
|
const apiCheckInfos: Map<string, string> = new Map(Object.entries({ ...DOC, ...DEFINE, ...CHANEGE }));
|
||||||
let apiCheckAdmissiveSet: Set<string> = new Set();
|
let apiCheckAdmissiveSet: Set<string> = new Set();
|
||||||
@ -53,7 +53,25 @@ export class LocalEntry {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const maskResult: ApiResultSimpleInfo[] = allResultInfo.filter((resultItem: ApiResultSimpleInfo) => {
|
const maskResult: ApiResultSimpleInfo[] = LocalEntry.filterAllResultInfo(allResultInfo,
|
||||||
|
apiCheckInfos, apiCheckAdmissiveSet);
|
||||||
|
maskResult.forEach(resultItem => {
|
||||||
|
const apiChecktErrorLog: ApiResultMessage = new ApiResultMessage();
|
||||||
|
apiChecktErrorLog
|
||||||
|
.setFilePath(resultItem.filePath)
|
||||||
|
.setLocation(resultItem.location)
|
||||||
|
.setLevel(resultItem.level)
|
||||||
|
.setType(resultItem.type)
|
||||||
|
.setMessage(resultItem.message)
|
||||||
|
.setMainBuggyCode(resultItem.apiText)
|
||||||
|
.setMainBuggyLine(resultItem.location);
|
||||||
|
apiCheckResult.push(apiChecktErrorLog);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static filterAllResultInfo(allResultInfo: ApiResultSimpleInfo[], apiCheckInfos: Map<string, string>,
|
||||||
|
apiCheckAdmissiveSet: Set<string>): ApiResultSimpleInfo[] {
|
||||||
|
return allResultInfo.filter((resultItem: ApiResultSimpleInfo) => {
|
||||||
let resultItemInfo: string = resultItem.message.replace(/API check error of \[.*\]: /g, '');
|
let resultItemInfo: string = resultItem.message.replace(/API check error of \[.*\]: /g, '');
|
||||||
const regex1 = /Prohibited word in \[.*\]:{option}.The word allowed is \[.*\]\./g;
|
const regex1 = /Prohibited word in \[.*\]:{option}.The word allowed is \[.*\]\./g;
|
||||||
const regex2 = /Prohibited word in \[.*\]:{ability} in the \[.*\] file\./g;
|
const regex2 = /Prohibited word in \[.*\]:{ability} in the \[.*\] file\./g;
|
||||||
@ -70,27 +88,21 @@ export class LocalEntry {
|
|||||||
resultItemInfo = resultItemInfo.replace(/\[.*\]/g, '[XXXX]');
|
resultItemInfo = resultItemInfo.replace(/\[.*\]/g, '[XXXX]');
|
||||||
}
|
}
|
||||||
if (apiCheckAdmissiveSet.has(resultItemInfo)) {
|
if (apiCheckAdmissiveSet.has(resultItemInfo)) {
|
||||||
for (let [key, value] of apiCheckInfos.entries()) {
|
const key: string = LocalEntry.filterApiCheckInfos(apiCheckInfos, resultItemInfo);
|
||||||
if (value === resultItemInfo)
|
if (key !== '') {
|
||||||
resultItem.setType(key);
|
resultItem.setType(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return apiCheckAdmissiveSet.has(resultItemInfo);
|
return apiCheckAdmissiveSet.has(resultItemInfo);
|
||||||
});
|
});
|
||||||
maskResult.forEach(resultItem => {
|
}
|
||||||
const apiChecktErrorLog: ApiResultMessage = new ApiResultMessage();
|
|
||||||
apiChecktErrorLog
|
|
||||||
.setFilePath(resultItem.filePath)
|
|
||||||
.setLocation(resultItem.location)
|
|
||||||
.setLevel(resultItem.level)
|
|
||||||
.setType(resultItem.type)
|
|
||||||
.setMessage(resultItem.message)
|
|
||||||
.setMainBuggyCode(resultItem.apiText)
|
|
||||||
.setMainBuggyLine(resultItem.location);
|
|
||||||
|
|
||||||
apiCheckResult.push(apiChecktErrorLog);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
static filterApiCheckInfos(apiCheckInfos: Map<string, string>, resultItemInfo: string): string {
|
||||||
|
for (let [key, value] of apiCheckInfos.entries()) {
|
||||||
|
if (value === resultItemInfo) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,160 +119,163 @@ export class Check {
|
|||||||
compositiveResult,
|
compositiveResult,
|
||||||
compositiveLocalResult
|
compositiveLocalResult
|
||||||
);
|
);
|
||||||
} else {
|
return;
|
||||||
// legality check
|
|
||||||
const tagLegalityCheckResult: ErrorTagFormat[] = LegalityCheck.apiLegalityCheck(singleApi, apiJsdoc);
|
|
||||||
// order check
|
|
||||||
const orderCheckResult: ErrorTagFormat = OrderCheck.orderCheck(singleApi, apiJsdoc);
|
|
||||||
// api naming check
|
|
||||||
const namingCheckResult: ErrorTagFormat = ApiNamingCheck.namingCheck(singleApi);
|
|
||||||
// tags name check
|
|
||||||
const tagNamseCheckResult: ErrorTagFormat = TagNameCheck.tagNameCheck(apiJsdoc);
|
|
||||||
// tags inherit check
|
|
||||||
const tagInheritCheckResult: ErrorTagFormat = TagInheritCheck.tagInheritCheck(singleApi);
|
|
||||||
// tags value check
|
|
||||||
const tagValueCheckResult: ErrorTagFormat[] = TagValueCheck.tagValueCheck(singleApi, apiJsdoc);
|
|
||||||
// tags repeat check
|
|
||||||
const tagRepeatCheckResult: ErrorTagFormat[] = TagRepeatCheck.tagRepeatCheck(apiJsdoc);
|
|
||||||
// api forbidden wors check
|
|
||||||
const forbiddenWorsCheckResult: ErrorTagFormat = ForbiddenWordsCheck.forbiddenWordsCheck(singleApi as ClassInfo);
|
|
||||||
if (!orderCheckResult.state) {
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.WRONG_ORDER_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
singleApi.getFilePath(),
|
|
||||||
singleApi.getPos(),
|
|
||||||
ErrorType.WRONG_ORDER,
|
|
||||||
LogType.LOG_JSDOC,
|
|
||||||
toNumber(apiJsdoc.since),
|
|
||||||
singleApi.getApiName(),
|
|
||||||
singleApi.getDefinedText(),
|
|
||||||
orderCheckResult.errorInfo,
|
|
||||||
compositiveResult,
|
|
||||||
compositiveLocalResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!tagNamseCheckResult.state) {
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.UNKNOW_DECORATOR_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
singleApi.getFilePath(),
|
|
||||||
singleApi.getPos(),
|
|
||||||
ErrorType.UNKNOW_DECORATOR,
|
|
||||||
LogType.LOG_JSDOC,
|
|
||||||
toNumber(apiJsdoc.since),
|
|
||||||
singleApi.getApiName(),
|
|
||||||
singleApi.getDefinedText(),
|
|
||||||
tagNamseCheckResult.errorInfo,
|
|
||||||
compositiveResult,
|
|
||||||
compositiveLocalResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!forbiddenWorsCheckResult.state) {
|
|
||||||
const isTsFile: boolean = /\.d\.ts/.test(singleApi.getFilePath());
|
|
||||||
const isAnyError: boolean = /any/.test(forbiddenWorsCheckResult.errorInfo);
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.FORBIDDEN_WORDS_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
singleApi.getFilePath(),
|
|
||||||
singleApi.getPos(),
|
|
||||||
ErrorType.FORBIDDEN_WORDS,
|
|
||||||
LogType.LOG_API,
|
|
||||||
toNumber(apiJsdoc.since),
|
|
||||||
singleApi.getApiName(),
|
|
||||||
singleApi.getDefinedText(),
|
|
||||||
forbiddenWorsCheckResult.errorInfo,
|
|
||||||
compositiveResult,
|
|
||||||
compositiveLocalResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!namingCheckResult.state) {
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.NAMING_ERRORS_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
singleApi.getFilePath(),
|
|
||||||
singleApi.getPos(),
|
|
||||||
ErrorType.NAMING_ERRORS,
|
|
||||||
LogType.LOG_API,
|
|
||||||
toNumber(apiJsdoc.since),
|
|
||||||
singleApi.getApiName(),
|
|
||||||
singleApi.getDefinedText(),
|
|
||||||
namingCheckResult.errorInfo,
|
|
||||||
compositiveResult,
|
|
||||||
compositiveLocalResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!tagInheritCheckResult.state) {
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.WRONG_SCENE_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
singleApi.getFilePath(),
|
|
||||||
singleApi.getPos(),
|
|
||||||
ErrorType.WRONG_SCENE,
|
|
||||||
LogType.LOG_JSDOC,
|
|
||||||
toNumber(apiJsdoc.since),
|
|
||||||
singleApi.getApiName(),
|
|
||||||
singleApi.getDefinedText(),
|
|
||||||
tagInheritCheckResult.errorInfo,
|
|
||||||
compositiveResult,
|
|
||||||
compositiveLocalResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
tagLegalityCheckResult.forEach((legalityResult) => {
|
|
||||||
if (legalityResult.state === false) {
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.WRONG_SCENE_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
singleApi.getFilePath(),
|
|
||||||
singleApi.getPos(),
|
|
||||||
ErrorType.WRONG_SCENE,
|
|
||||||
LogType.LOG_JSDOC,
|
|
||||||
toNumber(apiJsdoc.since),
|
|
||||||
singleApi.getApiName(),
|
|
||||||
singleApi.getDefinedText(),
|
|
||||||
legalityResult.errorInfo,
|
|
||||||
compositiveResult,
|
|
||||||
compositiveLocalResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tagValueCheckResult.forEach((valueResult) => {
|
|
||||||
if (valueResult.state === false) {
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.WRONG_VALUE_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
singleApi.getFilePath(),
|
|
||||||
singleApi.getPos(),
|
|
||||||
ErrorType.WRONG_VALUE,
|
|
||||||
LogType.LOG_JSDOC,
|
|
||||||
toNumber(apiJsdoc.since),
|
|
||||||
singleApi.getApiName(),
|
|
||||||
singleApi.getDefinedText(),
|
|
||||||
valueResult.errorInfo,
|
|
||||||
compositiveResult,
|
|
||||||
compositiveLocalResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tagRepeatCheckResult.forEach((repeatResult) => {
|
|
||||||
if (repeatResult.state === false) {
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.WRONG_SCENE_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
singleApi.getFilePath(),
|
|
||||||
singleApi.getPos(),
|
|
||||||
ErrorType.WRONG_SCENE,
|
|
||||||
LogType.LOG_JSDOC,
|
|
||||||
toNumber(apiJsdoc.since),
|
|
||||||
singleApi.getApiName(),
|
|
||||||
singleApi.getDefinedText(),
|
|
||||||
repeatResult.errorInfo,
|
|
||||||
compositiveResult,
|
|
||||||
compositiveLocalResult
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
// legality check
|
||||||
|
const tagLegalityCheckResult: ErrorTagFormat[] = LegalityCheck.apiLegalityCheck(singleApi, apiJsdoc);
|
||||||
|
// order check
|
||||||
|
const orderCheckResult: ErrorTagFormat = OrderCheck.orderCheck(singleApi, apiJsdoc);
|
||||||
|
// api naming check
|
||||||
|
const namingCheckResult: ErrorTagFormat = ApiNamingCheck.namingCheck(singleApi);
|
||||||
|
// tags name check
|
||||||
|
const tagNamseCheckResult: ErrorTagFormat = TagNameCheck.tagNameCheck(apiJsdoc);
|
||||||
|
// tags inherit check
|
||||||
|
const tagInheritCheckResult: ErrorTagFormat = TagInheritCheck.tagInheritCheck(singleApi);
|
||||||
|
// tags value check
|
||||||
|
const tagValueCheckResult: ErrorTagFormat[] = TagValueCheck.tagValueCheck(singleApi, apiJsdoc);
|
||||||
|
// tags repeat check
|
||||||
|
const tagRepeatCheckResult: ErrorTagFormat[] = TagRepeatCheck.tagRepeatCheck(apiJsdoc);
|
||||||
|
// api forbidden wors check
|
||||||
|
const forbiddenWorsCheckResult: ErrorTagFormat = ForbiddenWordsCheck.forbiddenWordsCheck(singleApi as ClassInfo);
|
||||||
|
if (!orderCheckResult.state) {
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.WRONG_ORDER_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
singleApi.getFilePath(),
|
||||||
|
singleApi.getPos(),
|
||||||
|
ErrorType.WRONG_ORDER,
|
||||||
|
LogType.LOG_JSDOC,
|
||||||
|
toNumber(apiJsdoc.since),
|
||||||
|
singleApi.getApiName(),
|
||||||
|
singleApi.getDefinedText(),
|
||||||
|
orderCheckResult.errorInfo,
|
||||||
|
compositiveResult,
|
||||||
|
compositiveLocalResult
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!tagNamseCheckResult.state) {
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.UNKNOW_DECORATOR_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
singleApi.getFilePath(),
|
||||||
|
singleApi.getPos(),
|
||||||
|
ErrorType.UNKNOW_DECORATOR,
|
||||||
|
LogType.LOG_JSDOC,
|
||||||
|
toNumber(apiJsdoc.since),
|
||||||
|
singleApi.getApiName(),
|
||||||
|
singleApi.getDefinedText(),
|
||||||
|
tagNamseCheckResult.errorInfo,
|
||||||
|
compositiveResult,
|
||||||
|
compositiveLocalResult
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!forbiddenWorsCheckResult.state) {
|
||||||
|
const isTsFile: boolean = /\.d\.ts/.test(singleApi.getFilePath());
|
||||||
|
const isAnyError: boolean = /any/.test(forbiddenWorsCheckResult.errorInfo);
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.FORBIDDEN_WORDS_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
singleApi.getFilePath(),
|
||||||
|
singleApi.getPos(),
|
||||||
|
ErrorType.FORBIDDEN_WORDS,
|
||||||
|
LogType.LOG_API,
|
||||||
|
toNumber(apiJsdoc.since),
|
||||||
|
singleApi.getApiName(),
|
||||||
|
singleApi.getDefinedText(),
|
||||||
|
forbiddenWorsCheckResult.errorInfo,
|
||||||
|
compositiveResult,
|
||||||
|
compositiveLocalResult
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!namingCheckResult.state) {
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.NAMING_ERRORS_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
singleApi.getFilePath(),
|
||||||
|
singleApi.getPos(),
|
||||||
|
ErrorType.NAMING_ERRORS,
|
||||||
|
LogType.LOG_API,
|
||||||
|
toNumber(apiJsdoc.since),
|
||||||
|
singleApi.getApiName(),
|
||||||
|
singleApi.getDefinedText(),
|
||||||
|
namingCheckResult.errorInfo,
|
||||||
|
compositiveResult,
|
||||||
|
compositiveLocalResult
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!tagInheritCheckResult.state) {
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.WRONG_SCENE_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
singleApi.getFilePath(),
|
||||||
|
singleApi.getPos(),
|
||||||
|
ErrorType.WRONG_SCENE,
|
||||||
|
LogType.LOG_JSDOC,
|
||||||
|
toNumber(apiJsdoc.since),
|
||||||
|
singleApi.getApiName(),
|
||||||
|
singleApi.getDefinedText(),
|
||||||
|
tagInheritCheckResult.errorInfo,
|
||||||
|
compositiveResult,
|
||||||
|
compositiveLocalResult
|
||||||
|
);
|
||||||
|
}
|
||||||
|
tagLegalityCheckResult.forEach((legalityResult) => {
|
||||||
|
if (legalityResult.state !== false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.WRONG_SCENE_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
singleApi.getFilePath(),
|
||||||
|
singleApi.getPos(),
|
||||||
|
ErrorType.WRONG_SCENE,
|
||||||
|
LogType.LOG_JSDOC,
|
||||||
|
toNumber(apiJsdoc.since),
|
||||||
|
singleApi.getApiName(),
|
||||||
|
singleApi.getDefinedText(),
|
||||||
|
legalityResult.errorInfo,
|
||||||
|
compositiveResult,
|
||||||
|
compositiveLocalResult
|
||||||
|
);
|
||||||
|
});
|
||||||
|
tagValueCheckResult.forEach((valueResult) => {
|
||||||
|
if (valueResult.state !== false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.WRONG_VALUE_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
singleApi.getFilePath(),
|
||||||
|
singleApi.getPos(),
|
||||||
|
ErrorType.WRONG_VALUE,
|
||||||
|
LogType.LOG_JSDOC,
|
||||||
|
toNumber(apiJsdoc.since),
|
||||||
|
singleApi.getApiName(),
|
||||||
|
singleApi.getDefinedText(),
|
||||||
|
valueResult.errorInfo,
|
||||||
|
compositiveResult,
|
||||||
|
compositiveLocalResult
|
||||||
|
);
|
||||||
|
});
|
||||||
|
tagRepeatCheckResult.forEach((repeatResult) => {
|
||||||
|
if (repeatResult.state !== false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.WRONG_SCENE_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
singleApi.getFilePath(),
|
||||||
|
singleApi.getPos(),
|
||||||
|
ErrorType.WRONG_SCENE,
|
||||||
|
LogType.LOG_JSDOC,
|
||||||
|
toNumber(apiJsdoc.since),
|
||||||
|
singleApi.getApiName(),
|
||||||
|
singleApi.getDefinedText(),
|
||||||
|
repeatResult.errorInfo,
|
||||||
|
compositiveResult,
|
||||||
|
compositiveLocalResult
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,6 @@ export class ApiChangeCheck {
|
|||||||
const newSDKApiMap: FilesMap = Parser.parseFile(path.resolve(newFileDir, '..'), newFileDir);
|
const newSDKApiMap: FilesMap = Parser.parseFile(path.resolve(newFileDir, '..'), newFileDir);
|
||||||
diffInfos = DiffHelper.diffSDK(oldSDKApiMap, newSDKApiMap, true);
|
diffInfos = DiffHelper.diffSDK(oldSDKApiMap, newSDKApiMap, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
diffInfos.forEach((diffInfo: BasicDiffInfo) => {
|
diffInfos.forEach((diffInfo: BasicDiffInfo) => {
|
||||||
if (diffInfo.getIsCompatible() !== false) {
|
if (diffInfo.getIsCompatible() !== false) {
|
||||||
return;
|
return;
|
||||||
|
@ -53,62 +53,62 @@ export class LegalityCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断api的jsdoc中是否存在非法标签,是否缺失必选标签
|
// 判断api的jsdoc中是否存在非法标签,是否缺失必选标签
|
||||||
if (Array.isArray(apiLegalityTagsArray)) {
|
if (!Array.isArray(apiLegalityTagsArray)) {
|
||||||
const apiTags: Comment.CommentTag[] | undefined = apiJsdoc.tags;
|
return apiLegalityCheckResult;
|
||||||
if (apiTags === undefined) {
|
|
||||||
const sinceLost: ErrorTagFormat = {
|
|
||||||
state: false,
|
|
||||||
errorInfo: CommonFunctions.createErrorInfo(ErrorMessage.ERROR_LOST_LABEL, ['since']),
|
|
||||||
};
|
|
||||||
const syscapLost: ErrorTagFormat = {
|
|
||||||
state: false,
|
|
||||||
errorInfo: CommonFunctions.createErrorInfo(ErrorMessage.ERROR_LOST_LABEL, ['syscap']),
|
|
||||||
};
|
|
||||||
apiLegalityCheckResult.push(sinceLost, syscapLost);
|
|
||||||
return apiLegalityCheckResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
let paramTagNumber: number = 0;
|
|
||||||
let paramApiNumber: number =
|
|
||||||
singleApi.getApiType() === ApiType.METHOD ? (singleApi as MethodInfo).getParams().length : 0;
|
|
||||||
apiTags.forEach((apiTag) => {
|
|
||||||
paramTagNumber = apiTag.tag === 'param' ? paramTagNumber + 1 : paramTagNumber;
|
|
||||||
const isUseinsteadLegalSituation: boolean = apiTag.tag === 'useinstead' && apiJsdoc.deprecatedVersion !== '-1';
|
|
||||||
|
|
||||||
if (illegalTagsArray.includes(apiTag.tag)) {
|
|
||||||
if (apiTag.tag !== 'useinstead' || !isUseinsteadLegalSituation) {
|
|
||||||
const apiRedundantResultFormat: ErrorTagFormat = {
|
|
||||||
state: false,
|
|
||||||
errorInfo: CommonFunctions.createErrorInfo(ErrorMessage.ERROR_USE, [apiTag.tag]),
|
|
||||||
};
|
|
||||||
apiLegalityCheckResult.push(apiRedundantResultFormat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
apiLegalityTagsSet.delete('param');
|
|
||||||
if (apiLegalityTagsSet.has(apiTag.tag)) {
|
|
||||||
apiLegalityTagsSet.delete(apiTag.tag);
|
|
||||||
}
|
|
||||||
if (singleApi.getApiType() === ApiType.INTERFACE && (apiTag.tag === 'typedef' || apiTag.tag === 'interface')) {
|
|
||||||
apiLegalityTagsSet.delete('typedef');
|
|
||||||
apiLegalityTagsSet.delete('interface');
|
|
||||||
}
|
|
||||||
if (singleApi.getApiType() === ApiType.METHOD && (singleApi as MethodInfo).getReturnValue().length === 0) {
|
|
||||||
apiLegalityTagsSet.delete('returns');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// param合法性单独进行校验
|
|
||||||
LegalityCheck.paramLegalityCheck(paramTagNumber, paramApiNumber, apiLegalityCheckResult);
|
|
||||||
// 缺失标签set合集
|
|
||||||
apiLegalityTagsSet.forEach((apiLegalityTag) => {
|
|
||||||
if (!conditionalOptionalTags.includes(apiLegalityTag)) {
|
|
||||||
const apiLostResultFormat: ErrorTagFormat = {
|
|
||||||
state: false,
|
|
||||||
errorInfo: CommonFunctions.createErrorInfo(ErrorMessage.ERROR_LOST_LABEL, [apiLegalityTag]),
|
|
||||||
};
|
|
||||||
apiLegalityCheckResult.push(apiLostResultFormat);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const apiTags: Comment.CommentTag[] | undefined = apiJsdoc.tags;
|
||||||
|
if (apiTags === undefined) {
|
||||||
|
const sinceLost: ErrorTagFormat = {
|
||||||
|
state: false,
|
||||||
|
errorInfo: CommonFunctions.createErrorInfo(ErrorMessage.ERROR_LOST_LABEL, ['since']),
|
||||||
|
};
|
||||||
|
const syscapLost: ErrorTagFormat = {
|
||||||
|
state: false,
|
||||||
|
errorInfo: CommonFunctions.createErrorInfo(ErrorMessage.ERROR_LOST_LABEL, ['syscap']),
|
||||||
|
};
|
||||||
|
apiLegalityCheckResult.push(sinceLost, syscapLost);
|
||||||
|
return apiLegalityCheckResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
let paramTagNumber: number = 0;
|
||||||
|
let paramApiNumber: number =
|
||||||
|
singleApi.getApiType() === ApiType.METHOD ? (singleApi as MethodInfo).getParams().length : 0;
|
||||||
|
apiTags.forEach((apiTag) => {
|
||||||
|
paramTagNumber = apiTag.tag === 'param' ? paramTagNumber + 1 : paramTagNumber;
|
||||||
|
const isUseinsteadLegalSituation: boolean = apiTag.tag === 'useinstead' && apiJsdoc.deprecatedVersion !== '-1';
|
||||||
|
|
||||||
|
if (illegalTagsArray.includes(apiTag.tag) && (apiTag.tag !== 'useinstead' || !isUseinsteadLegalSituation)) {
|
||||||
|
const apiRedundantResultFormat: ErrorTagFormat = {
|
||||||
|
state: false,
|
||||||
|
errorInfo: CommonFunctions.createErrorInfo(ErrorMessage.ERROR_USE, [apiTag.tag]),
|
||||||
|
};
|
||||||
|
apiLegalityCheckResult.push(apiRedundantResultFormat);
|
||||||
|
}
|
||||||
|
apiLegalityTagsSet.delete('param');
|
||||||
|
if (apiLegalityTagsSet.has(apiTag.tag)) {
|
||||||
|
apiLegalityTagsSet.delete(apiTag.tag);
|
||||||
|
}
|
||||||
|
if (singleApi.getApiType() === ApiType.INTERFACE && (apiTag.tag === 'typedef' || apiTag.tag === 'interface')) {
|
||||||
|
apiLegalityTagsSet.delete('typedef');
|
||||||
|
apiLegalityTagsSet.delete('interface');
|
||||||
|
}
|
||||||
|
if (singleApi.getApiType() === ApiType.METHOD && (singleApi as MethodInfo).getReturnValue().length === 0) {
|
||||||
|
apiLegalityTagsSet.delete('returns');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// param合法性单独进行校验
|
||||||
|
LegalityCheck.paramLegalityCheck(paramTagNumber, paramApiNumber, apiLegalityCheckResult);
|
||||||
|
// 缺失标签set合集
|
||||||
|
apiLegalityTagsSet.forEach((apiLegalityTag) => {
|
||||||
|
if (!conditionalOptionalTags.includes(apiLegalityTag)) {
|
||||||
|
const apiLostResultFormat: ErrorTagFormat = {
|
||||||
|
state: false,
|
||||||
|
errorInfo: CommonFunctions.createErrorInfo(ErrorMessage.ERROR_LOST_LABEL, [apiLegalityTag]),
|
||||||
|
};
|
||||||
|
apiLegalityCheckResult.push(apiLostResultFormat);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return apiLegalityCheckResult;
|
return apiLegalityCheckResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,85 +38,62 @@ export class TagValueCheck {
|
|||||||
return tagValueError;
|
return tagValueError;
|
||||||
}
|
}
|
||||||
tagsName.forEach((tag) => {
|
tagsName.forEach((tag) => {
|
||||||
if (tag.tag === 'since') {
|
let errorTagInfo: ErrorTagFormat = {
|
||||||
const sincevalueCheckResult = TagValueCheck.sinceTagValueCheck(tag);
|
state: true,
|
||||||
if (!sincevalueCheckResult.state) {
|
errorInfo: '',
|
||||||
tagValueError.push(sincevalueCheckResult);
|
};
|
||||||
}
|
switch (tag.tag) {
|
||||||
|
case 'since':
|
||||||
|
errorTagInfo = TagValueCheck.sinceTagValueCheck(tag);
|
||||||
|
break;
|
||||||
|
case 'extends':
|
||||||
|
case 'implements':
|
||||||
|
errorTagInfo = TagValueCheck.extendsTagValueCheck(singleApi, tag);
|
||||||
|
break;
|
||||||
|
case 'enum':
|
||||||
|
errorTagInfo = TagValueCheck.enumTagValueCheck(tag);
|
||||||
|
break;
|
||||||
|
case 'returns':
|
||||||
|
errorTagInfo = TagValueCheck.returnsTagValueCheck(singleApi, tag);
|
||||||
|
break;
|
||||||
|
case 'namespace':
|
||||||
|
case 'typedef':
|
||||||
|
case 'struct':
|
||||||
|
errorTagInfo = TagValueCheck.outerTagValueCheck(singleApi as ClassInfo, tag);
|
||||||
|
break;
|
||||||
|
case 'type':
|
||||||
|
errorTagInfo = TagValueCheck.typeTagValueCheck(singleApi, tag);
|
||||||
|
break;
|
||||||
|
case 'syscap':
|
||||||
|
errorTagInfo = TagValueCheck.syscapTagValueCheck(tag);
|
||||||
|
break;
|
||||||
|
case 'default':
|
||||||
|
errorTagInfo = TagValueCheck.defaultTagValueCheck(tag);
|
||||||
|
break;
|
||||||
|
case 'deprecated':
|
||||||
|
errorTagInfo = TagValueCheck.deprecatedTagValueCheck(tag);
|
||||||
|
break;
|
||||||
|
case 'permission':
|
||||||
|
errorTagInfo = TagValueCheck.permissionTagValueCheck(tag);
|
||||||
|
break;
|
||||||
|
case 'throws':
|
||||||
|
if (singleApi.getLastJsDocInfo()?.deprecatedVersion === '-1') {
|
||||||
|
throwsIndex += 1;
|
||||||
|
errorTagInfo = TagValueCheck.throwsTagValueCheck(tag, throwsIndex, tagsName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'param':
|
||||||
|
paramIndex += 1;
|
||||||
|
errorTagInfo = TagValueCheck.paramTagValueCheck(singleApi, tag, paramIndex);
|
||||||
|
break;
|
||||||
|
case 'useinstead':
|
||||||
|
errorTagInfo = TagValueCheck.useinsteadTagValueCheck(tag);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (tag.tag === 'extends' || tag.tag === 'implements') {
|
if (!errorTagInfo.state) {
|
||||||
const extendsvalueCheckResult = TagValueCheck.extendsTagValueCheck(singleApi, tag);
|
tagValueError.push(errorTagInfo);
|
||||||
if (!extendsvalueCheckResult.state) {
|
|
||||||
tagValueError.push(extendsvalueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'enum') {
|
|
||||||
const enumvalueCheckResult = TagValueCheck.enumTagValueCheck(tag);
|
|
||||||
if (!enumvalueCheckResult.state) {
|
|
||||||
tagValueError.push(enumvalueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'returns') {
|
|
||||||
const returnsvalueCheckResult = TagValueCheck.returnsTagValueCheck(singleApi, tag);
|
|
||||||
if (!returnsvalueCheckResult.state) {
|
|
||||||
tagValueError.push(returnsvalueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'namespace' || tag.tag === 'typedef' || tag.tag === 'struct') {
|
|
||||||
const outerValueCheckResult = TagValueCheck.outerTagValueCheck(singleApi as ClassInfo, tag);
|
|
||||||
if (!outerValueCheckResult.state) {
|
|
||||||
tagValueError.push(outerValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'type') {
|
|
||||||
const typeValueCheckResult = TagValueCheck.typeTagValueCheck(singleApi, tag);
|
|
||||||
if (!typeValueCheckResult.state) {
|
|
||||||
tagValueError.push(typeValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'syscap') {
|
|
||||||
const syscapValueCheckResult = TagValueCheck.syscapTagValueCheck(tag);
|
|
||||||
if (!syscapValueCheckResult.state) {
|
|
||||||
tagValueError.push(syscapValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'default') {
|
|
||||||
const defaultValueCheckResult = TagValueCheck.defaultTagValueCheck(tag);
|
|
||||||
if (!defaultValueCheckResult.state) {
|
|
||||||
tagValueError.push(defaultValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'deprecated') {
|
|
||||||
const deprecatedValueCheckResult = TagValueCheck.deprecatedTagValueCheck(tag);
|
|
||||||
if (!deprecatedValueCheckResult.state) {
|
|
||||||
tagValueError.push(deprecatedValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'permission') {
|
|
||||||
const permissionValueCheckResult = TagValueCheck.permissionTagValueCheck(tag);
|
|
||||||
if (!permissionValueCheckResult.state) {
|
|
||||||
tagValueError.push(permissionValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'throws' && singleApi.getLastJsDocInfo()?.deprecatedVersion === '-1') {
|
|
||||||
throwsIndex += 1;
|
|
||||||
const throwsValueCheckResult = TagValueCheck.throwsTagValueCheck(tag, throwsIndex, tagsName);
|
|
||||||
if (!throwsValueCheckResult.state) {
|
|
||||||
tagValueError.push(throwsValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'param') {
|
|
||||||
paramIndex += 1;
|
|
||||||
const paramValueCheckResult = TagValueCheck.paramTagValueCheck(singleApi, tag, paramIndex);
|
|
||||||
if (!paramValueCheckResult.state) {
|
|
||||||
tagValueError.push(paramValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag.tag === 'useinstead') {
|
|
||||||
const useinsteadValueCheckResult = TagValueCheck.useinsteadTagValueCheck(tag);
|
|
||||||
if (!useinsteadValueCheckResult.state) {
|
|
||||||
tagValueError.push(useinsteadValueCheckResult);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return tagValueError;
|
return tagValueError;
|
||||||
@ -200,7 +177,7 @@ export class TagValueCheck {
|
|||||||
|
|
||||||
let returnsApiValue: string[] = [];
|
let returnsApiValue: string[] = [];
|
||||||
if (singleApi.getApiType() !== ApiType.METHOD) {
|
if (singleApi.getApiType() !== ApiType.METHOD) {
|
||||||
return returnsValueCheckResult
|
return returnsValueCheckResult;
|
||||||
}
|
}
|
||||||
const spacealCase: string[] = CommonFunctions.judgeSpecialCase((singleApi as MethodInfo).returnValueType);
|
const spacealCase: string[] = CommonFunctions.judgeSpecialCase((singleApi as MethodInfo).returnValueType);
|
||||||
if (spacealCase.length > 0) {
|
if (spacealCase.length > 0) {
|
||||||
@ -240,8 +217,8 @@ export class TagValueCheck {
|
|||||||
const genericArr: GenericInfo[] = singleApi.getGenericInfo();
|
const genericArr: GenericInfo[] = singleApi.getGenericInfo();
|
||||||
if (genericArr.length > 0) {
|
if (genericArr.length > 0) {
|
||||||
let genericInfo = genericArr.map((generic) => {
|
let genericInfo = genericArr.map((generic) => {
|
||||||
return generic.getGenericContent()
|
return generic.getGenericContent();
|
||||||
}).join(',')
|
}).join(',');
|
||||||
apiValue = apiValue + '<' + genericInfo + '>';
|
apiValue = apiValue + '<' + genericInfo + '>';
|
||||||
}
|
}
|
||||||
if (singleApi.getApiType() === 'Interface' && tagValue !== apiValue) {
|
if (singleApi.getApiType() === 'Interface' && tagValue !== apiValue) {
|
||||||
@ -410,8 +387,8 @@ export class TagValueCheck {
|
|||||||
}
|
}
|
||||||
const allTagName: string[] = [];
|
const allTagName: string[] = [];
|
||||||
tagsName?.forEach((tag: Comment.CommentTag) => {
|
tagsName?.forEach((tag: Comment.CommentTag) => {
|
||||||
allTagName.push(tag.tag)
|
allTagName.push(tag.tag);
|
||||||
})
|
});
|
||||||
if (throwsTagName === '201' && !allTagName.includes('permission')) {
|
if (throwsTagName === '201' && !allTagName.includes('permission')) {
|
||||||
throwsValueCheckResult.state = false;
|
throwsValueCheckResult.state = false;
|
||||||
throwsValueCheckResult.errorInfo = CommonFunctions.createErrorInfo(ErrorMessage.ERROR_LOST_LABEL, ['permission']);
|
throwsValueCheckResult.errorInfo = CommonFunctions.createErrorInfo(ErrorMessage.ERROR_LOST_LABEL, ['permission']);
|
||||||
@ -506,28 +483,28 @@ export class TagValueCheck {
|
|||||||
const MODEL_COUNTS: number = 2;
|
const MODEL_COUNTS: number = 2;
|
||||||
const FILENAME_MODEL_COUNT: number = 1;
|
const FILENAME_MODEL_COUNT: number = 1;
|
||||||
if (splitArray.length === MODEL_COUNT) {
|
if (splitArray.length === MODEL_COUNT) {
|
||||||
if (
|
// 同一文件
|
||||||
|
useinsteadValueCheckResult.state =
|
||||||
splitArray[0].indexOf(PunctuationMark.LEFT_BRACKET) === -1 &&
|
splitArray[0].indexOf(PunctuationMark.LEFT_BRACKET) === -1 &&
|
||||||
splitArray[0].indexOf(PunctuationMark.RIGHT_BRACKET) === -1
|
splitArray[0].indexOf(PunctuationMark.RIGHT_BRACKET) === -1 &&
|
||||||
) {
|
TagValueCheck.checkModule(splitArray[0]);
|
||||||
// 同一文件
|
|
||||||
useinsteadValueCheckResult.state = TagValueCheck.checkModule(splitArray[0]);
|
|
||||||
}
|
|
||||||
} else if (splitArray.length === MODEL_COUNTS) {
|
} else if (splitArray.length === MODEL_COUNTS) {
|
||||||
// 不同文件
|
// 不同文件
|
||||||
const fileNameArray: string[] = splitArray[0].split('.');
|
const fileNameArray: string[] = splitArray[0].split('.');
|
||||||
if (fileNameArray.length === FILENAME_MODEL_COUNT) {
|
if (fileNameArray.length === FILENAME_MODEL_COUNT) {
|
||||||
// arkui
|
// arkui
|
||||||
if (!/^[A-Za-z0-9_]+\b$/.test(fileNameArray[0]) || !TagValueCheck.checkModule(splitArray[1])) {
|
useinsteadValueCheckResult.state =
|
||||||
useinsteadValueCheckResult.state = false;
|
useinsteadValueCheckResult.state &&
|
||||||
}
|
/^[A-Za-z0-9_]+\b$/.test(fileNameArray[0]) &&
|
||||||
|
TagValueCheck.checkModule(splitArray[1]);
|
||||||
} else {
|
} else {
|
||||||
// 非arkui
|
// 非arkui
|
||||||
let checkFileName: boolean = true;
|
let checkFileName: boolean = true;
|
||||||
for (let i = 0; i < fileNameArray.length; i++) {
|
for (let i = 0; i < fileNameArray.length; i++) {
|
||||||
if (fileNameArray[0] !== 'ohos' || !/^[A-Za-z0-9_]+\b$/.test(fileNameArray[i])) {
|
checkFileName =
|
||||||
checkFileName = false;
|
checkFileName &&
|
||||||
}
|
fileNameArray[0] === 'ohos' &&
|
||||||
|
/^[A-Za-z0-9_]+\b$/.test(fileNameArray[i]);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!checkFileName ||
|
!checkFileName ||
|
||||||
|
@ -88,27 +88,28 @@ export class TsSyntaxCheck {
|
|||||||
if (fileSuffix === '.ts') {
|
if (fileSuffix === '.ts') {
|
||||||
const targetSourceFile: ts.SourceFile = node.getSourceFile();
|
const targetSourceFile: ts.SourceFile = node.getSourceFile();
|
||||||
programSourceFiles.forEach((programSourceFile) => {
|
programSourceFiles.forEach((programSourceFile) => {
|
||||||
if (programSourceFile.fileName === targetSourceFile.fileName) {
|
if (programSourceFile.fileName !== targetSourceFile.fileName) {
|
||||||
const result: readonly ts.Diagnostic[] = program.getSemanticDiagnostics(programSourceFile);
|
return;
|
||||||
result.forEach((item) => {
|
|
||||||
const filePath: string = item.file?.fileName as string;
|
|
||||||
const fileName: string = filePath.substring(filePath.indexOf('api'), filePath.length);
|
|
||||||
AddErrorLogs.addAPICheckErrorLogs(
|
|
||||||
ErrorID.TS_SYNTAX_ERROR_ID,
|
|
||||||
ErrorLevel.MIDDLE,
|
|
||||||
fileName,
|
|
||||||
ts.getLineAndCharacterOfPosition(node.getSourceFile(), item.start as number),
|
|
||||||
ErrorType.TS_SYNTAX_ERROR,
|
|
||||||
LogType.LOG_API,
|
|
||||||
-1,
|
|
||||||
'NA',
|
|
||||||
'NA',
|
|
||||||
item.messageText as string,
|
|
||||||
tsResult,
|
|
||||||
checkErrorAllInfos
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const result: readonly ts.Diagnostic[] = program.getSemanticDiagnostics(programSourceFile);
|
||||||
|
result.forEach((item) => {
|
||||||
|
const filePath: string = item.file?.fileName as string;
|
||||||
|
const fileName: string = filePath.substring(filePath.indexOf('api'), filePath.length);
|
||||||
|
AddErrorLogs.addAPICheckErrorLogs(
|
||||||
|
ErrorID.TS_SYNTAX_ERROR_ID,
|
||||||
|
ErrorLevel.MIDDLE,
|
||||||
|
fileName,
|
||||||
|
ts.getLineAndCharacterOfPosition(node.getSourceFile(), item.start as number),
|
||||||
|
ErrorType.TS_SYNTAX_ERROR,
|
||||||
|
LogType.LOG_API,
|
||||||
|
-1,
|
||||||
|
'NA',
|
||||||
|
'NA',
|
||||||
|
item.messageText as string,
|
||||||
|
tsResult,
|
||||||
|
checkErrorAllInfos
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// ArkTS诊断日志
|
// ArkTS诊断日志
|
||||||
|
@ -27,8 +27,8 @@ import { tagsArrayOfOrder, officialTagArr, CommonFunctions } from '../../../util
|
|||||||
import { AddErrorLogs } from './compile_info';
|
import { AddErrorLogs } from './compile_info';
|
||||||
import { compositiveResult, compositiveLocalResult, punctuationMarkSet } from '../../../utils/checkUtils';
|
import { compositiveResult, compositiveLocalResult, punctuationMarkSet } from '../../../utils/checkUtils';
|
||||||
import { Set } from 'typescript';
|
import { Set } from 'typescript';
|
||||||
import {dictionariesArr} from '../config/dictionaries.json';
|
import { dictionariesArr } from '../config/dictionaries.json';
|
||||||
import {dictionariesSupplementaryArr} from '../config/dictionaries_supplementary.json';
|
import { dictionariesSupplementaryArr } from '../config/dictionaries_supplementary.json';
|
||||||
const dictionariesSet: Set<string> = new Set([
|
const dictionariesSet: Set<string> = new Set([
|
||||||
...dictionariesArr,
|
...dictionariesArr,
|
||||||
...dictionariesSupplementaryArr,
|
...dictionariesSupplementaryArr,
|
||||||
@ -43,18 +43,19 @@ export class WordsCheck {
|
|||||||
*/
|
*/
|
||||||
static wordCheckResultsProcessing(baseInfos: BasicApiInfo[]): void {
|
static wordCheckResultsProcessing(baseInfos: BasicApiInfo[]): void {
|
||||||
baseInfos.forEach((baseInfo) => {
|
baseInfos.forEach((baseInfo) => {
|
||||||
if (baseInfo.getApiType() !== ApiType.SOURCE_FILE) {
|
if (baseInfo.getApiType() === ApiType.SOURCE_FILE) {
|
||||||
let apiText: string = baseInfo.getJsDocText() + baseInfo.getDefinedText();
|
return;
|
||||||
if (baseInfo.getApiType() === ApiType.IMPORT) {
|
|
||||||
const importText: Array<ExportImportValue> = (baseInfo as ImportInfo).getImportValues();
|
|
||||||
const importValueArr: string[] = [];
|
|
||||||
importText.forEach(importValue => {
|
|
||||||
importValueArr.push(importValue.key);
|
|
||||||
});
|
|
||||||
apiText = importValueArr.join('|');
|
|
||||||
}
|
|
||||||
WordsCheck.wordsCheck(apiText, baseInfo);
|
|
||||||
}
|
}
|
||||||
|
let apiText: string = baseInfo.getJsDocText() + baseInfo.getDefinedText();
|
||||||
|
if (baseInfo.getApiType() === ApiType.IMPORT) {
|
||||||
|
const importText: Array<ExportImportValue> = (baseInfo as ImportInfo).getImportValues();
|
||||||
|
const importValueArr: string[] = [];
|
||||||
|
importText.forEach(importValue => {
|
||||||
|
importValueArr.push(importValue.key);
|
||||||
|
});
|
||||||
|
apiText = importValueArr.join('|');
|
||||||
|
}
|
||||||
|
WordsCheck.wordsCheck(apiText, baseInfo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ export class NodeProcessorHelper {
|
|||||||
return interfaceInfo;
|
return interfaceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static processGenericity(typeParameter: ts.TypeParameterDeclaration) {
|
static processGenericity(typeParameter: ts.TypeParameterDeclaration): GenericInfo {
|
||||||
const genericInfo: GenericInfo = new GenericInfo();
|
const genericInfo: GenericInfo = new GenericInfo();
|
||||||
genericInfo.setIsGenericity(true);
|
genericInfo.setIsGenericity(true);
|
||||||
genericInfo.setGenericContent(typeParameter.getText());
|
genericInfo.setGenericContent(typeParameter.getText());
|
||||||
@ -616,7 +616,7 @@ export class NodeProcessorHelper {
|
|||||||
methodInfo.setReturnValueType(methodNode.type.kind);
|
methodInfo.setReturnValueType(methodNode.type.kind);
|
||||||
if (Boolean(process.env.NEED_DETECTION)) {
|
if (Boolean(process.env.NEED_DETECTION)) {
|
||||||
NodeProcessorHelper.processFunctionTypeReference(methodNode.type, methodInfo, new ParamInfo(ApiType
|
NodeProcessorHelper.processFunctionTypeReference(methodNode.type, methodInfo, new ParamInfo(ApiType
|
||||||
.PARAM), false)
|
.PARAM), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let i = 0; i < methodNode.parameters.length; i++) {
|
for (let i = 0; i < methodNode.parameters.length; i++) {
|
||||||
@ -647,7 +647,9 @@ export class NodeProcessorHelper {
|
|||||||
return paramInfo;
|
return paramInfo;
|
||||||
}
|
}
|
||||||
let typeMapValue: string | undefined = undefined;
|
let typeMapValue: string | undefined = undefined;
|
||||||
NodeProcessorHelper.processFunctionTypeReference(param.type, methodInfo, paramInfo, true)
|
if (Boolean(process.env.NEED_DETECTION)) {
|
||||||
|
NodeProcessorHelper.processFunctionTypeReference(param.type, methodInfo, paramInfo, true);
|
||||||
|
}
|
||||||
if (ts.isLiteralTypeNode(param.type)) {
|
if (ts.isLiteralTypeNode(param.type)) {
|
||||||
typeMapValue = typeMap.get(param.type.literal.kind);
|
typeMapValue = typeMap.get(param.type.literal.kind);
|
||||||
}
|
}
|
||||||
@ -669,11 +671,11 @@ export class NodeProcessorHelper {
|
|||||||
*/
|
*/
|
||||||
static processFunctionTypeReference(typeNode: ts.TypeNode, methodInfo: MethodInfo, paramInfo: ParamInfo, isParam: boolean = true): void {
|
static processFunctionTypeReference(typeNode: ts.TypeNode, methodInfo: MethodInfo, paramInfo: ParamInfo, isParam: boolean = true): void {
|
||||||
if (ts.isTypeLiteralNode(typeNode)) {
|
if (ts.isTypeLiteralNode(typeNode)) {
|
||||||
NodeProcessorHelper.processFunctionTypeObject(typeNode, methodInfo, paramInfo, isParam)
|
NodeProcessorHelper.processFunctionTypeObject(typeNode, methodInfo, paramInfo, isParam);
|
||||||
} else if (ts.isUnionTypeNode(typeNode)) {
|
} else if (ts.isUnionTypeNode(typeNode)) {
|
||||||
typeNode.types.forEach((type: ts.TypeNode) => {
|
typeNode.types.forEach((type: ts.TypeNode) => {
|
||||||
NodeProcessorHelper.processFunctionTypeReference(type, methodInfo, paramInfo, isParam)
|
NodeProcessorHelper.processFunctionTypeReference(type, methodInfo, paramInfo, isParam);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
if (!ts.isTypeReferenceNode(typeNode)) {
|
if (!ts.isTypeReferenceNode(typeNode)) {
|
||||||
return;
|
return;
|
||||||
@ -686,17 +688,18 @@ export class NodeProcessorHelper {
|
|||||||
if (!declarations) {
|
if (!declarations) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const declaration: ts.Declaration = declarations[0]
|
const declaration: ts.Declaration = declarations[0];
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = JsDocProcessorHelper.processJsDocInfos(declaration, ApiType.TYPE_ALIAS, methodInfo.getKitInfoFromParent(methodInfo));
|
const jsDocInfos: Comment.JsDocInfo[] = JsDocProcessorHelper.processJsDocInfos(declaration, ApiType.TYPE_ALIAS,
|
||||||
|
methodInfo.getKitInfoFromParent(methodInfo));
|
||||||
if (jsDocInfos.length === 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const jsDoc: Comment.JsDocInfo = jsDocInfos[jsDocInfos.length - 1];
|
const jsDoc: Comment.JsDocInfo = jsDocInfos[jsDocInfos.length - 1];
|
||||||
jsDoc.removeTags()
|
jsDoc.removeTags();
|
||||||
if (isParam) {
|
if (isParam) {
|
||||||
paramInfo.addTypeLocations(jsDoc)
|
paramInfo.addTypeLocations(jsDoc);
|
||||||
} else {
|
} else {
|
||||||
methodInfo.addTypeLocations(jsDoc)
|
methodInfo.addTypeLocations(jsDoc);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
} finally {
|
} finally {
|
||||||
@ -713,20 +716,22 @@ export class NodeProcessorHelper {
|
|||||||
* true:类型为参数(入参)的数据
|
* true:类型为参数(入参)的数据
|
||||||
* false:类型为返回值(出参)的数据
|
* false:类型为返回值(出参)的数据
|
||||||
*/
|
*/
|
||||||
static processFunctionTypeObject(typeObject: ts.TypeLiteralNode, methodInfo: MethodInfo, paramInfo: ParamInfo, isParam: boolean = true) {
|
static processFunctionTypeObject(typeObject: ts.TypeLiteralNode, methodInfo: MethodInfo, paramInfo: ParamInfo,
|
||||||
typeObject.members.forEach(((member: ts.TypeElement) => {
|
isParam: boolean = true): void {
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = JsDocProcessorHelper.processJsDocInfos(member, ApiType.TYPE_ALIAS, methodInfo.getKitInfoFromParent(methodInfo));
|
typeObject.members.forEach((member: ts.TypeElement) => {
|
||||||
|
const jsDocInfos: Comment.JsDocInfo[] = JsDocProcessorHelper.processJsDocInfos(member, ApiType.TYPE_ALIAS,
|
||||||
|
methodInfo.getKitInfoFromParent(methodInfo));
|
||||||
if (jsDocInfos.length === 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const jsDoc: Comment.JsDocInfo = jsDocInfos[jsDocInfos.length - 1];
|
const jsDoc: Comment.JsDocInfo = jsDocInfos[jsDocInfos.length - 1];
|
||||||
jsDoc.removeTags()
|
jsDoc.removeTags();
|
||||||
if (isParam) {
|
if (isParam) {
|
||||||
paramInfo.addObjLocations(jsDoc)
|
paramInfo.addObjLocations(jsDoc);
|
||||||
} else {
|
} else {
|
||||||
methodInfo.addObjLocations(jsDoc)
|
methodInfo.addObjLocations(jsDoc);
|
||||||
}
|
}
|
||||||
}))
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,7 +251,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.PropertyInfo[] = [];
|
const infos: ResultsInfo.PropertyInfo[] = [];
|
||||||
const propertyInfo: PropertyInfo = apiInfo as PropertyInfo;
|
const propertyInfo: PropertyInfo = apiInfo as PropertyInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = propertyInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = propertyInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.PropertyInfo = new ResultsInfo.PropertyInfo(
|
const newInfo: ResultsInfo.PropertyInfo = new ResultsInfo.PropertyInfo(
|
||||||
apiInfo.getApiType(),
|
apiInfo.getApiType(),
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
@ -281,7 +281,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.ClassInterfaceInfo[] = [];
|
const infos: ResultsInfo.ClassInterfaceInfo[] = [];
|
||||||
const classInfo: ClassInfo = apiInfo as ClassInfo;
|
const classInfo: ClassInfo = apiInfo as ClassInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = classInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = classInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.ClassInterfaceInfo = new ResultsInfo.ClassInterfaceInfo(
|
const newInfo: ResultsInfo.ClassInterfaceInfo = new ResultsInfo.ClassInterfaceInfo(
|
||||||
apiInfo.getApiType(),
|
apiInfo.getApiType(),
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
@ -306,7 +306,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.ClassInterfaceInfo[] = [];
|
const infos: ResultsInfo.ClassInterfaceInfo[] = [];
|
||||||
const interfaceInfo: InterfaceInfo = apiInfo as InterfaceInfo;
|
const interfaceInfo: InterfaceInfo = apiInfo as InterfaceInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = interfaceInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = interfaceInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.ClassInterfaceInfo = new ResultsInfo.ClassInterfaceInfo(
|
const newInfo: ResultsInfo.ClassInterfaceInfo = new ResultsInfo.ClassInterfaceInfo(
|
||||||
apiInfo.getApiType(),
|
apiInfo.getApiType(),
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
@ -331,7 +331,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.NamespaceEnumInfo[] = [];
|
const infos: ResultsInfo.NamespaceEnumInfo[] = [];
|
||||||
const interfaceInfo: NamespaceInfo = apiInfo as NamespaceInfo;
|
const interfaceInfo: NamespaceInfo = apiInfo as NamespaceInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = interfaceInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = interfaceInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.NamespaceEnumInfo = new ResultsInfo.NamespaceEnumInfo(
|
const newInfo: ResultsInfo.NamespaceEnumInfo = new ResultsInfo.NamespaceEnumInfo(
|
||||||
apiInfo.getApiType(),
|
apiInfo.getApiType(),
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
@ -351,7 +351,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.MethodInfo[] = [];
|
const infos: ResultsInfo.MethodInfo[] = [];
|
||||||
const methodInfo: MethodInfo = apiInfo as MethodInfo;
|
const methodInfo: MethodInfo = apiInfo as MethodInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = methodInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = methodInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.MethodInfo = new ResultsInfo.MethodInfo(apiInfo.getApiType(), new Comment.JsDocInfo());
|
const newInfo: ResultsInfo.MethodInfo = new ResultsInfo.MethodInfo(apiInfo.getApiType(), new Comment.JsDocInfo());
|
||||||
newInfo.setName(apiInfo.getApiName());
|
newInfo.setName(apiInfo.getApiName());
|
||||||
newInfo.setCallForm(methodInfo.getCallForm());
|
newInfo.setCallForm(methodInfo.getCallForm());
|
||||||
@ -407,7 +407,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.ConstantInfo[] = [];
|
const infos: ResultsInfo.ConstantInfo[] = [];
|
||||||
const constantInfo: ConstantInfo = apiInfo as ConstantInfo;
|
const constantInfo: ConstantInfo = apiInfo as ConstantInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = constantInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = constantInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.ConstantInfo = new ResultsInfo.ConstantInfo(
|
const newInfo: ResultsInfo.ConstantInfo = new ResultsInfo.ConstantInfo(
|
||||||
apiInfo.getApiType(),
|
apiInfo.getApiType(),
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
@ -443,7 +443,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.DeclareConstInfo[] = [];
|
const infos: ResultsInfo.DeclareConstInfo[] = [];
|
||||||
const constantInfo: ConstantInfo = apiInfo as ConstantInfo;
|
const constantInfo: ConstantInfo = apiInfo as ConstantInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = constantInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = constantInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.DeclareConstInfo = new ResultsInfo.DeclareConstInfo(
|
const newInfo: ResultsInfo.DeclareConstInfo = new ResultsInfo.DeclareConstInfo(
|
||||||
apiInfo.getApiType(),
|
apiInfo.getApiType(),
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
@ -475,7 +475,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.NamespaceEnumInfo[] = [];
|
const infos: ResultsInfo.NamespaceEnumInfo[] = [];
|
||||||
const enumInfo: EnumInfo = apiInfo as EnumInfo;
|
const enumInfo: EnumInfo = apiInfo as EnumInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = enumInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = enumInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.NamespaceEnumInfo = new ResultsInfo.NamespaceEnumInfo(
|
const newInfo: ResultsInfo.NamespaceEnumInfo = new ResultsInfo.NamespaceEnumInfo(
|
||||||
apiInfo.getApiType(),
|
apiInfo.getApiType(),
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
@ -495,7 +495,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.EnumValueInfo[] = [];
|
const infos: ResultsInfo.EnumValueInfo[] = [];
|
||||||
const enumValueInfo: EnumValueInfo = apiInfo as EnumValueInfo;
|
const enumValueInfo: EnumValueInfo = apiInfo as EnumValueInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = enumValueInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = enumValueInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.EnumValueInfo = new ResultsInfo.EnumValueInfo(
|
const newInfo: ResultsInfo.EnumValueInfo = new ResultsInfo.EnumValueInfo(
|
||||||
apiInfo.getApiType(),
|
apiInfo.getApiType(),
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
@ -517,7 +517,7 @@ export class ResultsProcessHelper {
|
|||||||
const infos: ResultsInfo.BasicApiInfo[] = [];
|
const infos: ResultsInfo.BasicApiInfo[] = [];
|
||||||
const typeAliasInfo: TypeAliasInfo = apiInfo as TypeAliasInfo;
|
const typeAliasInfo: TypeAliasInfo = apiInfo as TypeAliasInfo;
|
||||||
const jsDocInfos: Comment.JsDocInfo[] = typeAliasInfo.getJsDocInfos();
|
const jsDocInfos: Comment.JsDocInfo[] = typeAliasInfo.getJsDocInfos();
|
||||||
if (jsDocInfos.length == 0) {
|
if (jsDocInfos.length === 0) {
|
||||||
const newInfo: ResultsInfo.BasicApiInfo = ResultsProcessHelper.processTypeAliasGetNewInfo(
|
const newInfo: ResultsInfo.BasicApiInfo = ResultsProcessHelper.processTypeAliasGetNewInfo(
|
||||||
typeAliasInfo,
|
typeAliasInfo,
|
||||||
new Comment.JsDocInfo()
|
new Comment.JsDocInfo()
|
||||||
|
@ -46,15 +46,15 @@ export class Parser {
|
|||||||
parserParam.setRootNames(files);
|
parserParam.setRootNames(files);
|
||||||
}
|
}
|
||||||
const apiMap: FilesMap = new Map();
|
const apiMap: FilesMap = new Map();
|
||||||
let collectFiles: Array<string> = []
|
let collectFiles: Array<string> = [];
|
||||||
if (collectFile == '') {
|
if (collectFile === '') {
|
||||||
collectFiles = files;
|
collectFiles = files;
|
||||||
} else if (FileUtils.isDirectory(collectFile)) {
|
} else if (FileUtils.isDirectory(collectFile)) {
|
||||||
collectFiles = FileUtils.readFilesInDir(collectFile, (name) => {
|
collectFiles = FileUtils.readFilesInDir(collectFile, (name) => {
|
||||||
return name.endsWith(StringConstant.DTS_EXTENSION) || name.endsWith(StringConstant.DETS_EXTENSION);
|
return name.endsWith(StringConstant.DTS_EXTENSION) || name.endsWith(StringConstant.DETS_EXTENSION);
|
||||||
});
|
});
|
||||||
} else if (FileUtils.isFile(collectFile)) {
|
} else if (FileUtils.isFile(collectFile)) {
|
||||||
collectFiles = [collectFile]
|
collectFiles = [collectFile];
|
||||||
}
|
}
|
||||||
collectFiles.forEach((filePath: string) => {
|
collectFiles.forEach((filePath: string) => {
|
||||||
Parser.parseFile(fileDir, filePath, apiMap);
|
Parser.parseFile(fileDir, filePath, apiMap);
|
||||||
@ -88,9 +88,9 @@ export class Parser {
|
|||||||
const fileArr: Array<string> = [filePath];
|
const fileArr: Array<string> = [filePath];
|
||||||
sourceFile.statements.forEach((statement: ts.Statement) => {
|
sourceFile.statements.forEach((statement: ts.Statement) => {
|
||||||
if (ts.isImportDeclaration(statement) && statement.moduleSpecifier.getText().startsWith('./', 1)) {
|
if (ts.isImportDeclaration(statement) && statement.moduleSpecifier.getText().startsWith('./', 1)) {
|
||||||
fileArr.push(path.resolve(filePath, '..', statement.moduleSpecifier.getText().replace(/'|"/g, '')))
|
fileArr.push(path.resolve(filePath, '..', statement.moduleSpecifier.getText().replace(/'|"/g, '')));
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
if (Boolean(process.env.NEED_DETECTION)) {
|
if (Boolean(process.env.NEED_DETECTION)) {
|
||||||
parserParam.setProgram(fileArr);
|
parserParam.setProgram(fileArr);
|
||||||
}
|
}
|
||||||
|
@ -197,8 +197,8 @@ export class ApiResultSimpleInfo {
|
|||||||
filePath: string = '';
|
filePath: string = '';
|
||||||
location: string = '';
|
location: string = '';
|
||||||
message: string = '';
|
message: string = '';
|
||||||
type:string='';
|
type: string = '';
|
||||||
apiText:string='';
|
apiText: string = '';
|
||||||
|
|
||||||
setID(id: number): ApiResultSimpleInfo {
|
setID(id: number): ApiResultSimpleInfo {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -91,7 +91,7 @@ export class BasicApiInfo {
|
|||||||
return this.node;
|
return this.node;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeNode() {
|
removeNode(): void {
|
||||||
this.node = undefined;
|
this.node = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ export class BasicApiInfo {
|
|||||||
return this.jsDocText;
|
return this.jsDocText;
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsJoinType(jsJoinType: boolean) {
|
setIsJoinType(jsJoinType: boolean): void {
|
||||||
this.isJoinType = jsJoinType;
|
this.isJoinType = jsJoinType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,7 +597,7 @@ export class MethodInfo extends ApiInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTypeLocations(typeLocation: Comment.JsDocInfo): void {
|
addTypeLocations(typeLocation: Comment.JsDocInfo): void {
|
||||||
this.typeLocations.push(typeLocation)
|
this.typeLocations.push(typeLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTypeLocations(): Comment.JsDocInfo[] {
|
getTypeLocations(): Comment.JsDocInfo[] {
|
||||||
@ -605,7 +605,7 @@ export class MethodInfo extends ApiInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addObjLocations(ObjLocation: Comment.JsDocInfo): void {
|
addObjLocations(ObjLocation: Comment.JsDocInfo): void {
|
||||||
this.objLocations.push(ObjLocation)
|
this.objLocations.push(ObjLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
getObjLocations(): Comment.JsDocInfo[] {
|
getObjLocations(): Comment.JsDocInfo[] {
|
||||||
@ -639,7 +639,7 @@ export class ParamInfo {
|
|||||||
return this.apiType;
|
return this.apiType;
|
||||||
}
|
}
|
||||||
|
|
||||||
setApiName(apiName: string) {
|
setApiName(apiName: string): void {
|
||||||
this.apiName = apiName;
|
this.apiName = apiName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,7 +680,7 @@ export class ParamInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTypeLocations(typeLocation: Comment.JsDocInfo): void {
|
addTypeLocations(typeLocation: Comment.JsDocInfo): void {
|
||||||
this.typeLocations.push(typeLocation)
|
this.typeLocations.push(typeLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTypeLocations(): Comment.JsDocInfo[] {
|
getTypeLocations(): Comment.JsDocInfo[] {
|
||||||
@ -688,7 +688,7 @@ export class ParamInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addObjLocations(ObjLocation: Comment.JsDocInfo): void {
|
addObjLocations(ObjLocation: Comment.JsDocInfo): void {
|
||||||
this.objLocations.push(ObjLocation)
|
this.objLocations.push(ObjLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
getObjLocations(): Comment.JsDocInfo[] {
|
getObjLocations(): Comment.JsDocInfo[] {
|
||||||
@ -700,18 +700,18 @@ export class GenericInfo {
|
|||||||
isGenericity: boolean = false;
|
isGenericity: boolean = false;
|
||||||
genericContent: string = '';
|
genericContent: string = '';
|
||||||
|
|
||||||
setIsGenericity(isGenericity: boolean) {
|
setIsGenericity(isGenericity: boolean): void {
|
||||||
this.isGenericity = isGenericity;
|
this.isGenericity = isGenericity;
|
||||||
}
|
}
|
||||||
getIsGenericity() {
|
getIsGenericity(): boolean {
|
||||||
return this.isGenericity;
|
return this.isGenericity;
|
||||||
}
|
}
|
||||||
|
|
||||||
setGenericContent(genericContent: string) {
|
setGenericContent(genericContent: string): void {
|
||||||
this.genericContent = genericContent;
|
this.genericContent = genericContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
getGenericContent() {
|
getGenericContent(): string {
|
||||||
return this.genericContent;
|
return this.genericContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -752,7 +752,7 @@ export class ParserParam {
|
|||||||
return this.fileDir;
|
return this.fileDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFileDir(fileDir: string) {
|
setFileDir(fileDir: string): void {
|
||||||
this.fileDir = fileDir;
|
this.fileDir = fileDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,7 +760,7 @@ export class ParserParam {
|
|||||||
return this.filePath;
|
return this.filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFilePath(filePath: string) {
|
setFilePath(filePath: string): void {
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,7 +768,7 @@ export class ParserParam {
|
|||||||
return this.sdkPath;
|
return this.sdkPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSdkPath(sdkPath: string) {
|
setSdkPath(sdkPath: string): void {
|
||||||
this.sdkPath = sdkPath;
|
this.sdkPath = sdkPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,7 +776,7 @@ export class ParserParam {
|
|||||||
return this.rootNames;
|
return this.rootNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
setRootNames(rootNames: string[]) {
|
setRootNames(rootNames: string[]): void {
|
||||||
this.rootNames = rootNames;
|
this.rootNames = rootNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,14 +784,14 @@ export class ParserParam {
|
|||||||
return this.tsProgram;
|
return this.tsProgram;
|
||||||
}
|
}
|
||||||
|
|
||||||
getETSOptions(componentLibs: Array<string>) {
|
getETSOptions(componentLibs: Array<string>): any {
|
||||||
const tsconfig = require('../../config/tsconfig.json');
|
const tsconfig = require('../../config/tsconfig.json');
|
||||||
const etsConfig = tsconfig.compilerOptions.ets;
|
const etsConfig = tsconfig.compilerOptions.ets;
|
||||||
etsConfig.libs = [...componentLibs];
|
etsConfig.libs = [...componentLibs];
|
||||||
return etsConfig;
|
return etsConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgram(apiLibs: Array<string>) {
|
setProgram(apiLibs: Array<string>): void {
|
||||||
const compilerOption = {
|
const compilerOption = {
|
||||||
target: ts.ScriptTarget.ES2017,
|
target: ts.ScriptTarget.ES2017,
|
||||||
ets: this.getETSOptions([]),
|
ets: this.getETSOptions([]),
|
||||||
@ -802,7 +802,7 @@ export class ParserParam {
|
|||||||
this.tsProgram = ts.createProgram({
|
this.tsProgram = ts.createProgram({
|
||||||
rootNames: [...apiLibs, ...this.rootNames],
|
rootNames: [...apiLibs, ...this.rootNames],
|
||||||
options: compilerOption
|
options: compilerOption
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@ export class ApiInfo extends BasicApiInfo {
|
|||||||
this.isCrossPlatForm = jsDocInfo.getIsCrossPlatForm();
|
this.isCrossPlatForm = jsDocInfo.getIsCrossPlatForm();
|
||||||
this.isSystemApi = jsDocInfo.getIsSystemApi();
|
this.isSystemApi = jsDocInfo.getIsSystemApi();
|
||||||
this.isStageModelOnly = jsDocInfo.getModelLimitation().toLowerCase() === StringConstant.STAGE_MODEL_ONLY;
|
this.isStageModelOnly = jsDocInfo.getModelLimitation().toLowerCase() === StringConstant.STAGE_MODEL_ONLY;
|
||||||
// jsDocInfo.getIsStageModelOnly();
|
|
||||||
this.isFaModelOnly = jsDocInfo.getModelLimitation().toLowerCase() === StringConstant.FA_MODEL_ONLY;
|
this.isFaModelOnly = jsDocInfo.getModelLimitation().toLowerCase() === StringConstant.FA_MODEL_ONLY;
|
||||||
this.deprecatedVersion = jsDocInfo.getDeprecatedVersion();
|
this.deprecatedVersion = jsDocInfo.getDeprecatedVersion();
|
||||||
this.useinstead = jsDocInfo.getUseinstead();
|
this.useinstead = jsDocInfo.getUseinstead();
|
||||||
|
@ -22,10 +22,10 @@ export class EnumUtils {
|
|||||||
* @return { any[] }
|
* @return { any[] }
|
||||||
* @memberof EnumUtils
|
* @memberof EnumUtils
|
||||||
*/
|
*/
|
||||||
static enum2arr(valueEnum: any[] | Record<string, any>) {
|
static enum2arr(valueEnum: any[] | Record<string, any>): any[] {
|
||||||
let values: any[] = Array.isArray(valueEnum) ? valueEnum : Object.values(valueEnum);
|
let values: any[] = Array.isArray(valueEnum) ? valueEnum : Object.values(valueEnum);
|
||||||
// 如果 enum 值为 number 类型,ts 生成的 js 对象会同时包含枚举的名称,针对该情形需提出枚举名称
|
// 如果 enum 值为 number 类型,ts 生成的 js 对象会同时包含枚举的名称,针对该情形需提出枚举名称
|
||||||
const hasNum = values.some((v) => typeof v === 'number');
|
const hasNum: boolean = values.some((v) => typeof v === 'number');
|
||||||
if (hasNum) {
|
if (hasNum) {
|
||||||
values = values.filter((v) => typeof v === 'number');
|
values = values.filter((v) => typeof v === 'number');
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import ts, { LineAndCharacter } from 'typescript';
|
|||||||
import { ApiResultSimpleInfo, ApiResultInfo, ApiResultMessage } from '../typedef/checker/result_type';
|
import { ApiResultSimpleInfo, ApiResultInfo, ApiResultMessage } from '../typedef/checker/result_type';
|
||||||
import { ApiInfo, ClassInfo, ParentClass } from '../typedef/parser/ApiInfoDefination';
|
import { ApiInfo, ClassInfo, ParentClass } from '../typedef/parser/ApiInfoDefination';
|
||||||
import { FileUtils } from './FileUtils';
|
import { FileUtils } from './FileUtils';
|
||||||
import { ApiCheckVersion } from '../coreImpl/checker/config/api_check_version.json'
|
import { ApiCheckVersion } from '../coreImpl/checker/config/api_check_version.json';
|
||||||
|
|
||||||
|
|
||||||
export class PosOfNode {
|
export class PosOfNode {
|
||||||
@ -157,10 +157,8 @@ export class ObtainFullPath {
|
|||||||
const status: Stats = fs.statSync(filePath);
|
const status: Stats = fs.statSync(filePath);
|
||||||
if (status.isDirectory()) {
|
if (status.isDirectory()) {
|
||||||
ObtainFullPath.getFullFiles(filePath, utFiles);
|
ObtainFullPath.getFullFiles(filePath, utFiles);
|
||||||
} else {
|
} else if (/\.d\.ts/.test(filePath) || /\.d\.ets/.test(filePath) || /\.ts/.test(filePath)) {
|
||||||
if (/\.d\.ts/.test(filePath) || /\.d\.ets/.test(filePath) || /\.ts/.test(filePath)) {
|
utFiles.push(filePath);
|
||||||
utFiles.push(filePath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -34,25 +34,25 @@ export class LogLevelUtil {
|
|||||||
export class LogUtil {
|
export class LogUtil {
|
||||||
static logLevel: LogLevel = process.env.NODE_ENV === 'development' ? LogLevel.DEBUG : LogLevel.ERR;
|
static logLevel: LogLevel = process.env.NODE_ENV === 'development' ? LogLevel.DEBUG : LogLevel.ERR;
|
||||||
|
|
||||||
static e(tag: string, message?: any) {
|
static e(tag: string, message?: any): void {
|
||||||
if (LogUtil.logLevel <= LogLevel.ERR) {
|
if (LogUtil.logLevel <= LogLevel.ERR) {
|
||||||
console.error(`${tag}: ${message}`);
|
console.error(`${tag}: ${message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static w(tag: string, message?: any) {
|
static w(tag: string, message?: any): void {
|
||||||
if (LogUtil.logLevel <= LogLevel.WARN) {
|
if (LogUtil.logLevel <= LogLevel.WARN) {
|
||||||
console.warn(`${tag}: ${message}`);
|
console.warn(`${tag}: ${message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static i(tag: string, message?: any) {
|
static i(tag: string, message?: any): void {
|
||||||
if (LogUtil.logLevel <= LogLevel.INFO) {
|
if (LogUtil.logLevel <= LogLevel.INFO) {
|
||||||
console.info(`${tag}: ${message}`);
|
console.info(`${tag}: ${message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static d(tag: string, message?: any) {
|
static d(tag: string, message?: any): void {
|
||||||
if (LogUtil.logLevel <= LogLevel.DEBUG) {
|
if (LogUtil.logLevel <= LogLevel.DEBUG) {
|
||||||
console.debug(`${tag}: ${message}`);
|
console.debug(`${tag}: ${message}`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user