Method, device, equipment and storage medium for searching code-associated files

By parsing the compilation command to build a parameter dictionary and filter out code-related files, the problems of low retrieval efficiency and poor accuracy in code engineering are solved, and efficient file search and stability of the compilation process are achieved.

CN120336266BActive Publication Date: 2025-09-05NANJING SIETIUM SEMICON CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510827710.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-09-05
Estimated Expiration
2045-06-20

AI Technical Summary

Technical Problem

In code engineering, users face a large number of choices when searching for general symbol definitions, resulting in low retrieval efficiency and poor accuracy.

Method used

By obtaining the compiler name and type, parsing the compilation command, building a parameter dictionary, extracting assignment information, filtering out the source file set and reference file set associated with the current code, using regular expressions and wildcard expressions for matching and filtering, combining the compiler type to determine indirect references, and performing syntax checking and backup.

Benefits of technology

Accurately screening files improves retrieval efficiency and accuracy, reduces the complexity of code retrieval, and ensures the stability and traceability of the compilation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336266B_ABST
    Figure CN120336266B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for searching code-associated files, including: obtaining the name and type of the compiler used to compile the current code, and determining the command to be parsed; performing grammatical analysis on the command to be parsed to obtain a parameter dictionary containing multiple key-value pairs, where the keys are command parameters and the values ​​are corresponding assignment information; extracting the assignment information corresponding to each command parameter from the parameter dictionary; and matching and screening an initial set of files based on the assignment information to obtain the source file set and reference file set associated with the current code. This method can accurately screen files, reduce the complexity of code retrieval, improve accuracy and efficiency, enhance maintainability, and ensure the effectiveness and completeness of the code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for searching code-associated files. Background Art

[0002] As the scale of code projects expands, when users search for general symbols / jump symbol definitions / references, the compilation tool will parse and present all source code files for users to manually select. However, general symbols in a code project may have multiple definitions in multiple files, and only during actual compilation will multiple selections for general symbol definitions be made according to the configuration. Therefore, when there are many definitions of general symbols, the compilation tool will present many items for users to manually select. Users face a large number of choices when searching for general symbol definitions, and manual screening is cumbersome. This leads to the inability to accurately screen files, low retrieval efficiency, and poor accuracy.

[0003] Therefore, how to accurately screen files, improve retrieval efficiency and increase accuracy is an urgent problem to be solved. Summary of the Invention

[0004] In view of this, the embodiments of the present application provide a method, device, equipment, and storage medium for searching code-related files, which can accurately screen files, improve retrieval efficiency, and increase accuracy. The embodiments of the present application provide a method, device, equipment, and storage medium for searching code-related files as follows:

[0005] The present invention provides a method for searching for a code-related file, including:

[0006] Obtaining the name and type of a compiler used to compile the current code, and determining a command to be parsed for the current code according to the compiler name and the compiler type;

[0007] Performing syntax analysis on the command to be parsed to obtain a parameter dictionary, the parameter dictionary including multiple sets of command parameter data in the form of key-value pairs, where the keys in the command parameter data are command parameters in the command to be parsed, and the values ​​in the command parameter data are assignment information corresponding to the command parameters, the assignment information including source file information, referenced file information, and preprocessing command information associated with the current code;

[0008] Extracting parameters from the parameter dictionary to obtain multiple pieces of assignment information corresponding to the command parameters;

[0009] The initial file set is matched and screened according to the assignment information to obtain the source file set and the reference file set associated with the current code.

[0010] In some embodiments, the assignment information further includes indirect reference to source file information;

[0011] Extracting parameters from the parameter dictionary to obtain assignment information corresponding to a plurality of command parameters further includes:

[0012] Extracting parameters from the parameter dictionary to obtain reference file information and pre-processing command information corresponding to a plurality of command parameters;

[0013] Determine whether the compiler type supports an indirect source file reference operation. If the compiler type supports the indirect source file reference operation, analyze and extract the reference file information and the preprocessing command information to obtain the indirect source file reference information.

[0014] In some embodiments, matching and screening the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code includes:

[0015] Marking the initial file set according to the assignment information and a preset matching rule to obtain an unmarked first sub-initial file set and a marked second sub-initial file set;

[0016] The marked second sub-initial file set in the initial file set is screened out according to a preset screening strategy to obtain an unmarked first sub-initial file set in the initial file set, wherein the unmarked first sub-initial file set includes a source file set and a reference file set associated with the current code.

[0017] In some embodiments, the preset screening policy includes any one of file hiding, prohibiting reading, and removing from directory.

[0018] In some embodiments, matching and screening the initial file set according to the assignment information to obtain the source file set and the reference file set associated with the current code further includes:

[0019] Perform grammar checking on the source file set and the reference file set to determine whether there is grammatical expansion in the source file set or the reference file set. If there is grammatical expansion in the source file set or the reference file set, back up the source file set or the reference file set.

[0020] In some embodiments, the syntax expansion includes any one of preprocessing command expansion or indirect source file reference expansion.

[0021] In some embodiments, the matching filter includes any one of a regular expression or a wildcard expression.

[0022] An embodiment of the present application provides a device for searching code-related files, comprising:

[0023] An acquisition module is used to obtain the name and type of the compiler used to compile the current code, and determine the command to be parsed of the current code according to the compiler name and the compiler type;

[0024] a processing module, configured to perform syntax analysis on the command to be parsed to obtain a parameter dictionary, wherein the parameter dictionary includes a plurality of sets of command parameter data in the form of key-value pairs, wherein the keys in the command parameter data are command parameters in the command to be parsed, and the values ​​in the command parameter data are assignment information corresponding to the command parameters, wherein the assignment information includes source file information, referenced file information, and preprocessing command information associated with the current code;

[0025] An extraction module, configured to extract parameters from the parameter dictionary to obtain assignment information corresponding to a plurality of command parameters;

[0026] The screening module is used to match and screen the initial file set according to the assignment information to obtain the source file set and the reference file set associated with the current code.

[0027] The computer device provided in an embodiment of the present application includes a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the method described in the embodiment of the present application is implemented.

[0028] The computer-readable storage medium provided in the embodiment of the present application stores a computer program thereon, and when the computer program is executed by a processor, the method provided in the embodiment of the present application is implemented.

[0029] The embodiments of the present application provide a method, apparatus, device, and storage medium for searching code-associated files. The method determines the command to be parsed by obtaining the name and type of the compiler that compiled the current code. The method then performs grammatical analysis on the command to be parsed to obtain a parameter dictionary containing multiple key-value pairs, where the keys are command parameters and the values ​​are corresponding assignment information. The method extracts the assignment information corresponding to each command parameter from the parameter dictionary. The method then matches and filters the initial file set based on the assignment information to obtain the source file set and reference file set associated with the current code. This method enables precise file screening, improving search efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments of the present application or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0031] Figure 1 A schematic diagram of an implementation flow of a method for searching code-associated files provided in an embodiment of the present application;

[0032] Figure 2 A schematic diagram of an implementation flow for obtaining assignment information in a code association file search method provided in an embodiment of the present application;

[0033] Figure 3 A schematic diagram of an implementation flow for obtaining a source file set and a reference file set in a code-associated file search method provided in an embodiment of the present application;

[0034] Figure 4 A device for searching code-associated files is provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] To make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the specific technical solutions of the present application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application but are not intended to limit the scope of the present application.

[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.

[0037] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0038] It should be pointed out that the terms "first\second\third" involved in the embodiments of the present application are used to distinguish similar or different objects, and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.

[0039] Figure 1 A schematic diagram of the implementation flow of a method for searching code-related files provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method may include the following steps 101 to 104:

[0040] Step 101: Obtain the name and type of the compiler used to compile the current code, and determine the commands to be parsed of the current code according to the compiler name and type.

[0041] In the embodiments of the present application, when a compilation tool compiles code, the specific name and type of the compiler currently in use are first obtained. The compiler name is used to uniquely identify the specific compilation tool software and to clarify the specific compilation tool entity being targeted so that the tool's unique command parameter format and syntax parsing rules can be adapted. The compiler name is a prerequisite for determining the compilation command to be parsed. Different compiler names correspond to different command parameter prefixes, syntax rules, and functional characteristics.

[0042] Based on the obtained compiler name and type, the command format used by the compiler when compiling the current code can be determined. Different compilers use different command parameters when performing compilation tasks. For example, some compilers use specific symbols to specify the search path for header files, while others use different symbols to represent preprocessing instructions such as macro definitions. By identifying the specific information of the compiler, the structure and parameter rules of the compilation commands that need to be parsed later can be clarified, thereby obtaining a command to be parsed containing various compilation parameters. For example, the command may contain the name of the output file, the path of the source code file involved in the compilation, the directory where the header file is located, and preprocessing instructions that need to be executed before compilation.

[0043] Step 102: Perform syntax analysis on the command to be parsed to obtain a parameter dictionary. The parameter dictionary includes multiple sets of command parameter data in the form of key-value pairs. The keys in the command parameter data are the command parameters in the command to be parsed, and the values ​​in the command parameter data are the assignment information corresponding to the command parameters. The assignment information includes the source file information, reference file information, and preprocessing command information associated with the current code.

[0044] In the embodiment of the present application, after obtaining the command to be parsed, a syntax analysis is performed on it. Specifically, the complete compilation command is split into multiple independent parameter units according to separators such as spaces, and then the function of each parameter unit is analyzed one by one.

[0045] In these parameter units, the part that begins with a specific symbol is identified as a command parameter, and the content following the command parameter is the corresponding assignment information of the parameter. For example, a command parameter is used to specify the source code files involved in the compilation, and its corresponding assignment information is the specific path of these source code files; another command parameter may be used to specify the search directory for header files, and its assignment information is the path of this directory; and some command parameters are used to define macro instructions that need to be processed before compilation, and their assignment information is the specific macro definition content.

[0046] Through syntax analysis, all command parameters are paired with their corresponding assignment information to form a parameter dictionary in the form of key-value pairs. This parameter dictionary contains three core types of assignment information: the path information of the source code files directly involved in the compilation, the directory or path information of the header files required during the compilation process, and the preprocessing command information required to be executed before compilation.

[0047] Step 103: extract parameters from the parameter dictionary to obtain assignment information corresponding to multiple command parameters.

[0048] In the embodiment of the present application, after constructing the parameter dictionary, it is necessary to extract the assignment information corresponding to each command parameter from it. Specifically, it is to separate the specific content related to the source code file, reference file and preprocessing command from the dictionary.

[0049] For source code file information, we primarily extract file names that are directly listed without a specific command parameter prefix. These file names represent the paths of the source files directly involved in the current code compilation. For reference file information, we focus on extracting the paths corresponding to the parameters used to specify the search directory for header files. These paths indicate the locations where header files need to be found during compilation. Preprocessing command information comes from parameters used to define macro instructions or conditional compilation options. Their assigned values ​​contain instructions that need to be pre-processed before compilation, such as macro definitions for enabling debugging mode.

[0050] Step 104 : matching and screening the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code.

[0051] In the embodiment of the present application, after obtaining the above-mentioned assignment information, it is necessary to perform matching screening based on the initial file set consisting of all files in the project directory.

[0052] The screening of source code file sets involves searching the initial file set for files that have the same path as the extracted source code files, and integrating these files into a source file set associated with the current code. These files are the core code files that are directly involved in compilation.

[0053] For the screening of the reference file set, the extracted header file search directory path is used to search for files whose paths are prefixed by these directories in the initial file set. For example, if the header file search directory is "project directory / include", all header files whose paths begin with this directory are screened out, such as "project directory / include / function definition.h" and "project directory / include / type declaration.h", to form a reference file set. In addition, if the preprocessing command contains indirectly referenced files, their specific paths are further parsed in combination with the header file search directory, and these files are added to the reference file set. Optionally, the header file search directory path provided in the embodiment of the present application is an ordered header file search directory path.

[0054] The embodiments of the present application adapt to the command parameter rules of different compilers to accurately parse the source code files, referenced files, and preprocessing instructions contained in the compilation command, and use this information as a basis to filter out the associated files actually involved in the compilation from the project directory. This can effectively exclude invalid files that are not referenced by the compilation configuration, so that when performing code retrieval, symbol jumps, etc., the files directly related to the current compilation configuration are faced, thereby significantly reducing the complexity of code retrieval and improving development efficiency.

[0055] In the above Figure 1 Based on the above, the present application also provides a schematic diagram of the implementation process of obtaining assignment information in a code association file search method, such as Figure 2 As shown, the process includes the following steps 201 to 202:

[0056] Step 201 : extract parameters from the parameter dictionary to obtain reference file information and pre-processing command information corresponding to multiple command parameters.

[0057] In the embodiment of the present application, the assignment information further includes indirect reference source file information. Indirect reference source file information refers to source files that are not directly listed in the compilation command but are indirectly associated with the source files through reference files or preprocessing commands.

[0058] Based on the previously extracted assignment information, the reference file information and preprocessing command information are further extracted in a targeted manner. Specifically, the parameters related to the reference file and their corresponding values, as well as the parameters related to the preprocessing command and their corresponding values, are clearly identified from the parameter dictionary. For example, the value corresponding to the parameter used to specify the header file search directory is the reference file information, while the value corresponding to the parameter used to define macros or conditional compilation is the preprocessing command information.

[0059] Step 202 , determining whether the compiler type supports the indirect reference source file operation. If the compiler type supports the indirect reference source file operation, performing analysis and extraction operations on the reference file information and the preprocessing command information to obtain the indirect reference source file information.

[0060] In an embodiment of the present application, it is determined whether the compiler type currently in use supports the indirect reference source file operation. Different compilers have different functions. Some compilers have the ability to support indirect reference source files, while others do not. Whether the compiler supports this operation can be determined by querying the compiler's documentation, version information, or using specific detection methods.

[0061] If it is determined that the compiler type supports the indirect reference source file operation, the previously extracted reference file information and preprocessing command information are analyzed, specifically:

[0062] In the header file search directory in the referenced file information, examine the contents of the header files therein. Some header files may point to other source files through specific reference statements. These pointed source files are potential indirect reference source files. For example, a header file may contain include directives for other files, which can be used to find the associated source files.

[0063] Macro definitions or conditional compilation options in preprocessor command information may affect file reference logic. By analyzing these preprocessor commands, you can understand which source files are indirectly referenced under different compilation conditions. For example, a macro definition may determine whether a specific source file is included. By analyzing the macro definition, you can identify the affected source files.

[0064] By comprehensively analyzing the reference file information and preprocessing command information, the indirectly referenced source file information found is added to the assignment information, thereby improving the information set of the entire code-associated file.

[0065] The embodiment of the present application can accurately extract indirect reference source file information by judging the compiler support status and analyzing the reference file information and preprocessing command information, making the search of code-related files more comprehensive and accurate, and providing more powerful support for code development and maintenance.

[0066] In the above Figure 1 Based on the above, the present application also provides a schematic diagram of the implementation process of obtaining a source file set and a reference file set in a code-related file search method, as shown in FIG. Figure 3 As shown, the process includes the following steps 301 to 302:

[0067] Step 301 : Mark the initial file set according to the assignment information and the preset matching rule to obtain an unmarked first sub-initial file set and a marked second sub-initial file set.

[0068] In the embodiment of the present application, each file in the initial file set is marked according to the assignment information and the preset matching rule. The preset matching rule can use a regular expression or a wildcard expression, specifically:

[0069] 1. Wildcard expressions are a relatively simple and intuitive matching method that uses specific symbols to represent fuzzy matching. For example, an asterisk can represent any number of any characters, and a question mark can represent a single any character.

[0070] If the assignment information specifies the source code files directly involved in the compilation, wildcard expressions can be used to mark these source files. For example, if the source file names contain a specific keyword, a wildcard expression containing that keyword and an asterisk can be used to match all matching source files. Files matching this expression are marked as part of the unmarked first sub-initial file set, meaning they are considered source files associated with the current code.

[0071] For header file search directories specified in the assignment information, wildcard expressions can also be used to mark reference files within that directory. For example, a wildcard expression representing a directory and an asterisk will match all files within that directory. Files matching the expression and located within the specified header file search directory are marked as the unmarked first child of the initial set of files, meaning that these files are considered reference files associated with the current code.

[0072] For those files that do not meet any wildcard expression matching rules, they are marked as the second sub-initial file set after marking, that is, it is considered that these files may be irrelevant to the current code.

[0073] 2. Regular expressions accurately match file paths or file names by defining complex rules.

[0074] Based on the characteristics of the source files in the assignment information, a corresponding regular expression is constructed. For example, if the source files have specific naming conventions, such as starting or ending with a specific prefix or suffix, or containing a specific character combination, a regular expression can be used to describe these conventions. Files in the initial file set that match the regular expression are marked as the unmarked first sub-initial file set, meaning that these files are considered source files associated with the current code.

[0075] For referenced files, a regular expression can be constructed based on the characteristics of the header file search directory in the assignment information and the possible naming conventions of the referenced files. For example, if referenced files typically end with a specific extension and are located in a specified header file search directory, a regular expression can be used to match these files. Files that match this regular expression are marked as part of the unmarked first sub-initial file set, meaning that these files are considered referenced files associated with the current code.

[0076] For those files that do not meet any regular expression matching rules, they are marked as the second sub-initial file set after the mark, that is, it is considered that these files may be irrelevant to the current code.

[0077] Step 302 , screen out the marked second sub-initial file set in the initial file set according to a preset screening strategy to obtain an unmarked first sub-initial file set in the initial file set, where the unmarked first sub-initial file set includes the source file set and the reference file set associated with the current code.

[0078] In the embodiments of the present application, the screening strategies primarily include file hiding, read prohibition, and removal from directories. File hiding involves setting the marked files in the second sub-initial file set to a hidden state. At the operating system level, appropriate settings are implemented to prevent these files from being displayed during regular file browsing operations. While these files are visually hidden, they remain in the original project directory and can be displayed later if needed through specific methods.

[0079] Disallowing read access sets permissions on marked files, removing their read permissions. Under the operating system's permission management mechanism, disallowing read access to these files prevents compilation tools and development environments from accessing them, thus preventing them from being processed during the compilation process.

[0080] Removing a directory removes the marked files from the current compilation path. You can move these files to a separate folder or simply delete them. Before deleting, you can make a backup.

[0081] After the above filtering process, the final unmarked first sub-initial file set contains the source file set and reference file set associated with the current code. The source file set is the set of files directly involved in code compilation, and the reference file set is the set of header files or other dependent files that need to be referenced during the compilation process.

[0082] The embodiment of the present application performs file matching and screening by first marking and then screening. After screening, only files directly related to the current code compilation are retained in the code project directory. When performing code retrieval, symbol jump and other operations, there will be no interference from a large number of irrelevant files, and the required files can be found more quickly and accurately. The preset matching rules and screening strategies can be flexibly adjusted according to different project requirements and development environments. Different matching rules can be formulated for different types of code projects, and different screening strategies can be selected for different security requirements.

[0083] In some embodiments, the initial file set is matched and screened according to the assignment information to obtain the source file set and the reference file set associated with the current code, and also includes: performing syntax checking on the source file set and the reference file set to determine whether there is syntax expansion in the source file set or the reference file set, and backing up the source file set or the reference file set if there is syntax expansion in the source file set or the reference file set.

[0084] Specifically, after obtaining the source file set and reference file set given by the compiler command parameters, the pre-compilation preprocessing command syntax check is performed on each file in the two sets. Specifically, the presence of specific grammatical structures in the files is checked to determine whether there is grammatical expansion.

[0085] Preprocessor command expansion typically involves dynamically generating or modifying code using specific syntax before compilation. The file is checked for special syntax or structures, such as directives for conditional compilation and macro definitions. If these directives are present and generate new code logic during compilation, the file is considered to have preprocessor command expansion.

[0086] Indirect source file reference expansion refers to indirect references to source files not directly listed in the compilation command, through header files or other means. Check the file for statements referencing other source files, such as those in header files. If so, the file is considered to have indirect source file reference expansion.

[0087] When files that are expanded by preprocessing commands or indirect source file references are found in the source file set or reference file set, these files need to be backed up.

[0088] The embodiments of the present application perform syntax checking on the selected source file set and reference file set to determine whether preprocessing command expansion or indirect source file reference expansion exists, and back up the files with syntax expansion, effectively ensuring the stability and traceability of the code compilation process. In the subsequent development process, if problems are found in the compilation results, the backup files can be used to troubleshoot and recover the problems.

[0089] Although this application provides method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on routine or non-creative work. The order of steps listed in this embodiment is only one way of executing the steps among many, and does not represent the only execution order. When an actual device or client product executes, the method shown in this embodiment or the accompanying drawings may be executed sequentially or in parallel (for example, in a parallel processor or multi-threaded processing environment).

[0090] like Figure 4 As shown, the embodiment of the present application also provides a device 400 for searching code-related files. The device includes:

[0091] An acquisition module 401 is configured to acquire the name and type of a compiler used to compile the current code, and determine the command to be parsed of the current code based on the compiler name and type.

[0092] Processing module 402 is configured to perform syntax analysis on the command to be parsed to obtain a parameter dictionary. The parameter dictionary includes multiple sets of command parameter data in the form of key-value pairs. The keys in the command parameter data are command parameters in the command to be parsed, and the values ​​in the command parameter data are assignment information corresponding to the command parameters. The assignment information includes source file information, referenced file information, and preprocessing command information associated with the current code.

[0093] Extraction module 403, used to extract parameters from the parameter dictionary to obtain assignment information corresponding to multiple command parameters;

[0094] The screening module 404 is used to match and screen the initial file set according to the assignment information to obtain the source file set and the reference file set associated with the current code.

[0095] In some embodiments, the extraction module 403 is further configured to extract parameters from the parameter dictionary to obtain reference file information and pre-processing command information corresponding to a plurality of command parameters;

[0096] The extraction module 403 is further used to determine whether the compiler type supports the indirect reference source file operation. If the compiler type supports the indirect reference source file operation, the reference file information and the preprocessing command information are analyzed and extracted to obtain the indirect reference source file information.

[0097] In some embodiments, the processing module 402 is further configured to mark the initial file set according to the assignment information and a preset matching rule to obtain an unmarked first sub-initial file set and a marked second sub-initial file set;

[0098] The screening module 404 is also used to screen out the marked second sub-initial file set in the initial file set according to a preset screening strategy to obtain an unmarked first sub-initial file set in the initial file set. The unmarked first sub-initial file set includes the source file set and the reference file set associated with the current code.

[0099] In some embodiments, the processing module 402 is also used to perform syntax checking on the source file set and the reference file set, determine whether there is syntax expansion in the source file set or the reference file set, and back up the source file set or the reference file set if there is syntax expansion in the source file set or the reference file set.

[0100] Some modules in the apparatus described herein may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0101] The devices or modules described in the above application embodiments can be implemented by computer chips or physical devices, or by products with certain functions. For ease of description, the above devices are described separately by function in various modules. When implementing the embodiments of this application, the functions of each module can be implemented in the same or multiple software and / or hardware. Of course, a module that implements a certain function can also be implemented by combining multiple sub-modules or sub-units.

[0102] The methods, devices, or modules described herein can be implemented in the form of computer-readable program code. The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the memory control logic. Those skilled in the art will also appreciate that, in addition to implementing the controller in pure computer-readable program code, the controller can also be implemented in the form of logic gates, switches, an application-specific integrated circuit, a programmable logic controller, an embedded microcontroller, etc. by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions may be considered to be both a software module for implementing the method and a structure within a hardware component.

[0103] An embodiment of the present application further provides a device comprising: a processor; a memory for storing processor-executable instructions; and when the processor executes the executable instructions, the method described in the embodiment of the present application is implemented.

[0104] The embodiments of the present application also provide a non-volatile computer-readable storage medium having a computer program or instruction stored thereon. When the computer program or instruction is executed, the method described in the embodiments of the present application is implemented.

[0105] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist independently, or two or more modules may be integrated into one module.

[0106] The above-mentioned storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), cache, hard disk drive (HDD), or memory card. Such memory can be used to store computer program instructions.

[0107] Through the description of the above implementation methods, it can be seen that those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary hardware. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, or can be embodied through the implementation process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application or certain parts of the embodiments.

[0108] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referenced to each other. Each embodiment focuses on the differences from other embodiments. All or part of this application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, mobile communication terminals, multi-processor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.

[0109] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit the present application. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present application.

Claims

1. A method for searching code-related files, characterized in that: The method comprises: Obtaining the name and type of a compiler used to compile the current code, and determining a command to be parsed for the current code according to the compiler name and the compiler type; Performing syntax analysis on the command to be parsed to obtain a parameter dictionary, the parameter dictionary including multiple sets of command parameter data in the form of key-value pairs, where the keys in the command parameter data are command parameters in the command to be parsed, and the values ​​in the command parameter data are assignment information corresponding to the command parameters, the assignment information including source file information, referenced file information, and preprocessing command information associated with the current code; Extracting parameters from the parameter dictionary to obtain multiple pieces of assignment information corresponding to the command parameters; Match and filter the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code; The assignment information also includes indirect reference to source file information; Extracting parameters from the parameter dictionary to obtain assignment information corresponding to a plurality of command parameters further includes: Extracting parameters from the parameter dictionary to obtain reference file information and pre-processing command information corresponding to a plurality of command parameters; determining whether the compiler type supports an indirect source file reference operation, and if the compiler type supports the indirect source file reference operation, performing an analysis and extraction operation on the reference file information and the preprocessing command information to obtain the indirect source file reference information; The matching and screening of the initial file set according to the assignment information to obtain the source file set and the reference file set associated with the current code includes: Marking the initial file set according to the assignment information and a preset matching rule to obtain an unmarked first sub-initial file set and a marked second sub-initial file set; The marked second sub-initial file set in the initial file set is screened out according to a preset screening strategy to obtain an unmarked first sub-initial file set in the initial file set, wherein the unmarked first sub-initial file set includes a source file set and a reference file set associated with the current code.

2. The method according to claim 1, characterized in that The preset screening strategy includes any one of file hiding, prohibiting reading, and removing from directory.

3. The method according to claim 1, characterized in that After matching and screening the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code, the method further includes: Perform grammar checking on the source file set and the reference file set to determine whether there is grammatical expansion in the source file set or the reference file set. If there is grammatical expansion in the source file set or the reference file set, back up the source file set or the reference file set.

4. The method according to claim 3, characterized in that The syntax expansion includes any one of preprocessing command expansion and indirect source file reference expansion.

5. The method according to claim 1, characterized in that The matching filter includes any one of a regular expression or a wildcard expression.

6. A device for searching code-related files, characterized in that: include: An acquisition module is used to obtain the name and type of the compiler used to compile the current code, and determine the command to be parsed of the current code according to the compiler name and the compiler type; a processing module, configured to perform syntax analysis on the command to be parsed to obtain a parameter dictionary, wherein the parameter dictionary includes a plurality of sets of command parameter data in the form of key-value pairs, wherein the keys in the command parameter data are command parameters in the command to be parsed, and the values ​​in the command parameter data are assignment information corresponding to the command parameters, wherein the assignment information includes source file information, referenced file information, and preprocessing command information associated with the current code; An extraction module, configured to extract parameters from the parameter dictionary to obtain assignment information corresponding to a plurality of command parameters; A screening module is used to match and screen the initial file set according to the assignment information to obtain the source file set and the reference file set associated with the current code; The assignment information also includes indirect reference to source file information; The extraction module is further used to extract parameters from the parameter dictionary to obtain assignment information corresponding to multiple command parameters, wherein: Extracting parameters from the parameter dictionary to obtain reference file information and pre-processing command information corresponding to a plurality of command parameters; determining whether the compiler type supports an indirect source file reference operation, and if the compiler type supports the indirect source file reference operation, performing an analysis and extraction operation on the reference file information and the preprocessing command information to obtain the indirect source file reference information; The screening module is used to match and screen the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code, wherein: Marking the initial file set according to the assignment information and a preset matching rule to obtain an unmarked first sub-initial file set and a marked second sub-initial file set; The marked second sub-initial file set in the initial file set is screened out according to a preset screening strategy to obtain an unmarked first sub-initial file set in the initial file set, wherein the unmarked first sub-initial file set includes a source file set and a reference file set associated with the current code.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • File searching method and device, computer equipment and storage medium

    CN114185852A