• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15const result = require("../check_result.json");
16
17// print compile info
18function addAPICheckErrorLogs(node, sourcefile, fileName, errorType, errorInfo) {
19  const checkFailFileNameSet = new Set(result.apiFiles);
20    if (!checkFailFileNameSet.has(fileName)) {
21      result.apiFiles.push(fileName);
22    }
23    const posOfNode = sourcefile.getLineAndCharacterOfPosition(node.pos);
24    // const errorMessage = {
25    //   "error_type": "misspell words",
26    //   "file": fileName,
27    //   "pos": node.pos,
28    //   "column": posOfNode.character + 1,
29    //   "line": posOfNode.line + 1,
30    //   "error_info": `Error basic words in [${nodeText}]: ${errorWords}. ` +
31    //     `Do you want to spell it as [${suggest}]?`
32    // };
33    const errorMessage = `API check error of [${errorType}] in ${fileName}(line:${posOfNode.line + 1}, col:` +
34      `${posOfNode.character + 1}): ${errorInfo}`;
35    const scanResultSet = new Set(result.scanResult);
36    scanResultSet.add(errorMessage);
37    result.scanResult = [...scanResultSet];
38}
39exports.addAPICheckErrorLogs = addAPICheckErrorLogs;
40