Code associated file searching method and device, equipment and storage medium

By obtaining compiler information for syntax analysis and file matching screening, the problem of low file retrieval efficiency and poor accuracy in code projects is solved, accurate screening and efficient search are realized, and maintainability of code development is improved.

CN120336266AActive Publication Date: 2025-07-18NANJING SIETIUM SEMICON CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In code engineering, the existing technology cannot accurately filter files, resulting in low retrieval efficiency and poor accuracy. Users face a large number of choices when looking for general symbol definitions, and manual screening is cumbersome.

Method used

By obtaining the compiler name and type, determining the command to be parsed, performing syntax analysis to obtain the parameter dictionary, extracting the assignment information, matching and filtering the initial file set based on the assignment information, obtaining the source file set and reference file set associated with the current code, supporting indirect reference source file operations, and accurately filtering files through preset matching rules and filtering strategies.

Benefits of technology

It realizes accurate screening of files, improves retrieval efficiency and accuracy, reduces the complexity of code retrieval, and enhances the maintainability and development efficiency of code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336266A_ABST
    Figure CN120336266A_ABST
Patent Text Reader

Abstract

The invention discloses a search method, device and equipment for a code associated file and a storage medium, and the method comprises the steps: obtaining the name and the type of a compiler for compiling a current code, and determining a to-be-analyzed command; syntactic analysis is conducted on the to-be-analyzed command, a parameter dictionary containing multiple sets of key-value pairs is obtained, keys are command parameters, and values are corresponding assignment information; extracting assignment information corresponding to each command parameter from a parameter dictionary; and matching and screening the initial file set according to the assignment information to obtain a source file set and a reference file set associated with the current code. The file can be accurately screened, the code retrieval complexity is reduced, the accuracy and efficiency are improved, the maintainability is enhanced, and it is guaranteed that codes are effective and complete.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] As the scale of the code project expands, when a user performs a search for a general symbol / jumps to the symbol definition / reference, the compilation tool will parse and present all source code files for the user to select manually. However, a general symbol in a code project may have multiple definitions in multiple files, and only when actual compilation is performed will the general symbol definition be selected one from multiple according to the configuration. Therefore, when there are many definitions of general symbols, the number of entries presented by the compilation tool for the user to select manually will also become very large. When the user searches for the definition of a general symbol, there are a large number of selections, and manual screening is cumbersome. This leads to the problems of inability to accurately screen files, low retrieval efficiency, and poor accuracy.

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

[0004] In view of this, a method, apparatus, device, and storage medium for finding code-associated files provided by an embodiment of this application can accurately screen files, improve retrieval efficiency and accuracy. A method, apparatus, device, and storage medium for finding code-associated files provided by an embodiment of this application are implemented as follows: A method for finding code-associated files provided by an embodiment of this application includes: Obtain the name and type of the compiler for compiling the current code, and determine the command to be parsed for the current code according to the compiler name and the compiler type; Perform syntactic analysis processing 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 key in the command parameter data is the command parameter in the command to be parsed, and the value in the command parameter data is the assignment information corresponding to the command parameter. The assignment information includes source file information, reference file information, and preprocessing command information associated with the current code; Extract parameters from the parameter dictionary to obtain the assignment information corresponding to multiple command parameters; 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.

[0005] In some embodiments, the assignment information further includes indirectly referenced source file information; The extracting parameters from the parameter dictionary to obtain the assignment information corresponding to multiple command parameters further includes: Extract parameters from the parameter dictionary to obtain reference file information and preprocessing command information corresponding to multiple command parameters; Determine whether the compiler type supports indirect reference to source files. If the compiler type supports indirect reference to source files, perform analysis and extraction operations on the reference file information and preprocessing command information to obtain indirect reference source file information.

[0006] In some embodiments, the matching and screening of 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: 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; Perform a screening process on the marked second sub-initial file set in the initial file set according to a preset screening strategy to obtain the unmarked first sub-initial file set in the initial file set, and the unmarked first sub-initial file set includes the source file set and reference file set associated with the current code.

[0007] In some embodiments, the preset screening strategy includes any one of file hiding, prohibited reading, and moving out of the directory.

[0008] In some embodiments, the matching and screening of the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code further includes: Perform a syntax check process 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. If there is syntax expansion in the source file set or the reference file set, back up the source file set or the reference file set.

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

[0010] In some embodiments, the matching and screening includes any one of regular expression or wildcard expression.

[0011] A device for finding code-associated files provided by an embodiment of the present application includes: An acquisition module, configured to acquire the compiler name and compiler type for compiling the current code, and determine the command to be parsed for the current code according to the compiler name and the compiler type; A processing module, configured to perform syntax analysis processing on the command to be parsed to obtain a parameter dictionary, where the parameter dictionary includes multiple sets of command parameter data in the form of key-value pairs. The key in the command parameter data is the command parameter in the command to be parsed, and the value in the command parameter data is the assignment information corresponding to the command parameter. The assignment information includes source file information, reference file information, and preprocessing command information associated with the current code; An extraction module, configured to extract parameters from the parameter dictionary to obtain the assignment information corresponding to multiple command parameters; A screening module, configured to perform matching and screening on the initial file set according to the assignment information to obtain a source file set and a reference file set associated with the current code.

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

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

[0014] A method, device, equipment, and storage medium for finding code-associated files provided by the embodiment of the present application, by obtaining the name and type of the compiler for compiling the current code to determine the command to be parsed; performing syntax analysis on the command to be parsed to obtain a parameter dictionary containing multiple sets of key-value pairs, where the key is the command parameter and the value is the corresponding assignment information; extracting the assignment information corresponding to each command parameter from the parameter dictionary; and performing matching and screening on the initial file set according to the assignment information to obtain a source file set and a reference file set associated with the current code. In this way, files can be accurately screened, and the retrieval efficiency and accuracy can be improved. Description of the Drawings

[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for use in the description of the embodiments of the present application or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0016] Figure 1 It is a schematic flowchart of the implementation of a method for finding code-associated files provided by the embodiment of the present application; Figure 2 It is a schematic flowchart of the implementation of obtaining assignment information in a method for finding code-associated files provided by the embodiment of the present application; Figure 3Schematic diagram of the implementation process for obtaining a source file set and a reference file set in a method for finding a code-associated file provided by an embodiment of the present application; Figure 4 A device for finding a code-associated file provided by an embodiment of the present application. Detailed implementation manners

[0017] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will further describe the specific technical solutions of the present application in detail with reference to the accompanying 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.

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

[0019] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.

[0020] It should be noted 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 order for the objects. It can be understood that "first / second / third" can be interchanged with a specific order or sequence when permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0021] Figure 1 Schematic diagram of the implementation process for a method for finding a code-associated file provided by an embodiment of the present application, as Figure 1 shown, the method may include the following steps 101 to 104: Step 101: Obtain the name and type of the compiler for compiling the current code, and determine the command to be parsed for the current code according to the name and type of the compiler.

[0022] In the embodiments of the present application, when a compilation tool compiles code, first obtain the specific name and the type to which the currently used compiler belongs. The compiler name is used to uniquely identify a specific compilation tool software, to clarify the specific compilation tool entity targeted, so as to adapt to the unique command parameter format and syntax parsing rules of the tool. The compiler name is the prerequisite for determining the compilation command to be parsed, and different compiler names correspond to different command parameter prefixes, syntax rules, and functional characteristics.

[0023] Based on the obtained compiler name and type, the command format used by the compiler when compiling the current code can be determined. When different compilers execute the compilation task, there are differences in the command parameters they adopt. For example, some compilers use specific symbols to specify the search path of 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 command to be parsed subsequently can be clarified, so as to obtain the command to be parsed containing various compilation parameters. For example, this command may contain information such as the name of the output file, the path of the source code file participating in the compilation, the directory where the header files are located, and the preprocessing instructions to be executed before compilation.

[0024] 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 key in the command parameter data is the command parameter in the command to be parsed, and the value in the command parameter data is the assignment information corresponding to the command parameter. The assignment information includes the source file information associated with the current code, the reference file information, and the preprocessing command information.

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

[0026] Among these parameter units, the part starting with a specific symbol is recognized as a command parameter, and the content following the command parameter is the assignment information corresponding to the parameter. For example, a certain command parameter is used to specify the source code files participating in the compilation, and its corresponding assignment information is the specific paths of these source code files; another command parameter may be used to specify the search directory of header files, and its assignment information is the path of the directory; there are also command parameters used to define the macro instructions to be processed before compilation, and its assignment information is the specific macro definition content.

[0027] 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 types of core assignment information: the path information of the source code files directly participating in the compilation, the directory or path information of the header files to be referenced during the compilation process, and the preprocessing command information to be executed before compilation.

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

[0029] In the embodiments of the present application, after the parameter dictionary is constructed, 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.

[0030] For the source code file information, mainly extract those file names directly listed without a specific command parameter prefix, and these file names represent the source file paths directly participating in the current code compilation. For the reference file information, focus on extracting the paths corresponding to the parameters used to specify the header file search directory, and these paths indicate the positions where header files need to be searched during compilation. The preprocessing command information comes from the parameters used to define macro instructions or conditional compilation options, and its assignment content contains the instructions that need to be preprocessed before compilation, such as the macro definition for enabling the debug mode, etc.

[0031] Step 104, perform matching and screening on the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code.

[0032] In the embodiments of the present application, after obtaining the above assignment information, it is necessary to perform matching and screening based on the initial file set composed of all files in the project directory.

[0033] For the screening of the source code file set, search for files in the initial file set that are exactly the same as the extracted source code file paths, and integrate these files to form the source file set associated with the current code. These files are the core code files directly participating in the compilation.

[0034] For the screening of the reference file set, according to the extracted header file search directory paths, search for files in the initial file set whose paths start with these directories. For example, if the header file search directory is "project directory / include", then filter out all header files whose paths start with this directory, such as "project directory / include / function definition.h", "project directory / include / type declaration.h", etc., to form the reference file set. In addition, if the preprocessing command contains indirectly referenced files, further resolve their specific paths in combination with the header file search directory, and supplement these files to the reference file set. Optionally, the header file search directory paths provided in the embodiments of the present application are ordered header file search directory paths.

[0035] In the embodiments of the present application, by adapting to the command parameter rules of different compilers, information such as source code files, reference files, and preprocessing instructions included in the compilation command is accurately parsed, and based on this, associated files actually participating in the compilation are screened out from the project directory. It can effectively exclude invalid files not referenced by the compilation configuration, so that when performing operations such as code retrieval and symbol jumping, the files faced are a set of files directly related to the current compilation configuration, thereby greatly reducing the complexity of code retrieval and improving development efficiency.

[0036] Based on the above Figure 1 shown, the present application also provides a schematic flowchart of the implementation process for obtaining assignment information in a method for finding code associated files, as Figure 2 shown, including the following steps 201 to step 202: Step 201, extract parameters from the parameter dictionary to obtain reference file information and preprocessing command information corresponding to multiple command parameters.

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

[0038] Based on the previous extraction of assignment information, further extract reference file information and preprocessing command information in a targeted manner. Specifically, clearly identify the parameters related to reference files and their corresponding values, as well as the parameters related to preprocessing commands and their corresponding values from the parameter dictionary. For example, the value corresponding to the parameter for specifying the header file search directory is reference file information, and the value corresponding to the parameter for defining macros or conditional compilation is preprocessing command information.

[0039] Step 202, determine whether the compiler type supports the operation of indirectly referencing source files. If the compiler type supports the operation of indirectly referencing source files, perform analysis and extraction operations on the reference file information and preprocessing command information to obtain indirect reference source file information.

[0040] In the embodiments of the present application, determine whether the currently used compiler type supports the operation of indirectly referencing source files. Different compilers have differences in functions. Some compilers have the ability to support indirectly referencing source files, while some do not. It can be determined whether it supports this operation by querying the compiler's documentation, version information, or using specific detection means.

[0041] If it is determined that the compiler type supports the operation of indirectly referencing source files, then analyze the previously extracted reference file information and preprocessing command information. Specifically: For the header file search directories in the reference file information, view the content of the header files. Some header files may point to other source files through specific reference statements, and these pointed-to source files are potential indirectly referenced source files. For example, a header file may contain inclusion directives for other files, and the associated source files can be found through these directives.

[0042] Macro definitions or conditional compilation options in the preprocessing command information may affect the file reference logic. By analyzing these preprocessing commands, it is possible to understand which source files will be indirectly referenced under different compilation conditions. For example, a certain macro definition may determine whether to include a specific source file, and by analyzing the macro definition, these affected source files can be found.

[0043] Based on the comprehensive analysis of the reference file information and the preprocessing command information, the found indirectly referenced source file information is supplemented into the assignment information, thus improving the information set of the entire code-related files.

[0044] The embodiments of the present application can accurately extract the indirectly referenced source file information by judging the compiler support situation and analyzing the reference file information and the preprocessing command information, making the search for code-related files more comprehensive and accurate, and providing stronger support for code development and maintenance.

[0045] Based on the above Figure 1 On this basis, the present application also provides a schematic diagram of the implementation process for obtaining the source file set and the reference file set in a method for searching code-related files, as shown in Figure 3 shown, including the following steps 301 to step 302: Step 301, mark the initial file set according to the assignment information and the preset matching rules to obtain an unmarked first sub-initial file set and a marked second sub-initial file set.

[0046] In the embodiments of the present application, each file in the initial file set is marked according to the assignment information and the preset matching rules. The preset matching rules can use regular expressions or wildcard expressions. Specifically: 1. The wildcard expression is 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 arbitrary character.

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

[0048] For the header file search directories specified in the assignment information, wildcard expressions can also be used to mark the referenced files in that directory. For example, using a wildcard expression representing the directory and an asterisk can match all files in that directory. For files that match this expression and are located in the specified header file search directory, they are marked as the first unmarked sub-initial file set, that is, these files are considered to be the referenced files associated with the current code.

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

[0050] 2. Regular expressions precisely match file paths or file names by defining complex rules.

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

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

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

[0054] Step 302, perform a screening process on the marked second sub-initial file set in the initial file set according to a preset screening strategy to obtain the 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.

[0055] In the embodiments of the present application, the screening strategy mainly includes file hiding, prohibiting reading, and moving out of the directory. Among them, file hiding is to set the files in the marked second sub-initial file set to the hidden state. At the operating system level, through the corresponding setting function, these files will not be displayed in the regular file browsing operation. Although these files are visually hidden, they still remain in the original project directory. If needed in the future, they can be displayed through a specific method.

[0056] Prohibiting reading is to set the permissions of the marked files and remove their read permissions. Under the permission management mechanism of the operating system, these files are set not to be readable, so that the compilation tool and the development environment cannot access these files, thus avoiding processing these potentially irrelevant files during the compilation process.

[0057] Moving out of the directory is to remove the marked files from the current compilation path. These files can be moved to a separate folder or directly deleted. Before deletion, a backup can be made first.

[0058] After the above screening process, the finally obtained unmarked first sub-initial file set contains the source file set and the 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.

[0059] In the embodiments of the present application, file matching and screening are performed by first marking and then screening. After screening, only the files directly related to the current code compilation are retained in the code project directory. When performing operations such as code retrieval and symbol jumping, it will not be interfered by 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. For different types of code projects, different matching rules can be formulated, and for different security requirements, different screening strategies can be selected.

[0060] In some embodiments, when performing matching and screening on 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, it further includes: performing a syntax check process on the source file set and the reference file set to determine whether there is a syntax expansion in the source file set or the reference file set. In the case where there is a syntax expansion in the source file set or the reference file set, back up the source file set or the reference file set.

[0061] Specifically, after obtaining the source file set and reference file set given according to the compiler command parameters, syntax check processing of pre-compilation commands is performed on each file in these two sets. Specifically, it is checked whether there is a specific syntax structure in the file to determine whether there is a syntax expansion situation.

[0062] Preprocessing command expansion usually involves dynamically generating or modifying code through specific syntax before compilation. It is checked whether there are some special syntaxes or structures in the file, such as instructions for conditional compilation, content related to macro definitions, etc. If there are these instructions in the file and these instructions will generate new code logic during compilation, then it is determined that there is preprocessing command expansion in the file.

[0063] Indirect source file reference expansion refers to indirectly associating with source files that are not directly listed in the compilation command through header files or other means. It is checked whether there are statements in the file that reference other source files, such as other source files being referenced in a header file. If such a situation exists, it is determined that there is indirect source file reference expansion in the file.

[0064] When files with preprocessing command expansion or indirect source file reference expansion are found in the source file set or reference file set, these files need to be backed up.

[0065] By performing syntax checks on the filtered source file set and reference file set in the embodiments of the present application, it is determined whether there is preprocessing command expansion or indirect source file reference expansion, and files with syntax expansion are backed up, which can effectively ensure the stability and traceability of the code compilation process. During subsequent development, if problems occur in the compilation results, the backup files can be used for problem troubleshooting and recovery.

[0066] Although the present application provides method operation steps as described in the embodiments or flowcharts, based on routine or non-creative labor, there may be more or fewer operation steps. The step sequence listed in this embodiment is only one way among the execution sequences of numerous steps and does not represent the only execution sequence. When actually executed by a device or client product, it can be executed in the method sequence shown in this embodiment or the drawings or executed in parallel (for example, in an environment of parallel processors or multi-threaded processing).

[0067] As Figure 4 shown, the embodiments of the present application also provide a search device 400 for code-related files. The device includes: An acquisition module 401, configured to acquire the name and type of the compiler for compiling the current code, and determine the command to be parsed for the current code according to the name and type of the compiler; A processing module 402 is configured to perform syntax analysis and processing on a 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 key in the command parameter data is the command parameter in the command to be parsed, and the value in the command parameter data is the assignment information corresponding to the command parameter. The assignment information includes source file information, reference file information, and preprocessing command information associated with the current code. An extraction module 403 is configured to extract parameters from the parameter dictionary to obtain assignment information corresponding to multiple command parameters. A screening module 404 is configured to perform matching and screening on the initial file set according to the assignment information to obtain a source file set and a reference file set associated with the current code.

[0068] In some embodiments, the extraction module 403 is further configured to extract parameters from the parameter dictionary to obtain reference file information and preprocessing command information corresponding to multiple command parameters. The extraction module 403 is further configured to determine whether the compiler type supports the operation of indirectly referencing source files. If the compiler type supports the operation of indirectly referencing source files, perform analysis and extraction operations on the reference file information and the preprocessing command information to obtain indirectly referenced source file information.

[0069] 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. The screening module 404 is further configured to perform screening processing on the marked second sub-initial file set in the initial file set according to a preset screening strategy to obtain the unmarked first sub-initial file set in the initial file set. The unmarked first sub-initial file set includes a source file set and a reference file set associated with the current code.

[0070] In some embodiments, the processing module 402 is further configured to perform syntax check processing 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. If there is syntax expansion in the source file set or the reference file set, back up the source file set or the reference file set.

[0071] Some modules in the device described in this application can be described in a 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 can also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0072] The device or module illustrated in the above application embodiments can be specifically implemented by a computer chip or entity, or by a product with a certain function. For the convenience of description, when describing the above device, it is divided into various modules according to functions and described separately. When implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware. Of course, the module for implementing a certain function can also be implemented by combining multiple sub-modules or sub-units.

[0073] The method, device or module described in the present application can be implemented in the form of computer-readable program code. The controller can be implemented in any appropriate manner. For example, the controller can take the form of, for example, a microprocessor or a processor, and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, application specific integrated circuit (ASIC), programmable logic controller, and embedded microcontroller. Examples of the controller 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 control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, the method steps can be logically programmed to enable the controller to be implemented in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, and embedded microcontrollers to achieve the same function. Therefore, such a controller can be regarded as a hardware component, and the devices included therein for implementing various functions can also be regarded as the structure within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or the structure within the hardware component.

[0074] The embodiments of the present application also provide a device, which includes: a processor; a memory for storing executable instructions of the processor; when the processor executes the executable instructions, the method described in the embodiments of the present application is implemented.

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

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

[0077] The above storage medium includes, but is not limited to, random access memory (English: Random Access Memory; abbreviation: RAM), read-only memory (English: Read-Only Memory; abbreviation: ROM), cache (English: Cache), hard disk drive (English: Hard Disk Drive; abbreviation: HDD), or memory card (English: Memory Card). The memory can be used to store computer program instructions.

[0078] From the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary hardware. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, or can also be embodied in the implementation process of data migration. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disc, etc., and includes several instructions to enable a computer device (which can be a personal computer, mobile terminal, server, or network device, etc.) to execute the methods described in each embodiment or some parts of each embodiment of this application.

[0079] The various embodiments in this specification are described in a progressive manner. For the same or similar parts between the various embodiments, reference can be made to each other. The key point of each embodiment is to illustrate 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 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, and so on.

[0080] The above embodiments are only used to illustrate the technical solutions of this application, rather than to limit this application; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of this application.

Claims

1. A method for finding a code-associated file, characterized in that The method includes: Obtaining the name and type of the compiler for compiling the current code, and determining the command to be parsed for the current code according to the compiler name and the compiler type; Performing syntax analysis processing on the command to be parsed to obtain a parameter dictionary, where the parameter dictionary includes multiple sets of command parameter data in the form of key-value pairs. The key in the command parameter data is the command parameter in the command to be parsed, and the value in the command parameter data is the assignment information corresponding to the command parameter. The assignment information includes source file information, reference file information, and preprocessing command information associated with the current code; Performing parameter extraction on the parameter dictionary to obtain the assignment information corresponding to multiple command parameters; Performing matching and screening on the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code.

2. The method according to claim 1, wherein The assignment information further includes indirectly referenced source file information; The performing parameter extraction on the parameter dictionary to obtain the assignment information corresponding to multiple command parameters further includes: Performing parameter extraction on the parameter dictionary to obtain the reference file information and preprocessing command information corresponding to multiple command parameters; Judging whether the compiler type supports the operation of indirectly referencing source files. When the compiler type supports the operation of indirectly referencing source files, performing analysis and extraction operations on the reference file information and preprocessing command information to obtain indirectly referenced source file information.

3. The method according to claim 1, wherein The performing matching and screening on 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: 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; Performing screening processing on the marked second sub-initial file set in the initial file set according to a preset screening strategy to obtain the unmarked first sub-initial file set in the initial file set. The unmarked first sub-initial file set includes the source file set and reference file set associated with the current code.

4. The method according to claim 3, wherein The preset screening strategy includes any one of file hiding, prohibiting reading, and moving out of the directory.

5. The method according to claim 1, wherein After performing matching and screening on the initial file set according to the assignment information to obtain the source file set and reference file set associated with the current code, it further includes: Performing syntax check processing on the source file set and the reference file set, and judging whether there is syntax expansion in the source file set or the reference file set. When there is syntax expansion in the source file set or the reference file set, backing up the source file set or the reference file set.

6. The method according to claim 5, characterized in that The syntax expansion includes any one of preprocessing command expansion or indirectly referenced source file expansion.

7. The method according to claim 1, characterized in that, The matching and screening includes any one of regular expression or wildcard expression.

8. A searching device for code-related files, characterized in that, It includes: An obtaining module, configured to obtain the name and type of the compiler for compiling the current code, and determine the command to be parsed for the current code according to the compiler name and the compiler type; A processing module, configured to perform syntax analysis processing on the command to be parsed, so as to obtain a parameter dictionary, where the parameter dictionary includes multiple groups of command parameter data in the form of key-value pairs, the key in the command parameter data is the command parameter in the command to be parsed, and the value in the command parameter data is the assignment information corresponding to the command parameter, and the assignment information includes source file information, reference file information, and preprocessing command information associated with the current code; An extraction module, configured to extract parameters from the parameter dictionary to obtain the assignment information corresponding to multiple command parameters; A screening module, configured to perform matching and screening on the initial file set according to the assignment information to obtain a source file set and a reference file set associated with the current code.

9. A computer device, comprising a memory and a processor, the memory storing a computer program that can 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 7 are implemented.

10. 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 7 is implemented.

Citation Information

Patent Citations

  • Code file processing method and system, computer equipment and readable storage medium

    CN109918076A

  • Code segment positioning method and device, computer equipment and storage medium

    CN110134401A

  • File filtering method and device, electronic equipment and storage medium

    CN113946853A

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

    CN114185852A

  • AVX2SVE code transplantation and optimization method based on compiler expansion

    CN117591174A