mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-11-27 09:22:53 +00:00
commit
54de39f9ce
@ -20,7 +20,7 @@ import { FileUtils } from '../utils/FileUtils';
|
||||
import { LogUtil } from '../utils/logUtil';
|
||||
import { FilesMap, Parser } from '../coreImpl/parser/parser';
|
||||
import { DiffHelper } from '../coreImpl/diff/diff';
|
||||
import { BasicDiffInfo, diffTypeMap } from '../typedef/diff/ApiInfoDiff';
|
||||
import { BasicDiffInfo, diffTypeMap, ApiDiffType } from '../typedef/diff/ApiInfoDiff';
|
||||
import { WriterHelper } from './writer';
|
||||
import { LocalEntry } from '../coreImpl/checker/local_entry';
|
||||
import { ApiResultSimpleInfo } from '../typedef/checker/result_type';
|
||||
@ -210,7 +210,7 @@ function collectApi(options: OptionObjType): ToolNameValueType {
|
||||
return {
|
||||
data:
|
||||
options.format === 'excel' ?
|
||||
ApiStatisticsHelper.getApiStatisticsInfos(allApis).apiStatisticsInfos :
|
||||
ApiStatisticsHelper.getApiStatisticsInfos(allApis).apiStatisticsInfos :
|
||||
[fileContent],
|
||||
callback: collectApiCallback as ToolNameExcelCallback,
|
||||
};
|
||||
@ -378,22 +378,26 @@ function diffApiCallback(data: BasicDiffInfo[], sheet: ExcelJS.Worksheet, dest?:
|
||||
}
|
||||
|
||||
export function joinOldMessage(diffInfo: BasicDiffInfo): string {
|
||||
if (!diffInfo.getOldDescription()) {
|
||||
if (diffInfo.getDiffMessage() === diffTypeMap.get(ApiDiffType.ADD)) {
|
||||
return 'NA';
|
||||
}
|
||||
let oldDescription: string = '';
|
||||
const relation: string[] = diffInfo.getOldHierarchicalRelations();
|
||||
const parentModuleName: string = diffInfo.getParentModuleName(relation);
|
||||
const oldDescription = diffInfo.getOldDescription() === '-1' ? 'NA' : diffInfo.getOldDescription();
|
||||
oldDescription =
|
||||
diffInfo.getOldDescription() === '-1' || !diffInfo.getOldDescription() ? 'NA' : diffInfo.getOldDescription();
|
||||
return `类名:${parentModuleName};\n` + `API声明:${diffInfo.getOldApiDefinedText()}\n差异内容:${oldDescription}`;
|
||||
}
|
||||
|
||||
export function joinNewMessage(diffInfo: BasicDiffInfo): string {
|
||||
if (!diffInfo.getNewDescription()) {
|
||||
if (diffInfo.getDiffMessage() === diffTypeMap.get(ApiDiffType.REDUCE)) {
|
||||
return 'NA';
|
||||
}
|
||||
let newDescription: string = '';
|
||||
const relation: string[] = diffInfo.getNewHierarchicalRelations();
|
||||
const parentModuleName: string = diffInfo.getParentModuleName(relation);
|
||||
const newDescription = diffInfo.getOldDescription() === '-1' ? 'NA' : diffInfo.getNewDescription();
|
||||
newDescription =
|
||||
diffInfo.getOldDescription() === '-1' || !diffInfo.getNewDescription() ? 'NA' : diffInfo.getNewDescription();
|
||||
return `类名:${parentModuleName};\n` + `API声明:${diffInfo.getNewApiDefinedText()}\n差异内容:${newDescription}`;
|
||||
}
|
||||
|
||||
|
@ -84,13 +84,24 @@ export namespace DiffProcessorHelper {
|
||||
}
|
||||
}
|
||||
|
||||
static getFirstSinceVersion(jsDocInfos: Comment.JsDocInfo[]): string {
|
||||
let sinceVersion: string = '';
|
||||
for (let i = 0; i < jsDocInfos.length; i++) {
|
||||
const jsDocInfo: Comment.JsDocInfo = jsDocInfos[i];
|
||||
if (jsDocInfo.getSince() !== '-1') {
|
||||
sinceVersion = jsDocInfo.getSince();
|
||||
return sinceVersion;
|
||||
}
|
||||
}
|
||||
return sinceVersion;
|
||||
}
|
||||
|
||||
static diffSinceVersion(oldApiInfo: ApiInfo, newApiInfo: ApiInfo, diffInfos: BasicDiffInfo[]): void {
|
||||
const diffTypeInfo: DiffTypeInfo = new DiffTypeInfo();
|
||||
const oldFirstJsDocInfo: Comment.JsDocInfo | undefined = oldApiInfo.getJsDocInfos()[0];
|
||||
const newFirstJsDocInfo: Comment.JsDocInfo | undefined = newApiInfo.getJsDocInfos()[0];
|
||||
const sinceVersionOfOld: string = oldFirstJsDocInfo ? oldFirstJsDocInfo.getSince() : '-1';
|
||||
const sinceVersionOfNew: string = newFirstJsDocInfo ? newFirstJsDocInfo.getSince() : '-1';
|
||||
|
||||
const oldJsDocInfos: Comment.JsDocInfo[] = oldApiInfo.getJsDocInfos();
|
||||
const newJsDocInfos: Comment.JsDocInfo[] = newApiInfo.getJsDocInfos();
|
||||
const sinceVersionOfOld: string = JsDocDiffHelper.getFirstSinceVersion(oldJsDocInfos);
|
||||
const sinceVersionOfNew: string = JsDocDiffHelper.getFirstSinceVersion(newJsDocInfos);
|
||||
diffTypeInfo
|
||||
.setStatusCode(ApiStatusCode.VERSION_CHNAGES)
|
||||
.setOldMessage(sinceVersionOfOld)
|
||||
@ -586,8 +597,8 @@ export namespace DiffProcessorHelper {
|
||||
const diffTypeInfo: DiffTypeInfo = new DiffTypeInfo();
|
||||
const olaMethodType: string[] = oldApiInfo.getReturnValue();
|
||||
const newMethodType: string[] = newApiInfo.getReturnValue();
|
||||
const olaMethodTypeStr = olaMethodType.toString();
|
||||
const newMethodTypeStr = newMethodType.toString();
|
||||
const olaMethodTypeStr = olaMethodType.toString().replace(/\r|\n|\s+/g, '');
|
||||
const newMethodTypeStr = newMethodType.toString().replace(/\r|\n|\s+/g, '');
|
||||
if (olaMethodTypeStr === newMethodTypeStr) {
|
||||
return undefined;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user