mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-11-23 15:20:17 +00:00
js api_diff工具适配新规则
Signed-off-by: wangqing <wangqing136@huawei.com>
This commit is contained in:
parent
6303194c8b
commit
871ac73d68
@ -39,14 +39,12 @@ import {
|
|||||||
diffMap,
|
diffMap,
|
||||||
incompatibleApiDiffTypes,
|
incompatibleApiDiffTypes,
|
||||||
JsDocDiffProcessor,
|
JsDocDiffProcessor,
|
||||||
parentApiTypeSet,
|
|
||||||
} from '../../typedef/diff/ApiInfoDiff';
|
} from '../../typedef/diff/ApiInfoDiff';
|
||||||
import { StringUtils } from '../../utils/StringUtils';
|
import { StringUtils } from '../../utils/StringUtils';
|
||||||
import { CharMapType, CompareReturnObjType, PermissionsProcessorHelper, RangeChange } from './PermissionsProcessor';
|
import { CharMapType, CompareReturnObjType, PermissionsProcessorHelper, RangeChange } from './PermissionsProcessor';
|
||||||
import { DecoratorInfo } from '../../typedef/parser/Decorator';
|
import { DecoratorInfo } from '../../typedef/parser/Decorator';
|
||||||
import { CommonFunctions } from '../../utils/checkUtils';
|
import { CommonFunctions } from '../../utils/checkUtils';
|
||||||
import { NumberConstant } from '../../utils/Constant';
|
import { NumberConstant } from '../../utils/Constant';
|
||||||
import { CommentHelper } from '../parser/JsDocProcessor';
|
|
||||||
|
|
||||||
export namespace DiffProcessorHelper {
|
export namespace DiffProcessorHelper {
|
||||||
/**
|
/**
|
||||||
@ -1641,14 +1639,15 @@ export namespace DiffProcessorHelper {
|
|||||||
oldApiInfo: BasicApiInfo | undefined = undefined,
|
oldApiInfo: BasicApiInfo | undefined = undefined,
|
||||||
newApiInfo: BasicApiInfo | undefined = undefined,
|
newApiInfo: BasicApiInfo | undefined = undefined,
|
||||||
diffTypeInfo: DiffTypeInfo,
|
diffTypeInfo: DiffTypeInfo,
|
||||||
isSameNameFunction?: boolean
|
isSameNameFunction?: boolean,
|
||||||
|
isNewFile?: boolean
|
||||||
): BasicDiffInfo {
|
): BasicDiffInfo {
|
||||||
const newPropertyInfo = newApiInfo as PropertyInfo;
|
const newPropertyInfo = newApiInfo as PropertyInfo;
|
||||||
const newMethodInfo = newApiInfo as MethodInfo;
|
const newMethodInfo = newApiInfo as MethodInfo;
|
||||||
const parentApiType: string = (newApiInfo && newApiInfo.getParentApiType()) ? newApiInfo.getParentApiType() : '';
|
const parentApiType: string = (newApiInfo && newApiInfo.getParentApiType()) ? newApiInfo.getParentApiType() : '';
|
||||||
let isCompatible = true;
|
let isCompatible = true;
|
||||||
if (
|
if (
|
||||||
parentApiTypeSet.has(parentApiType) &&
|
!isNewFile && parentApiType === ApiType.INTERFACE &&
|
||||||
diffTypeInfo.getDiffType() === ApiDiffType.ADD &&
|
diffTypeInfo.getDiffType() === ApiDiffType.ADD &&
|
||||||
((newApiInfo?.getApiType() === ApiType.METHOD && newMethodInfo.getIsRequired()) ||
|
((newApiInfo?.getApiType() === ApiType.METHOD && newMethodInfo.getIsRequired()) ||
|
||||||
(newApiInfo?.getApiType() === ApiType.PROPERTY && newPropertyInfo.getIsRequired()))
|
(newApiInfo?.getApiType() === ApiType.PROPERTY && newPropertyInfo.getIsRequired()))
|
||||||
|
@ -53,6 +53,8 @@ export class DiffHelper {
|
|||||||
const oldSDKApiLocations: Map<string, string[]> = DiffHelper.getApiLocations(clonedOldSDKApiMap, isCheck);
|
const oldSDKApiLocations: Map<string, string[]> = DiffHelper.getApiLocations(clonedOldSDKApiMap, isCheck);
|
||||||
const newSDKApiLocations: Map<string, string[]> = DiffHelper.getApiLocations(clonedNewSDKApiMap, isCheck);
|
const newSDKApiLocations: Map<string, string[]> = DiffHelper.getApiLocations(clonedNewSDKApiMap, isCheck);
|
||||||
DiffHelper.diffKit(clonedOldSDKApiMap, clonedNewSDKApiMap, diffInfos);
|
DiffHelper.diffKit(clonedOldSDKApiMap, clonedNewSDKApiMap, diffInfos);
|
||||||
|
const oldFilePathSet: Set<string> = new Set(Array.from(clonedOldSDKApiMap.keys()));
|
||||||
|
Array.from(clonedOldSDKApiMap.keys())
|
||||||
// 先以旧版本为基础进行对比
|
// 先以旧版本为基础进行对比
|
||||||
for (const key of oldSDKApiLocations.keys()) {
|
for (const key of oldSDKApiLocations.keys()) {
|
||||||
const apiLocation: string[] = oldSDKApiLocations.get(key) as string[];
|
const apiLocation: string[] = oldSDKApiLocations.get(key) as string[];
|
||||||
@ -81,11 +83,17 @@ export class DiffHelper {
|
|||||||
const locations: string[] = newSDKApiLocations.get(key) as string[];
|
const locations: string[] = newSDKApiLocations.get(key) as string[];
|
||||||
const newApiInfos: ApiInfo[] = Parser.getApiInfo(locations, clonedNewSDKApiMap) as ApiInfo[];
|
const newApiInfos: ApiInfo[] = Parser.getApiInfo(locations, clonedNewSDKApiMap) as ApiInfo[];
|
||||||
newApiInfos.forEach((newApiInfo: ApiInfo) => {
|
newApiInfos.forEach((newApiInfo: ApiInfo) => {
|
||||||
|
let isNewFile: boolean = true;
|
||||||
|
if (oldFilePathSet.has(newApiInfo.getFilePath())) {
|
||||||
|
isNewFile = false;
|
||||||
|
}
|
||||||
diffInfos.push(
|
diffInfos.push(
|
||||||
DiffProcessorHelper.wrapDiffInfo(
|
DiffProcessorHelper.wrapDiffInfo(
|
||||||
undefined,
|
undefined,
|
||||||
newApiInfo,
|
newApiInfo,
|
||||||
new DiffTypeInfo(ApiStatusCode.NEW_API, ApiDiffType.ADD, undefined, newApiInfo.getDefinedText())
|
new DiffTypeInfo(ApiStatusCode.NEW_API, ApiDiffType.ADD, undefined, newApiInfo.getDefinedText()),
|
||||||
|
false,
|
||||||
|
isNewFile
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -1007,12 +1007,3 @@ export const isNotApiSet: Set<string> = new Set([
|
|||||||
ApiType.ENUM,
|
ApiType.ENUM,
|
||||||
ApiType.SOURCE_FILE,
|
ApiType.SOURCE_FILE,
|
||||||
])
|
])
|
||||||
|
|
||||||
/**
|
|
||||||
* 以下API类型中新增必选属性/方法都是非兼容性变更
|
|
||||||
*/
|
|
||||||
export const parentApiTypeSet: Set<string> = new Set([
|
|
||||||
ApiType.INTERFACE,
|
|
||||||
ApiType.STRUCT,
|
|
||||||
ApiType.CLASS
|
|
||||||
])
|
|
||||||
|
Loading…
Reference in New Issue
Block a user