Code text management method, device, storage medium and terminal equipment
By performing module analysis of code text and generating module configuration files, determining and introducing top-level modules, the reliability and low efficiency problems caused by complex dependencies between modules in web pages are solved, and clear code sorting and operation efficiency are achieved.
Patent Information
- Application Number
- CN201910039494.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-01-16
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2039-01-16
AI Technical Summary
With the increase in web page functions, the dependencies between modules become complicated, resulting in confusion of code and problems with the reliability and low operation efficiency of web pages.
By performing module parsing of the code text to be managed, generating module configuration files, identifying and introducing top-level modules in dependencies, to avoid duplicate introduction and code confusion.
It effectively solves the problem of confusing dependencies between modules and improves the reliability and operation efficiency of web programs.
Smart Images

Figure CN109871229B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a code text management method, device, storage medium and terminal equipment. Background Art
[0002] With the development of Internet technology, front-end HTML5 has achieved modularization, that is, each function is encapsulated into a module and directly referenced when needed. Inevitably, there is a mutual dependency between the functional modules. For example, the implementation of the function of module A requires calling the interface of module B, that is, module A depends on module B.
[0003] As functions and modules gradually increase, the dependencies between modules become confusing and complicated. The same module is often referenced repeatedly, which easily causes code confusion and leads to problems with web page reliability and low operating efficiency. Summary of the invention
[0004] In view of this, the embodiments of the present invention provide a code text management method, apparatus, storage medium and terminal device to solve the problem in the prior art that the reliability and operation efficiency of the web page are low due to the confusion of the dependencies between modules of the web page code.
[0005] A first aspect of an embodiment of the present invention provides a method for managing code texts, which may include:
[0006] Acquire the code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes module names in the code text and dependencies between modules corresponding to the module names;
[0007] Generate a module configuration file of the code text according to the module information;
[0008] The name of the parent module in the module configuration file is determined, and the parent module corresponding to the name is introduced into the code text, wherein the parent module is the top-level module in the dependency relationship.
[0009] A second aspect of an embodiment of the present invention provides a code text management device, which may include:
[0010] A module parsing unit, used to obtain a code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes module names in the code text and dependencies between modules corresponding to the module names;
[0011] A file generating unit, used for generating a module configuration file of the code text according to the module information;
[0012] The module introduction unit is used to determine the name of the parent module in the module configuration file and introduce the parent module corresponding to the name into the code text, wherein the parent module is the top-level module in the dependency relationship.
[0013] According to a third aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0014] Acquire the code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes module names in the code text and dependencies between modules corresponding to the module names;
[0015] Generate a module configuration file of the code text according to the module information;
[0016] The name of the parent module in the module configuration file is determined, and the parent module corresponding to the name is introduced into the code text, wherein the parent module is the top-level module in the dependency relationship.
[0017] According to a third aspect of an embodiment of the present invention, a terminal device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0018] Acquire the code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes module names in the code text and dependencies between modules corresponding to the module names;
[0019] Generate a module configuration file of the code text according to the module information;
[0020] The name of the parent module in the module configuration file is determined, and the parent module corresponding to the name is introduced into the code text, wherein the parent module is the top-level module in the dependency relationship.
[0021] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0022] The embodiment of the present invention performs module parsing on the code text to be managed, parses out all module information contained in the code text, that is, the name of the module and the dependency relationship between the modules corresponding to the name of each module, and effectively decouples the code text; generates a module configuration file of the code text according to all the module information, that is, the module configuration file records the name of each module in the code text and the dependency relationship between the modules, can sort out the dependency relationship between the modules in the code text, and effectively solves the problem of confusion in the dependency relationship; then determines the name of the parent module in the module configuration file, that is, determines the module at the top level in the dependency relationship of each module in the code text, and introduces the parent module into the code text. Since the parent module is at the top level in the dependency relationship of each module, other modules eventually need to rely on the parent module. The parent module is directly introduced into the code text, which avoids the code confusion caused by repeated introduction of modules and random introduction of modules, and effectively improves the reliability and operation efficiency of the web page program. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0024] Figure 1 It is a schematic diagram of the implementation flow of the code text management method provided by an embodiment of the present invention;
[0025] Figure 2 is a schematic diagram of a code text management device provided by an embodiment of the present invention;
[0026] Figure 3 It is a schematic diagram of a terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0028] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0029] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0030] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0031] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0032] In order to illustrate the technical solution of the present invention, a specific embodiment is provided below for illustration.
[0033] Figure 1 1 is a schematic diagram of an implementation flow of a code text management method provided by an embodiment of the present invention. As shown in the figure, the method may include the following steps:
[0034] Step S101, obtain the code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes module names in the code text and dependencies between modules corresponding to the module names.
[0035] In actual applications, the code text may only contain preset grammatical formats, such as code statements that reference modules, through which modules outside the code text (encapsulated codes that can implement certain functions) can be introduced, that is, the module may be outside the code text.
[0036] In one embodiment, performing module parsing on the code text to obtain module information of the code text includes:
[0037] The code text is parsed grammatically, and all complete sentences in the code text are obtained according to the result of the grammatical parsing.
[0038] Functional analysis is performed on the complete statement, and the code text is divided into at least one functional program segment according to the result of the functional analysis, and the functional program segments are numbered.
[0039] Each functional program segment is parsed respectively to obtain at least one module information of the functional program segment, wherein the module information includes the module name in the functional program segment and the dependency relationship between modules corresponding to the module name.
[0040] In practical applications, each complete statement in the code text is first identified, and then the function of the statement is determined. The statement is divided according to the function to obtain multiple functional program segments. Finally, the functional program segments are parsed to obtain the module names involved in the functional program segments and the dependency relationships between modules corresponding to the module names, that is, module information.
[0041] Because different functional program segments in the code text may involve different modules and different dependencies, the above method can accurately divide the code text into different functional program segments, and then parse the module information in units of functional program segments, so that the obtained dependency relationship is clearer and more accurate.
[0042] In one embodiment, the parsing of each functional program segment to obtain at least one module information of the functional program segment includes:
[0043] Each complete statement in the functional program segment is identified respectively to determine whether the complete statement contains a preset grammatical format.
[0044] If the complete sentence contains a preset grammatical format, the module name in the grammatical format is extracted, and the module corresponding to the module name is recorded as the first module.
[0045] The name of the module to which the complete statement belongs is determined, and the module corresponding to the module name is recorded as the second module.
[0046] The dependency relationship between the first module and the second module is determined according to the grammatical format, and the name of the first module, the name of the second module and the dependency relationship are marked as module information corresponding to the complete statement.
[0047] In actual applications, in code text, when module A depends on module B, a fixed syntax format is usually used to express the dependency relationship. Therefore, as long as this fixed syntax format (i.e., the preset syntax format) is identified, it means that there is a dependency relationship in the statement, and the dependency relationship can be sorted out according to the syntax format. It should be noted that a complete statement may contain or not contain a dependency relationship, or may contain one or more dependency relationships.
[0048] For example, if module A depends on module B, then a complete statement in module A contains the syntax format of import Bmodule; extract the module name in the syntax format, that is, B, and record module B as the first module; determine the module to which the current complete statement belongs, that is, module A, and record module A as the second module. Because the syntax format is contained in module A, that is, module B is referenced in module A, it can be determined that module A depends on module B based on the syntax format. Finally, A (module name), B (module name) and the dependency relationship (module A depends on module B) are packaged into the module information corresponding to the current complete statement.
[0049] Step S102: Generate a module configuration file of the code text according to the module information.
[0050] In one embodiment, the module configuration file of the code text is generated according to the module information, including:
[0051] The module information included in each functional program segment is counted respectively, and the dependency relationship between all modules in each functional program segment is sorted out according to the dependency relationship in the module information.
[0052] According to the dependency relationship between all modules in the functional program segment, a first configuration file of the functional program segment is generated, and the number of the functional program segment is used as the number of the first configuration file.
[0053] In order of numbering, the first configuration files are combined into a second configuration file, and the second configuration file is used as a module configuration file of the code text.
[0054] For example, the first functional program segment has two pieces of module information a and b, the dependency in a is module 1 depends on module 2, and the dependency in b is module 2 depends on module 3. Then the first configuration file of the first functional program segment is generated, and the first first configuration file contains module 1 depends on module 2, and module 2 depends on module 3; and the number of the first functional program segment, i.e. 1, is used as the number of the first configuration file, i.e. the first configuration file. Assuming there are 10 functional program segments in total, then by analogy, 10 first configuration files can be generated, and these 10 first configuration files can be combined into a module configuration file in the order of numbers.
[0055] That is, the first first configuration file contains the dependencies in the first functional program segment, the second first configuration file contains the dependencies in the second functional program segment, and so on.
[0056] Step S103, determining the name of the parent module in the module configuration file, and introducing the parent module corresponding to the name into the code text, wherein the parent module is the top-level module in the dependency relationship.
[0057] In practical applications, the code text can be regarded as a whole, corresponding to only one parent module, because the parent module is the top-level module in the dependency relationship of each module. Therefore, as long as the parent module is introduced, the modules that depend on it will naturally be referenced as well, thus avoiding the repeated introduction of the same module.
[0058] For example, the code text involves modules A, B, and C, and their dependency relationship is A depends on B, B depends on C, and A depends on C. Then C is the parent module of the code text. In the code text, modules A and B both need to depend on C. In this way, C only needs to be introduced once, avoiding the repeated introduction of module C.
[0059] Of course, there may be multiple functional program segments in a code text, and each functional program segment has different functions, and thus may involve different modules and have different dependencies between modules. Therefore, modules can be introduced in units of functional program segments, as follows.
[0060] In one embodiment, determining the name of the parent module in the module configuration file and introducing the parent module corresponding to the name into the code text includes:
[0061] The name of a top-level module in the dependency relationship included in the first configuration file is obtained, and the name of the module is used as the name of the parent module of the first configuration file.
[0062] After determining the name of the parent module of each first configuration file in the module configuration file, the parent modules corresponding to the name of the parent module are introduced into the code text in sequence according to the sequence of the numbers of the first configuration files.
[0063] In actual applications, modules are introduced in units of functional program segments. Multiple parent modules may appear in a code text (because each functional program segment corresponds to a parent module). Then, repeated parent modules may appear, that is, repeated references may occur. In order to avoid repeated introduction, in one embodiment, the parent modules are introduced into the code text in sequence according to the numbering order of the first configuration file, including:
[0064] Determine whether the current parent module has been introduced into the code text.
[0065] If the current parent module has been introduced into the code text, the introduction of the current parent module is stopped, and the next parent module is introduced in the order of the numbers of the first configuration files.
[0066] If the current parent module is not introduced in the code text, the parent module is introduced and marked as an introduced module.
[0067] Among them, judging whether it has been introduced is to avoid repeated introduction.
[0068] For example, the parent module of the first first configuration file is A, and the parent module of the second first configuration file is also A. Then, after A in the first first configuration file is introduced, A is marked as an introduced module. When the parent module of the second first configuration file is to be introduced, it is determined that the parent module A has been introduced (which can be determined by the mark of module A), and A in the second first configuration file is no longer introduced.
[0069] It should be noted that, as mentioned above, a code text may include the contents of a complete module, or may not include the contents of a module, but only include the name and dependencies of the module. For example, the code text includes the contents of module A, and module A has a preset syntax format import B module (i.e., only includes the name and dependencies of B). According to the syntax format, A depends on B. In other words, A is definitely not the parent module. Therefore, when the code text includes the contents of a module, the module is usually not the parent module of the code text, and there is no need to introduce it using the method of the present invention.
[0070] The embodiment of the present invention performs module parsing on the code text to be managed, parses out all module information contained in the code text, that is, the name of the module and the dependency relationship between the modules corresponding to the name of each module, and effectively decouples the code text; generates a module configuration file of the code text according to all the module information, that is, the module configuration file records the name of each module in the code text and the dependency relationship between the modules, can sort out the dependency relationship between the modules in the code text, and effectively solves the problem of confusion in the dependency relationship; then determines the name of the parent module in the module configuration file, that is, determines the module at the top level in the dependency relationship of each module in the code text, and introduces the parent module into the code text. Since the parent module is at the top level in the dependency relationship of each module, other modules eventually need to rely on the parent module. The parent module is directly introduced into the code text, which avoids the code confusion caused by repeated introduction of modules and random introduction of modules, and effectively improves the reliability and operation efficiency of the web page program.
[0071] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0072] Figure 2 It is a schematic diagram of a code text management device provided by an embodiment of the present invention. For the sake of convenience of explanation, only the part related to the embodiment of the present invention is shown.
[0073] Figure 2 The management device of the code text shown can be a software unit, a hardware unit, or a combination of software and hardware units built into an existing terminal device, or can be integrated into the terminal device as an independent hang-up, or can exist as an independent terminal device.
[0074] The code text management device 2 comprises:
[0075] The module parsing unit 21 is used to obtain the code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes the module name in the code text and the dependency relationship between modules corresponding to the module name.
[0076] The file generating unit 22 is used to generate a module configuration file of the code text according to the module information.
[0077] The module introduction unit 23 is used to determine the name of the parent module in the module configuration file and introduce the parent module corresponding to the name into the code text, wherein the parent module is the top-level module in the dependency relationship.
[0078] Optionally, the module parsing unit 21 includes:
[0079] The grammar analysis module is used to perform grammar analysis on the code text and obtain all complete sentences in the code text according to the result of the grammar analysis.
[0080] The function analysis module is used to perform function analysis on the complete statement, divide the code text into at least one function program segment according to the result of the function analysis, and number the function program segments.
[0081] The module information analysis module is used to analyze each functional program segment respectively to obtain at least one module information of the functional program segment, and the module information includes the module name in the functional program segment and the dependency relationship between modules corresponding to the module name.
[0082] Optionally, the module information parsing module includes:
[0083] The identification submodule is used to identify each complete statement in the functional program segment respectively, and determine whether the complete statement contains a preset grammatical format.
[0084] The extraction submodule is used to extract the module name in the grammatical format if the complete sentence contains a preset grammatical format, and record the module corresponding to the module name as the first module.
[0085] Determine a submodule, which is used to determine the name of the module to which the complete statement belongs, and record the module corresponding to the module name as the second module.
[0086] A packaging submodule is used to determine the dependency relationship between the first module and the second module according to the grammatical format, and mark the name of the first module, the name of the second module and the dependency relationship as module information corresponding to the complete statement.
[0087] Optionally, the file generating unit 22 includes:
[0088] The statistical module is used to count the module information contained in each functional program segment respectively, and sort out the dependency relationship between all modules in each functional program segment according to the dependency relationship in the module information.
[0089] The numbering module is used to generate a first configuration file of the functional program segment according to the dependency relationship between all modules in the functional program segment, and use the number of the functional program segment as the number of the first configuration file.
[0090] A generating module is used to combine the first configuration files into a second configuration file according to the sequence of numbers, and use the second configuration file as a module configuration file of the code text.
[0091] Optionally, the introduction module unit 23 includes:
[0092] The acquisition module is used to acquire the name of a top-level module in the dependency relationship included in the first configuration file, and use the name of the module as the name of the parent module of the first configuration file.
[0093] An introduction module is used to introduce the parent modules corresponding to the names of the parent modules into the code text in sequence according to the order of the numbers of the first configuration files after determining the names of the parent modules of each first configuration file in the module configuration file.
[0094] Optionally, the introduction module includes:
[0095] The judgment submodule is used to judge whether the current parent module has been introduced into the code text.
[0096] Stop importing submodules, if the current parent module has been imported into the code text, then stop importing the current parent module, and import the next parent module in the order of the numbers of the first configuration file.
[0097] The marking submodule is used to introduce the parent module if the current parent module is not introduced in the code text, and mark the parent module as an introduced module.
[0098] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0099] Figure 3 Schematic diagram of a terminal device provided by an embodiment of the present invention. Figure 3 As shown, the terminal device 3 of this embodiment includes: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30. When the processor 30 executes the computer program 32, the steps in the above-mentioned code text management method embodiments are implemented, for example Figure 1 Alternatively, when the processor 30 executes the computer program 32, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 2 The functions of modules 21 to 23 are shown.
[0100] Exemplarily, the computer program 32 may be divided into one or more modules / units, which are stored in the memory 31 and executed by the processor 30 to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 32 in the terminal device 3. For example, the computer program 32 may be divided into a module parsing unit, a file generating unit, and an importing module unit, and the specific functions of each unit are as follows:
[0101] The module parsing unit is used to obtain the code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes the module name in the code text and the dependency relationship between modules corresponding to the module name.
[0102] A file generating unit is used to generate a module configuration file of the code text according to the module information.
[0103] The module introduction unit is used to determine the name of the parent module in the module configuration file and introduce the parent module corresponding to the name into the code text, wherein the parent module is the top-level module in the dependency relationship.
[0104] Optionally, the module parsing unit includes:
[0105] The grammar analysis module is used to perform grammar analysis on the code text and obtain all complete sentences in the code text according to the result of the grammar analysis.
[0106] The function analysis module is used to perform function analysis on the complete statement, divide the code text into at least one function program segment according to the result of the function analysis, and number the function program segments.
[0107] The module information analysis module is used to analyze each functional program segment respectively to obtain at least one module information of the functional program segment, and the module information includes the module name in the functional program segment and the dependency relationship between modules corresponding to the module name.
[0108] Optionally, the module information parsing module includes:
[0109] The identification submodule is used to identify each complete statement in the functional program segment respectively, and determine whether the complete statement contains a preset grammatical format.
[0110] The extraction submodule is used to extract the module name in the grammatical format if the complete sentence contains a preset grammatical format, and record the module corresponding to the module name as the first module.
[0111] Determine a submodule, which is used to determine the name of the module to which the complete statement belongs, and record the module corresponding to the module name as the second module.
[0112] A packaging submodule is used to determine the dependency relationship between the first module and the second module according to the grammatical format, and mark the name of the first module, the name of the second module and the dependency relationship as module information corresponding to the complete statement.
[0113] Optionally, the file generating unit includes:
[0114] The statistical module is used to count the module information contained in each functional program segment respectively, and sort out the dependency relationship between all modules in each functional program segment according to the dependency relationship in the module information.
[0115] The numbering module is used to generate a first configuration file of the functional program segment according to the dependency relationship between all modules in the functional program segment, and use the number of the functional program segment as the number of the first configuration file.
[0116] A generating module is used to combine the first configuration files into a second configuration file according to the sequence of numbers, and use the second configuration file as a module configuration file of the code text.
[0117] Optionally, the introduction module unit includes:
[0118] The acquisition module is used to acquire the name of a top-level module in the dependency relationship included in the first configuration file, and use the name of the module as the name of the parent module of the first configuration file.
[0119] An introduction module is used to introduce the parent modules corresponding to the names of the parent modules into the code text in sequence according to the order of the numbers of the first configuration files after determining the names of the parent modules of each first configuration file in the module configuration file.
[0120] Optionally, the introduction module includes:
[0121] The judgment submodule is used to judge whether the current parent module has been introduced into the code text.
[0122] Stop importing submodules, if the current parent module has been imported into the code text, then stop importing the current parent module, and import the next parent module in the order of the numbers of the first configuration file.
[0123] The marking submodule is used to introduce the parent module if the current parent module is not introduced in the code text, and mark the parent module as an introduced module.
[0124] The terminal device 3 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 30 and a memory 31. Those skilled in the art will appreciate that Figure 3 It is only an example of the terminal device 3 and does not constitute a limitation on the terminal device 3. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
[0125] The processor 30 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0126] The memory 31 may be an internal storage unit of the terminal device 3, such as a hard disk or memory of the terminal device 3. The memory 31 may also be an external storage device of the terminal device 3, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 3. Further, the memory 31 may also include both an internal storage unit and an external storage device of the terminal device 3. The memory 31 is used to store the computer program and other programs and data required by the terminal device. The memory 31 may also be used to temporarily store data that has been output or is to be output.
[0127] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0128] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0129] In the embodiments provided by the present invention, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0130] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0131] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0132] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0133] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for managing code texts, characterized in that: include: Acquire the code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes module names in the code text and dependencies between modules corresponding to the module names; Generate a module configuration file of the code text according to the module information; Determine the name of the parent module in the module configuration file, and introduce the parent module corresponding to the name into the code text, wherein the parent module is the top-level module in the dependency relationship; The module parsing of the code text to obtain module information of the code text includes: Performing grammatical analysis on the code text, and obtaining all complete sentences in the code text according to the result of the grammatical analysis; Performing functional analysis on the complete statement, dividing the code text into at least one functional program segment according to the result of the functional analysis, and numbering the functional program segments; Parsing each functional program segment respectively to obtain at least one module information of the functional program segment, wherein the module information includes a module name in the functional program segment and a dependency relationship between modules corresponding to the module name; The step of determining the name of the parent module in the module configuration file and introducing the parent module corresponding to the name into the code text includes: Obtain the name of a top-level module in the dependency relationship included in the first configuration file, and use the name of the module as the name of the parent module of the first configuration file; After determining the name of the parent module of each first configuration file in the module configuration file, determine whether the current parent module has been introduced into the code text according to the order of the numbers of the first configuration files; if the current parent module has been introduced into the code text, stop introducing the current parent module, and introduce the next parent module according to the order of the numbers of the first configuration files.
2. The code text management method according to claim 1, characterized in that: The step of respectively parsing each functional program segment to obtain at least one module information of the functional program segment includes: Respectively identifying each complete statement in the functional program segment to determine whether the complete statement contains a preset grammatical format; If the complete sentence contains a preset grammatical format, extracting a module name in the grammatical format, and recording a module corresponding to the module name as a first module; Determine the name of the module to which the complete statement belongs, and record the module corresponding to the module name as the second module; The dependency relationship between the first module and the second module is determined according to the grammatical format, and the name of the first module, the name of the second module and the dependency relationship are marked as module information corresponding to the complete statement.
3. The code text management method according to claim 1, characterized in that: The module configuration file for generating the code text according to the module information includes: Counting the module information contained in each functional program segment respectively, and sorting out the dependency relationship between all modules in each functional program segment according to the dependency relationship in the module information; Generate a first configuration file of the functional program segment according to the dependency relationship between all modules in the functional program segment, and use the number of the functional program segment as the number of the first configuration file; In order of numbering, the first configuration files are combined into a second configuration file, and the second configuration file is used as a module configuration file of the code text.
4. The code text management method according to claim 3, characterized in that: If the current parent module is not introduced in the code text, the parent module is introduced and marked as an introduced module.
5. A code text management device, characterized in that: include: A module parsing unit, used to obtain a code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes module names in the code text and dependencies between modules corresponding to the module names; A file generating unit, used for generating a module configuration file of the code text according to the module information; An import module unit is used to determine the name of a parent module in the module configuration file, and introduce the parent module corresponding to the name into the code text, wherein the parent module is a top-level module in the dependency relationship; Wherein, the module parsing unit includes: A syntax analysis module, used for performing syntax analysis on the code text, and obtaining all complete sentences in the code text according to the result of the syntax analysis; A function analysis module, used for performing function analysis on the complete statement, dividing the code text into at least one function program segment according to the result of the function analysis, and numbering the function program segments; A module information analysis module, used to analyze each functional program segment respectively to obtain at least one module information of the functional program segment, wherein the module information includes a module name in the functional program segment and a dependency relationship between modules corresponding to the module name; The introduction module unit comprises: An acquisition module, used to acquire the name of a top-level module in the dependency relationship contained in the first configuration file, and use the name of the module as the name of the parent module of the first configuration file; An introduction module is used to, after determining the name of the parent module of each first configuration file in the module configuration file, introduce the parent modules corresponding to the name of the parent module into the code text in sequence according to the order of the numbers of the first configuration files; The introduction module includes: A judgment submodule is used to judge whether the current parent module has been introduced into the code text; Stop importing submodules, if the current parent module has been imported into the code text, then stop importing the current parent module, and import the next parent module in the order of the numbers of the first configuration file.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the program management method according to any one of claims 1 to 4 are implemented.
7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: Acquire the code text to be managed, and perform module parsing on the code text to obtain module information of the code text, wherein the module information includes module names in the code text and dependencies between modules corresponding to the module names; Generate a module configuration file of the code text according to the module information; Determine the name of the parent module in the module configuration file, and introduce the parent module corresponding to the name into the code text, wherein the parent module is the top-level module in the dependency relationship; The module parsing of the code text to obtain module information of the code text includes: Performing grammatical analysis on the code text, and obtaining all complete sentences in the code text according to the result of the grammatical analysis; Performing functional analysis on the complete statement, dividing the code text into at least one functional program segment according to the result of the functional analysis, and numbering the functional program segments; Parsing each functional program segment respectively to obtain at least one module information of the functional program segment, wherein the module information includes a module name in the functional program segment and a dependency relationship between modules corresponding to the module name; Among them, the determining the name of the parent module in the module configuration file and introducing the parent module corresponding to the name into the code text includes: obtaining the name of the top-level module in the dependency relationship contained in the first configuration file, and using the name of the module as the name of the parent module of the first configuration file; after determining the name of the parent module of each first configuration file in the module configuration file, judging whether the current parent module has been introduced into the code text according to the order of the numbers of the first configuration files; if the current parent module has been introduced into the code text, stopping the introduction of the current parent module, and introducing the next parent module according to the order of the numbers of the first configuration files.
