CN112256637A - File management method and device based on abstract syntax tree and storage medium - Google Patents
File management method and device based on abstract syntax tree and storage medium Download PDFInfo
- Publication number
- CN112256637A CN112256637A CN202011117804.1A CN202011117804A CN112256637A CN 112256637 A CN112256637 A CN 112256637A CN 202011117804 A CN202011117804 A CN 202011117804A CN 112256637 A CN112256637 A CN 112256637A
- Authority
- CN
- China
- Prior art keywords
- file
- project
- project file
- record
- dependency
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/14—Details of searching files based on file metadata
- G06F16/148—File search processing
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Library & Information Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The application discloses a file management method, a device and a storage medium based on an abstract syntax tree, which specifically comprise the following steps: analyzing a forward dependency relationship among the project files by using the abstract syntax tree, establishing a forward dependency record for each project file, and forming a global path object set by storage paths in all forward dependency record attributes; traversing all the attributes of the forward dependency records, and creating a backward dependency record for the second item file in each attribute; when the project file is modified, the project file is reversely searched by utilizing the attribute of the reverse dependency record of the modified project file, and the range of the affected project file is determined according to the searched project file. By applying the scheme of the application, because the backward dependence record is established for each project file, when a certain project file is modified, the affected range can be quickly determined, errors or confusion caused by modifying the project file are avoided, and the efficiency and the quality of the whole service on line are ensured.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a file management method based on an abstract syntax tree, a file management apparatus based on an abstract syntax tree, a computer-readable storage medium, and an electronic device.
Background
When some services on the line continuously meet the requirements of users, the updating and the iteration are continuously carried out. The project files of the whole business system are very huge, close reference and referenced dependency relationship exist among the project files, and the project files in the business system need to be managed in the updating and iteration process of the business system, so that errors or confusion caused by updating and iteration are avoided. For example, in order to modify the function of a certain line in the front end of the business system, a technician modifies a certain item file or certain item files in the system. If the affected area of the file in the system is not accurately found and the function test is performed, errors or confusion of the system can be caused. To do so, technicians typically manually clean the relationships of project files within the system and determine whether they are affected by modifying the files. Finding the affected range of the modified file in a huge business system is very heavy, which not only wastes a lot of human resources, but also seriously affects the online efficiency and quality of the business system.
Disclosure of Invention
In view of the foregoing prior art, an embodiment of the present application discloses a file management method based on an abstract syntax tree, which can avoid a large amount of manpower to manage and ensure online efficiency and quality of a service system.
The embodiment of the application discloses a file management method based on an abstract syntax tree, which specifically comprises the following steps:
a method for file management based on abstract syntax trees, the method comprising:
analyzing a forward dependency relationship among project files in a business system by using an abstract syntax tree, and establishing a forward dependency record for the project files to express the forward dependency relationship; the forward dependency represents a reference relationship from a first project file to a second project file, the first project file references the second project file, a storage path of the second project file is contained in an attribute of a forward dependency record of the first project file, and the storage path in the attribute of the forward dependency record in the service system forms a global path object set;
traversing a storage path in the attributes of the forward dependency records in the global path object set, creating a backward dependency record for a second project file corresponding to the storage path in the attributes, wherein the backward dependency record represents a backward dependency relationship between the project files, and adding the storage paths of all first project files referencing the second project file to the attributes of the backward dependency record of the second project file;
when the project file is modified, the project file is reversely searched by utilizing the attribute of the reverse dependency record of the modified project file, the range of the affected project file is determined according to the searched project file, and the affected project file is synchronized to the testing process flow.
Further, the air conditioner is provided with a fan,
the step of analyzing the forward dependency relationship among the project files in the business system by using the abstract syntax tree and establishing a forward dependency record for the project files to express the forward dependency relationship comprises the following steps:
taking an entry file of the business system as a current entry file;
creating an abstract syntax tree for the current entry file by utilizing a lexical method and a syntax analysis method;
traversing the abstract syntax tree of the current entry file, establishing a forward dependency record for the project file in the abstract syntax tree of the current entry file in the traversing process, taking the project file as a first project file, taking the project file quoted by the project file as a second project file, adding a storage path of the second project file into the attribute of the forward dependency record of the first project file, and simultaneously storing the attribute into the created global path object set;
and taking the next entry file of the business system as a current entry file, and returning to the step of creating the abstract syntax tree for the current entry file by utilizing the lexical and syntactic analysis method until the entry file of the business system is processed.
Further, the air conditioner is provided with a fan,
between the step of creating a forward dependency record for each project file to represent the forward dependency relationship and the step of traversing the storage path of the attributes of the forward dependency record in the global path object set, the method further comprises:
and traversing the attributes of the forward dependency records of all the project files in the system service, and merging the repeated attributes in the forward dependency records.
Further, the air conditioner is provided with a fan,
when the project file is modified, the step of reversely searching the project file by using the attribute of the reversely dependent record of the modified project file comprises the following steps:
taking the modified project file as a current second project file;
determining a corresponding backward dependence record according to the current second project file, and obtaining a storage path of the first project file stored in the attribute of the backward dependence record so as to determine the current first project file searched reversely;
and taking the searched current first project file as a second project file, and then returning to execute the step of determining the corresponding backward dependence record according to the current second project file until the entry file in the service system is searched in a backward direction.
Further, the air conditioner is provided with a fan,
when a function in the business system is offline, the method further comprises the following steps:
determining an entry file corresponding to a function needing offline, and taking the entry file as an entry file to be offline;
determining all project files needing to be deleted in the business system by using the positive dependency relationship from the entry file to be offline, and marking the project files in the attribute of the positive dependency record where the project files are located;
deleting the project file which needs to be deleted in the service system, traversing the attribute of the forward dependence record of the project file, and deleting the reference relation corresponding to the mark which needs to be deleted in the attribute.
Further, the air conditioner is provided with a fan,
the step of determining the item file to be deleted in the business system by using the positive dependency relationship from the entry file to be downloaded, and marking the attribute of the positive dependency record includes:
creating an abstract syntax tree for the entry file to be downloaded by using the lexical method and the syntax analysis method;
traversing the abstract syntax tree of the file to be downlinked, establishing a forward dependency record for the project file in the abstract syntax tree of the file to be downlinked in the traversing process, taking the project file as a first project file, taking the project file quoted by the first project file as a second project file, adding a storage path of the second project file into the attribute of the forward dependency record of the first project file, simultaneously storing the attribute into the created local path object set, and calculating the quoted times of the first project file;
determining item files corresponding to the same storage path in the global path object set and the local path object set; and subtracting the referenced times in the same item file, and taking the difference value 0 as the mark needing to be deleted.
The embodiment of the application also discloses a file management device based on the abstract syntax tree, which can avoid a large amount of manpower to manage and ensure the online efficiency and quality of the service system. The embodiment of the application discloses a file management device based on an abstract syntax tree, which specifically comprises:
an abstract syntax tree-based file management apparatus, the apparatus comprising:
the forward dependency record establishing unit is used for analyzing a forward dependency relationship among project files in a business system by using an abstract syntax tree and establishing a forward dependency record for the project files to express the forward dependency relationship; the forward dependency represents a reference relationship from a first project file to a second project file, the first project file references the second project file, the attribute of a forward dependency record of the first project file comprises a storage path of the second project file, and the storage path in the attribute of the forward dependency record in the service system forms a global path object set;
the backward dependency record establishing unit is used for traversing a storage path in the attribute of the forward dependency record in the global path object set, creating a backward dependency record for a second project file corresponding to the storage path in the attribute, wherein the backward dependency record represents a backward dependency relationship among the project files, and adding the storage paths of all first project files which refer to the second project file into the attribute of the backward dependency record of the second project file;
and the affected range determining unit is used for reversely searching the project files by utilizing the attributes of the reverse dependency records of the modified project files when the project files are modified, determining the range of the affected project files according to the searched project files, and synchronizing the affected project files to the test processing flow.
Further, the air conditioner is provided with a fan,
the forward dependency record creating unit includes:
a first abstract syntax tree establishing subunit, configured to use an entry file of the service system as a current entry file, and establish an abstract syntax tree for the current entry file by using a lexical method and a syntax analysis method;
the first record establishing and executing subunit is used for traversing the abstract syntax tree of the current entry file, establishing a forward dependency record for the project file in the abstract syntax tree of the current entry file in the traversing process, taking the project file as the first project file, taking the project file quoted by the project file as the second project file, adding the storage path of the second project file to the attribute of the forward dependency record of the first project file, and simultaneously storing the attribute into the created global path object set; and taking the next entry file of the business system as a current entry file, and returning to the step of creating the abstract syntax tree for the current entry file by utilizing the lexical and syntactic analysis method until the entry file of the business system is processed.
The apparatus further comprises:
and the merging unit is used for traversing the attributes of the forward dependency records of the project files in the system service and merging the repeated attributes in the forward dependency records.
Further, the air conditioner is provided with a fan,
the affected range determining unit includes:
the reverse search subunit is used for determining a corresponding reverse dependency record according to the current second project file and obtaining a storage path of the first project file stored in the attribute of the reverse dependency record to determine the current first project file which is reversely searched;
and the appointing subunit is used for taking the searched current first project file as a second project file, and then returning to execute the step of determining the corresponding backward dependence record according to the current second project file until the entry file in the service system is reversely searched.
The apparatus further comprises:
the offline entry file determining unit is used for determining an entry file corresponding to a function needing offline as an entry file to be offline when one function in the business system is offline;
a deleted object determining unit, configured to determine, starting from the entry file to be offline, an item file to be deleted in the business system by using the positive dependency relationship, and mark the item file in an attribute of a positive dependency record where the item file is located;
and the deletion execution unit is used for deleting the item file which needs to be deleted in the service system, traversing the attribute of the forward dependence record of the item file, and deleting the reference relation corresponding to the mark which needs to be deleted in the attribute.
Further, the air conditioner is provided with a fan,
the deletion object determination unit includes:
the second abstract syntax tree establishing subunit is used for establishing an abstract syntax tree for the entry file to be downloaded by utilizing the lexical and syntax analysis methods;
a second record establishing and executing subunit, configured to traverse the abstract syntax tree of the to-be-downlinked entry file, establish a forward dependency record for a project file in the abstract syntax tree of the to-be-downlinked entry file in the traversal process, use the project file as a first project file, use a project file referred by the project file as a second project file, add a storage path of the second project file to an attribute of the forward dependency record of the first project file, simultaneously store the storage path into the created local path object set, and calculate the number of times the first project file is referred;
a deletion mark determining subunit, configured to determine item files corresponding to the same storage path in the global path object set and the local path object set; and subtracting the referenced times in the same item file, and taking the difference value 0 as the mark needing to be deleted.
The embodiment of the application also discloses a computer readable storage medium, which stores computer instructions, and the instructions can realize the file management method based on the abstract syntax tree when being executed by a processor.
An embodiment of the present application further discloses an electronic device, which at least includes the computer-readable storage medium as described above, and further includes a processor;
the processor is configured to read the executable instructions from the computer-readable storage medium and execute the instructions to implement any one of the above-mentioned file management methods based on abstract syntax trees.
In summary, since the embodiment of the present application establishes the backward dependency record for each project file in the service system, when a certain project file is modified, the entry file of the service system can be obtained according to the tracing back of the backward dependency record, the affected range is quickly determined and the test is synchronously performed on the tester, thereby avoiding errors or confusion caused by modifying the project file, saving a large amount of human resources, and ensuring the efficiency and quality of the whole service on line.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
Fig. 1 shows a flow chart of a first embodiment of the method of the present application.
Fig. 2 is a schematic diagram illustrating a dependency relationship between project files in a business system.
Fig. 3 shows a flow chart of a second embodiment of the method of the present application.
Fig. 4 is a schematic diagram showing the dependency relationship between the project files in the entry file 1.
Fig. 5 is a schematic diagram showing the dependency relationship between the project files in the entry file 2.
Fig. 6 is a schematic diagram showing the dependency relationship between the project files in the entry file 3.
Fig. 7 shows a flow chart of a third embodiment of the method of the present application.
FIG. 8 is a flow chart of a method for determining a project file that needs to be deleted.
Fig. 9 is a schematic diagram showing the dependency relationship between the project files after the downline function is deleted.
Fig. 10 shows a schematic structural diagram of a first embodiment of the apparatus according to the present application.
Fig. 11 shows a schematic structural diagram of a second embodiment of the apparatus of the present application.
Fig. 12 shows a schematic structural diagram of a third embodiment of the apparatus of the present application.
Fig. 13 is a schematic structural diagram of an electronic device according to the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements explicitly listed, but may include other steps or elements not explicitly listed or inherent to such process, method, article, or apparatus.
The technical solution of the present invention will be described in detail with specific examples. Several of the following embodiments may be combined with each other and some details of the same or similar concepts or processes may not be repeated in some embodiments.
The method comprises the steps that a forward dependency relationship between project files of a business system is analyzed through an abstract syntax tree, and the reference relationship from a first project file to a second project file is represented by the forward dependency relationship; establishing a forward dependency record for each project file by utilizing a forward dependency relationship; and traversing all the forward dependency records, and creating a backward dependency record to obtain a backward dependency relationship of the second project file, which is referred by the first project file, so as to determine and manage the range of the affected project file when the business system is modified.
FIG. 1 is a flowchart of a first embodiment of a file management method based on an abstract syntax tree according to the present application. As shown in fig. 1, the method includes:
step 101: analyzing a forward dependency relationship among the project files in the service system by using the abstract syntax tree, and establishing a forward dependency record for each project file to express the forward dependency relationship; the forward dependency represents a reference relationship from a first project file to a second project file, the first project file references the second project file, and a storage path of the second project file is added to the attribute of the forward dependency record of the first project file; and all storage paths in the forward dependency record attributes in the service system form a global path object set.
In the field of computer technology, an Abstract Syntax Tree (AST) is an abstract representation of a syntax structure of source code, and represents the syntax structure of a language in a tree form, wherein each node on the tree represents a structure in the source code. In practical applications, for example, the abstract syntax tree can be obtained by lexical analysis and syntactic analysis using the createSourceFile method provided by TypeScript language.
Because a large number of project files in the business system have dependency relationships, the work of analyzing the dependency relationships by using manpower is very complicated. According to the method and the device, the forward dependency relationship among the project files in the business system is analyzed by using the abstract syntax tree instead of manual analysis. Such as: and (3) transmitting the entry file of the service system as a parameter to a TypeScript language createSourceFile method, and obtaining the abstract syntax tree of the entry file through the analysis of the createSourceFile method. If the service system has a plurality of entry files, the createSourceFile method can be used for a plurality of times to obtain the abstract syntax tree of all the entry files of the service system.
The "dependency" described in the embodiments of the present application is a reference relationship between one project file and another project file in a business system, and is not particularly limited to a specific project file. For example, one of the project files is referred to as a "first project file", and the other project file is referred to as a "second project file". If a second project file is referenced in a first project file, then the dependency from the first project file to the second project file is referred to as a forward dependency. In order to clearly express such forward dependency relationships, the embodiment of the present application may create a forward dependency record for each project file by traversing the abstract syntax tree, and add the storage path of the referenced project file to the attribute of its record. If a second project file is referenced in the first project file, a storage path of the second project file may be added to the attributes of the first project file when traversing the abstract syntax tree to create a forward dependency record for the first project file.
Fig. 2 is a schematic diagram showing a dependency relationship between project files in a certain service system. Suppose there are 3 entry files in a business system, these entry files refer to files 1 to 4, and files 1 to 4 refer to subfiles 1 to 6, respectively. In order to express the dependency relationship between the project files, in practical applications, the number of the project files in the business system is larger, and the relationship is more complex. In this example, when the forward dependency record is created for the entry file2, since the entry file2 refers to the file2 and the file4, the entry file2 serves as a first project file, the file2 and the file4 serve as a second project file, and the storage paths of the file2 and the file4 are added to the attribute of the forward dependency record of the entry file 2. The first project file and the second project file described herein are not a specific file but refer to two files having a reference relationship. When establishing the forward dependency record for file2, file2 will be the first project file and its referenced subfiles 3 and 5 will be the second project file.
In summary, forward dependency records can be built for all project files to represent forward dependencies in the manner described above. Then, all the established forward dependency records represent the forward dependency relationships among all the project files in the business system, and the storage path in the attribute is referred to as a "global path object set" in the embodiment of the present application. The "global path object set" is not a set with other special meanings, and refers to the sum of the paths stored in all the forward dependency records in the business system.
Step 102: and traversing storage paths in the attributes of all the forward dependency records in the global path object set, creating a backward dependency record for the second project file corresponding to the storage path in each attribute, wherein the backward dependency record represents the backward dependency relationship among the project files, and adding the storage paths of all the first project files which refer to the second project file to the attributes of the backward dependency record of the second project file.
As described above, in the process of continuously modifying and iterating the functions of the business system, a certain project file is modified. If other project files directly or indirectly reference the modified project file, errors or confusion may occur. Thus, when a project file is to be modified, it is necessary to determine other project files that directly or indirectly reference the modified project file. However, the step 101 establishes a forward dependency record from which it is difficult to determine. To this end, this step creates an inverse dependency record for the project file. It is assumed that the "dependency" described in the embodiments of the present application is a reference relationship between one project file and another project file in a business system. For example, one of the project files is referred to as a "first project file", and the other project file is referred to as a "second project file". If a second project file is referenced in a first project file, then the dependency from the first project file to the second project file is referred to as a forward dependency and vice versa as a backward dependency. In order to clearly express such a backward dependency relationship, the embodiment of the present application traverses the attributes of all forward dependency records, establishes a backward dependency record for each project file, and adds the storage path referring to the project file of itself to the attributes of the backward dependency record of itself. If the second project file is referred to in the first project file, the second project file can be determined when the forward dependency record of the first project file is traversed, a backward dependency record is established for the determined second project file, and the storage path of the first project file is added to the attribute of the backward dependency record of the second project file.
Still taking FIG. 2 as an example, assuming that traversing to File2, the forward dependency record of File2 contains storage paths for subfiles 3 and 5. At this time, an inverse dependency record may be established for the subfile 3, and the storage path of the file2 may be added to the attribute of the inverse dependency record of the subfile 3, so as to represent the inverse dependency relationship between the subfile 3 and the file 2.
Step 103: when the project file is modified, the project file is reversely searched by utilizing the attribute of the reverse dependency record of the modified project file, the range of the affected project file is determined according to the searched project file, and the affected project file is synchronized to the testing process flow.
Because the backward dependency record is established for each project file, when a certain project file is modified, the backward dependency record of the modified project file can be inquired to directly obtain other project files which refer to the modified project file, then the other project files are inquired upwards layer by layer, and finally a certain entry file or certain entry files of a service system can be traced back, so that the affected range can be quickly determined. At this time, if the entry files in the determined affected range are synchronized to the tester, the tester can only test some functions of the affected entry files, thereby avoiding errors or confusion caused by modifying the project files and ensuring the efficiency and quality of the whole service on line.
The application also provides another file management method embodiment based on the abstract syntax tree. In the second embodiment, the forward dependency record is represented by a data structure of a type K-V. Fig. 3 is a flow chart of a second embodiment of a method. As shown in fig. 3, the method includes:
step 301: and taking one entry file of the business system as the current entry file.
Step 302: and creating an abstract syntax tree for the current entry file by utilizing a lexical method and a syntax analysis method.
Step 303: traversing the abstract syntax tree of the current entry file, establishing a forward dependency record for each project file in the abstract syntax tree of the current entry file in the traversing process, taking each project file as a first project file, taking the project file quoted by the project file as a second project file, adding a storage path of the second project file into the attribute of the forward dependency record of the first project file, and simultaneously storing the attribute into the created global path object set.
The steps 301 to 303 establish the abstract syntax tree and the forward dependency records of all project files in the abstract syntax tree for the current entry file. Still taking fig. 2 as an example, when the current entry file is entry file1, a schematic diagram of a reference relationship between the entry files in the created abstract syntax tree is shown in fig. 4; when the current entry file is entry file2, the schematic diagram of the reference relationship between the entry files in the established abstract syntax tree is shown in fig. 5; fig. 6 is a schematic diagram of a reference relationship between project files in the created abstract syntax tree when the current portal file is the portal file 3.
The forward dependency record of each project file can be represented by a K-V data structure, wherein the K value is the record name of the forward dependency record, and the V value can be used as the attribute of the forward dependency record. For example, when creating a forward dependency record for file1 in the abstract syntax tree of entry file1, the K-V data structure of this file1 can be represented as:
watch 1
The utilization code can be expressed as follows:
js represents a storage path of the file1 as a K value of the forward dependency record of the file 1; js represents the storage path of the subfile 1, 2/index.js represents the storage path of the subfile 2, and 4/index.js represents the storage path of the subfile 4 as the V value of the file1 forward dependency record.
In practical applications, other attributes, such as the number of times of being referred to, may also be set for the forward dependency record to indicate the number of times that the traversed current project file is referred to by other project files. At this time, the K-V data structure thereof can be expressed as:
watch two
The utilization code can be expressed as follows:
where value represents the number of times file1/index. js is referenced. Of course, if it is not necessary to determine the number of times the project file is referred to in the file management process, "value" may not be set.
When traversing the abstract syntax tree, firstly judging whether the storage path of the currently traversed project file is already stored in the attribute of the forward dependency record, and if so, directly adding 1 to the number of times of reference (value); if the item file is not saved, a new forward dependency record (K-V data structure) is created, the storage path of the currently traversed item file is used as the record name (K value), and the initial value of the number of times of reference (value) is set to be 1.
Step 304: judging whether all the entry files are processed or not, if so, executing step 306; otherwise, step 305 is performed.
Step 305: the next entry file is taken as the current file and returns to step 302.
According to the method from step 301 to step 305, the embodiment of the present application may establish forward dependency records for project files under each entry file. Since the project file under a certain entry file is a part of the whole business system, and the forward dependency records the storage path in which the project file is stored, the embodiment of the present application may be referred to as a "local path object set".
Step 306: and traversing the attributes of the forward dependency records of all the project files in the system service, and merging the repeated attributes in the forward dependency records.
Although the forward dependency records are already established for the project files under the respective entry files in steps 301 to 305, due to the complexity of the reference relationship of the project files, duplicate forward dependency records may be established for a certain project file. Such as: in the schematic diagram of the dependency relationship of the project file under the entry file1 shown in fig. 4, the file1 refers to the subfile 2, and then the attribute of the forward dependency record of the file1 includes the storage path of the subfile 2, and a forward dependency record is established for the subfile 2. In the entry file of the entry file 3 shown in fig. 6, the file 3 also refers to the subfile 2, the attribute of the forward dependency record of the file 3 also includes the storage of the subfile 2, and a forward dependency record is also established for the subfile 2. In order to avoid confusion of file management caused by creating repeated forward dependency records for the same project file, the embodiment of the present application performs a merging process on the repeated attributes in step 306. Of course, in practical applications, if the attributes in the forward dependency record of the project file are not duplicated, the merging process is not required, i.e., step 306 is omitted. When the duplicate attributes are merged, the record names (K values) of different forward dependent records can be merged, and the uniqueness of the attributes (V values) can be ensured.
At this time, forward dependency records have been established for all project files in the business system in the embodiments of the present application, and the storage paths in the attributes of these forward dependency records constitute the "global path object set".
Step 307: and traversing storage paths in the attributes of all the forward dependency records in the global path object set, creating a backward dependency record for the second project file corresponding to the storage path in each attribute, wherein the backward dependency record represents the backward dependency relationship among the project files, and adding the storage paths of all the first project files which refer to the second project file to the attributes of the backward dependency record of the second project file.
This step is the same as step 102 in the first embodiment of the method. The established inverse dependency record can also be represented by a K-V data structure, wherein the K value is the record name of the inverse dependency record, and the V value is the attribute of the inverse dependency record. Still taking FIG. 2 as an example, assuming that the attributes in the forward dependency record of file1 (e.g., the storage path of subfile 1) are traversed, a backward dependency record is established for subfile 1, and the data structure of subfile 1 is represented as:
K | V |
subfile 1 | Document 1 |
Watch III
`sonfile1/index.js':{
influenceFactors[`file1/index.js']
};
Js represents the storage path of the subfile 1 as the K value of the subfile 1 inverse dependency record, and file1/index. js represents the storage path of the file1 as the V value of the subfile 1 inverse dependency record. In the same way, this step will establish all the backward dependency records of the service system.
Step 308: when the project file is modified, the modified project file is used as the current second project file.
Step 309: and determining a corresponding backward dependence record according to the current second project file, and obtaining a storage path of the first project file stored in the attribute of the backward dependence record so as to determine the current first project file searched reversely.
Step 310: judging whether the entry file is searched, if the entry file is not searched, executing step 311; otherwise, step 312 is performed.
Step 311: and taking the searched current first project file as a second project file, and returning to the step 309.
The above-mentioned steps 308 to 311 are specific implementation methods for reversely searching the project file by using the attribute of the backward dependency record of the modified project file. Since the business system establishes the inverse dependency records, the inverse dependency records can be used for tracing. For example, the subfile 1 is modified, and the affected item file can be found to be the file1 according to the backward dependency record (table three) of the subfile 1; similarly, the affected project file can be found to be the entry file1 according to the backward dependency record of the file 1. Of course, if there are storage paths of multiple project files in the attributes of the backward dependency record, further search is required for other project files, and the entry file also needs to be traced back.
Step 312: and determining the range of the affected project files according to the searched project files, and synchronizing the range of the affected project files to the testing process flow.
As with the first method embodiment, in this embodiment, when determining the affected range, it is also necessary to synchronize the entry files of the affected range to the tester, and the tester may test only some functions of the affected entry files. Assuming that the affected entry file is determined to be entry file1, then entry file1 needs to be synchronized to the tester. In this way, the tester can test only the functions under the entry file 1. Further, in practical application, if there are several functions under the entry file1, only part of the affected functions may be synchronized to the tester, and the tester only needs to test part of the functions under the entry file 1. Because the embodiment utilizes the established backward dependence record to trace back the range of the affected project file, the error or confusion caused by modifying the project file is avoided, and the efficiency and the quality of the whole service on line are ensured. In addition, the tester does not need to test the whole service system, and the test efficiency can be greatly improved.
The above embodiments of the present application describe a file management method based on an abstract syntax tree. Under the file management method, when a certain project file in the business system is modified, the range of the affected project file can be determined quickly and accurately. In practical application, there may be other operations on the service system, and a certain function in the service system is taken off line. In this case, if the project file related to the function is not cleared, more and more redundant codes are generated, which is not beneficial to the file management of the business system. For this situation, in the following third embodiment of the method, in order to clear the item file related to the offline function, the forward dependency record indicating the forward dependency relationship is also used to determine the range of the item file related to the offline function, and then delete the range.
FIG. 7 is a flowchart of another file management method based on abstract syntax trees according to a third embodiment of the present application. In the third embodiment of the method of the present application, it is assumed that forward dependency records have been established for all project files in the business system by using the method of step 101 or by using steps 301 to 306, and detailed descriptions thereof are not repeated here. When a certain function needs to be offline, as shown in fig. 7, the method includes:
step 701: and determining the entry file corresponding to the function needing to be offline, and taking the entry file as the entry file to be offline.
A certain function of the business system is usually implemented from a certain entry file, and if a certain function is to be taken off line, the corresponding entry file needs to be determined, and the item file on which the entry file directly or indirectly depends is the item file related to the function to be taken off line.
Step 702: and determining all project files needing to be deleted in the business system by using the positive dependency relationship from the entry file to be downloaded, and marking the project files in the attribute of the positive dependency record where the project files are located.
Similar to the step of establishing the forward dependency record for the item file under the current entry file in the second method embodiment, the forward dependency record may also be established for the item file under the entry file to be downloaded in the embodiment of the present application by referring to the same method, so that all the item files under the entry file to be downloaded are the item files that need to be deleted. Assuming that the established "global path object set" is a summary deps set, this step needs to determine that a certain "local path object set" is a currentDeps set, i.e. a project file directly or indirectly referenced under an entry file to be downloaded. And subsequently deleting the storage path in the currentDeps set from the summaryDeps set, and simultaneously deleting the item file corresponding to the storage path.
Step 703: deleting all the project files needing to be deleted in the service system, traversing the attributes of the forward dependence records of all the project files, and deleting the reference relation corresponding to the marks needing to be deleted in the attributes.
When the currentDeps set corresponding to the entry file to be offline is determined, the item file corresponding to each storage path in the currentDeps set can be deleted by using a delete method, and the item file is deleted from the summarDeps set at the same time, that is, the related reference relationship is deleted.
In another embodiment of the method of the present application, a specific method for determining a project file that needs to be deleted is further disclosed, that is, a specific method for implementing the step 702. Fig. 8 is a method of determining an item file that needs to be deleted. As shown in fig. 8, the method specifically includes:
step 801: and creating an abstract syntax tree for the entry file to be downloaded by using the lexical method and the syntax analysis method.
This step is similar to step 302 of the second embodiment of the method, except that the entry file is the entry file to be offline.
Step 802: traversing the abstract syntax tree of the file to be downlinked, establishing a forward dependency record for each project file in the abstract syntax tree of the file to be downlinked in the traversing process, taking each project file as a first project file, taking the project file quoted by the project file as a second project file, adding a storage path of the second project file into the attribute of the forward dependency record of the first project file, simultaneously saving the attribute into the created local path object set, and calculating the quoted times of the first project file.
This step is similar to step 303 in the second embodiment of the method, except that, here, when creating the forward dependency record, it is also necessary to set the number of times of referencing of the first project file, and the number of times of referencing of the first project file is calculated in the traversal process. Similarly, when traversing the abstract syntax tree, it may be determined first whether the storage path of the currently traversed project file is already saved in the attribute of the forward dependency record, and if so, directly add 1 to the number of times it is referred (value); if the item file is not saved, a new forward dependency record (K-V data structure) is created, the storage path of the currently traversed item file is used as the record name (K value), and the initial value of the number of times of reference (value) is set to be 1.
Step 803: and determining the project files corresponding to the same storage path in the global path object set and the local path object set.
Since the global path object set includes the storage paths in the forward dependency records of all project files in the business system, and the local path object set is only a part of the global path object set, the same storage path should exist. Assuming that fig. 2 represents all storage paths in the global path object set and the entry file to be offline is entry file 3, fig. 6 represents all storage paths in the local path object set. Then, the entry file 3, the subfile 2, and the subfile 6 are the entry files corresponding to the same storage path.
Step 804: and subtracting the referenced times in the same item file, and taking the difference value 0 as the mark needing to be deleted.
Due to the fact that the function corresponding to the entry file to be downloaded needs to be deleted, only the item file under the entry file to be downloaded related to the function to be downloaded is deleted, and the item file still depended on by other functions is not allowed to be deleted. In order to accurately find the item file to be deleted, the embodiment of the method takes the reference number difference of 0 as the mark to be deleted. Assuming that the number of times of reference of the file 3 in the global path object set is 1, the number of times of reference of the file 3 in the local path object set is 1, and the subtraction difference value is 0, it can be determined that the file 3 is an item file that needs to be deleted.
According to the method of this embodiment, after the function corresponding to the entry file 3 is offline, a schematic diagram of a dependency relationship between each item file of the service system with the offline function deleted is shown in fig. 9. The entry file 3, the file 3 and the subfile 6 are deleted, and the subfile 2 is subtracted by 1, so that the entry file, the file 3 and the subfile are not deleted.
The method embodiments of the present application list methods for managing project files by different operations, and there are other operations that may also affect project files in practical applications, and the project files may also be managed by using the embodiments of the present application. In a word, by applying the scheme of the embodiment of the application, because the positive dependency record is established for each project file of the service system to reflect the dependency relationship among the project files, the project files in the service system can be conveniently managed by using the dependency relationship, so that the human resources are saved, and the online efficiency and quality of the service system are obviously improved.
Aiming at the file management method based on the abstract syntax tree, the embodiment of the application also discloses a file management device based on the abstract syntax tree. As shown in fig. 10, the first structural diagram of the apparatus in the first embodiment includes: a forward dependent record establishing unit A1, a backward dependent record establishing unit A2, and an affected range determining unit A3. Wherein:
the forward dependency record establishing unit A1 is used for analyzing the forward dependency relationship among the project files in the business system by using the abstract syntax tree and establishing a forward dependency record for each project file to represent the forward dependency relationship; the forward dependency represents a reference relationship from a first project file to a second project file, the first project file references the second project file, the attribute of the forward dependency record of the first project file comprises a storage path of the second project file, and the storage paths in all the attributes of the forward dependency record in the service system form a global path object set.
A backward dependency record creating unit a2, configured to traverse storage paths in the attributes of all the forward dependency records in the global path object set, create a backward dependency record for the second item file of the storage path in each attribute, where the backward dependency record represents a backward dependency relationship between the item files, and add the storage path of all the first item files referencing the second item file to the attribute of the backward dependency record of the second item file.
And the affected range determining unit A3 is used for reversely searching the project file by using the attribute of the reverse dependency record of the modified project file when the project file is modified, determining the affected project file range according to the searched project file, and synchronizing the affected project file range to the test processing flow.
That is to say, the forward dependency record creating unit a1 first analyzes the forward dependency relationship between the project files in the business system by using the abstract syntax tree, and creates a forward dependency record for each project file to represent the forward dependency relationship; traversing all storage paths in the attributes of the forward dependency records in the global path object set by the backward dependency record establishing unit A2, and establishing a backward dependency record for a second item file corresponding to the storage path in each attribute; then, when modifying the project file, the affected range determining unit a3 reversely searches the project file using the attribute of the reverse dependency record of the modified project file, determines the affected project file range from the searched project file, and synchronizes it to the test processing flow.
Because the backward dependency record is established for each project file in the service system, when a certain project file is modified, the backward dependency record of the modified project file can be inquired to directly obtain other project files which refer to the modified project file, and then the entry file is traced layer by layer, so that the affected range is quickly determined. And synchronizing the entry files in the determined affected range to a tester, so that the tester can test only some functions of the affected entry files, errors or confusion caused by modifying the project files are avoided, and the efficiency and quality of the whole service on line are ensured.
The application also discloses another file management device embodiment based on the abstract syntax tree. Fig. 11 is a schematic structural diagram of a second embodiment of the apparatus. As shown in fig. 11, the apparatus includes: a forward dependent record establishing unit A1, a backward dependent record establishing unit A2, an affected range determining unit A3 and a merging unit A4. The forward dependent record creating unit A1 includes the first abstract syntax tree creating subunit A11 and the first created record executing subunit A12. The affected range determining unit A3 includes a reverse search subunit a31, a designated subunit a 32. Specifically, the method comprises the following steps:
a first abstract syntax tree creating subunit a11, configured to use an entry file of the business system as a current entry file, and create an abstract syntax tree for the current entry file by using a lexical and syntactic analysis method.
The first record creating and executing subunit a12, configured to traverse an abstract syntax tree of a current entry file, create a forward dependency record for each item file in the abstract syntax tree of the current entry file during the traversal, use each item file as a first item file, use an item file referred to by the first item file as a second item file, add a storage path of the second item file to an attribute of the forward dependency record of the first item file, and store the attribute in a created global path object set; and taking the next entry file of the business system as the current entry file, and returning to the step of establishing the abstract syntax tree for the current entry file by utilizing the lexical and syntactic analysis method until all the entry files of the business system are processed.
A backward dependency record creating unit a2, configured to traverse storage paths in the attributes of all the forward dependency records in the global path object set, create a backward dependency record for the second item file corresponding to the storage path in each attribute, where the backward dependency record represents a backward dependency relationship between the item files, and add the storage path of all the first item files referencing the second item file to the attribute of the backward dependency record of the second item file.
And the reverse search subunit a31 is configured to use the modified project file as a current second project file, determine a corresponding reverse dependency record according to the current second project file, and obtain a storage path of the first project file stored in the attribute of the corresponding reverse dependency record, so as to determine a current first project file which is reversely searched.
A designating subunit a32, configured to use the searched current first project file as a second project file, and then return to execute the step of determining a corresponding backward dependency record according to the current second project file until an entry file in the service system is searched backward.
And the merging unit A4 is configured to traverse the attributes of the forward dependency records of all the project files in the system service, and merge the repeated attributes in the forward dependency records. Of course, in practical applications, if the attributes in the forward dependency record of the project file are not duplicated, the merge process need not be performed, i.e., merge unit a4 is omitted. When the duplicate attributes are merged, the record names (K values) of different forward dependent records can be merged, and the uniqueness of the attributes (V values) can be ensured.
By applying the scheme of the embodiment of the application apparatus, that is, the first abstract syntax tree creating subunit a11 takes an entry file of the service system as a current entry file, and creates an abstract syntax tree for the current entry file by using a lexical method and a syntax analysis method; the first record establishing and executing subunit a12 traverses the abstract syntax tree of the current entry file, establishes a forward dependency record for each item file in the abstract syntax tree of the current entry file, and completes processing of all entry files according to the method; the merging unit A4 traverses the attributes of the forward dependency records of all the project files, and merges the repeated attributes in the forward dependency records; the backward dependency record establishing unit a2 traverses the storage paths in the attributes of all the forward dependency records in the global path object set, and creates a backward dependency record for the second item file corresponding to the storage path in each attribute; the reverse search subunit a31 reverses the modified project file as the current second project file, and reverses the current first project file searched in the reverse dependency record until the entry file in the business system is searched in reverse in this way to determine the affected area.
The application also discloses another file management device embodiment based on the abstract syntax tree. Fig. 12 is a schematic structural diagram of a third embodiment of the apparatus of the present application, and as shown in fig. 12, the apparatus includes: the system comprises a forward dependent record establishing unit A1, a backward dependent record establishing unit A2, an affected range determining unit A3, a merging unit A4 (which may or may not be included), a downline entry file determining unit A5, a deleted object determining unit A6 and a deleted execution unit A7. The functions of the forward dependent record establishing unit a1, the backward dependent record establishing unit a2, the affected area determining unit A3 and the merging unit a4 are the same as those of the second embodiment of the apparatus. The deleted object determining unit a6 includes a second abstract syntax tree building sub-unit a61, a second created record executing sub-unit a62, and a deletion marker determining sub-unit a 63. In particular, the method comprises the following steps of,
the offline entry file determining unit a5 is configured to, when a function in the business system is offline, determine an entry file corresponding to the function that needs to be offline, and use the entry file as an entry file to be offline.
And a deleted object determining unit a6, configured to determine, starting from the entry file to be downloaded, all item files that need to be deleted in the business system by using the positive dependency relationship, and mark the item files in the attribute of the positive dependency record where the item files are located.
In the deleted object determination unit a 6:
and a second abstract syntax tree creating subunit a61, configured to create an abstract syntax tree for the entry file to be downloaded by using the lexical and syntactic analysis methods.
And a second record creating and executing subunit a62, configured to traverse the abstract syntax tree of the to-be-downlinked entry file, create a forward dependency record for each item file in the abstract syntax tree of the to-be-downlinked entry file during the traversal, take each item file as a first item file, take an item file referred to by the first item file as a second item file, add a storage path of the second item file to an attribute of the forward dependency record of the first item file, and simultaneously store the storage path into the created local path object set, and calculate the number of times the first item file is referred to.
A deletion marker determining subunit a63, configured to determine item files corresponding to the same storage path in the global path object set and the local path object set; and subtracting the referenced times in the same item file, and taking the difference value 0 as the mark needing to be deleted.
And the deletion execution unit a7 is configured to delete all the item files that need to be deleted in the service system, traverse the attributes of the forward dependency records of all the item files, and delete the reference relationship corresponding to the mark that needs to be deleted in the attributes.
By applying the scheme of the embodiment of the application, that is, when a certain function needs to be offline, the offline entry file determining unit a5 determines the entry file corresponding to the function needing to be offline, and takes the entry file as the entry file to be offline; the second abstract syntax tree creating subunit a61 creates an abstract syntax tree for the entry file to be downloaded by using the lexical and syntactic analysis methods; the second record establishing and executing subunit a62 traverses the abstract syntax tree of the to-be-downlinked entry file, establishes a forward dependency record for each item file in the abstract syntax tree of the to-be-downlinked entry file in the traversing process, and stores the storage path of the second item file referenced by the forward dependency record into the created local path object set; the deletion marker determining subunit a63 determines the item files corresponding to the same storage path in the global path object set and the local path object set; subtracting the referred times in the same item file, and taking the difference value 0 as the mark needing to be deleted; thereafter, the deletion execution unit a7 deletes all the item files that need to be deleted in the business system, traverses the attributes of the forward dependency records of all the item files, and deletes the reference relationship corresponding to the mark that needs to be deleted in the attributes.
Embodiments of the present application also provide a computer-readable storage medium storing instructions that, when executed by a processor, may perform the steps of the abstract syntax tree based file management method as described above. In practical applications, the computer readable medium may be included in each device/apparatus/system of the above embodiments, or may exist separately and not be assembled into the device/apparatus/system. Wherein instructions are stored in a computer readable storage medium, which stored instructions, when executed by a processor, may perform the steps in the abstract syntax tree based file management method as described above.
According to embodiments disclosed herein, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example and without limitation: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing, without limiting the scope of the present disclosure. In the embodiments disclosed herein, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
As shown in fig. 13, an embodiment of the present invention further provides an electronic device. As shown in fig. 13, it shows a schematic structural diagram of an electronic device according to an embodiment of the present invention, specifically:
the electronic device may include a processor 1301 of one or more processing cores, memory 1302 of one or more computer-readable storage media, and a computer program stored on the memory and executable on the processor. The file management method based on the abstract syntax tree described above may be implemented when the program of the memory 1302 is executed.
Specifically, in practical applications, the electronic device may further include a power supply 1303, an input/output unit 1304, and other components. Those skilled in the art will appreciate that the configuration of the electronic device shown in fig. 13 is not intended to be limiting of the electronic device and may include more or fewer components than shown, or some components in combination, or a different arrangement of components. Wherein:
the processor 1301 is a control center of the electronic device, connects various parts of the entire electronic device using various interfaces and lines, and performs various functions of the server and processes data by running or executing software programs and/or modules stored in the memory 1302 and calling data stored in the memory 1302, thereby integrally monitoring the electronic device.
The memory 1302 may be used to store software programs and modules, i.e., the computer-readable storage media described above. The processor 1301 executes various functional applications and data processing by running software programs and modules stored in the memory 1302. The memory 1302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the server, and the like. Further, the memory 1302 may include high speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 1302 may also include a memory controller to provide processor 1301 access to memory 1302.
The electronic device further includes a power supply 1303 for supplying power to each component, and the power supply 1303 may be logically connected to the processor 1301 through a power management system, so that the functions of managing charging, discharging, power consumption, and the like are implemented through the power management system. The power supply 1303 may also include one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and any other components.
The electronic device may also include an input-output unit 1304, where the input-output unit 1304 may be used to receive entered numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. The input unit output 1304 may also be used to display information input by or provided to the user, as well as various graphical user interfaces, which may be composed of graphics, text, icons, video, and any combination thereof.
The flowchart and block diagrams in the figures of the present application illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments disclosed herein. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not explicitly recited in the present application. In particular, the features recited in the various embodiments and/or claims of the present application may be combined and/or coupled in various ways, all of which fall within the scope of the present disclosure, without departing from the spirit and teachings of the present application.
The principles and embodiments of the present invention are explained herein using specific examples, which are provided only to help understanding the method and the core idea of the present invention, and are not intended to limit the present application. It will be appreciated by those skilled in the art that changes may be made in this embodiment and its broader aspects and without departing from the principles, spirit and scope of the invention, and that all such modifications, equivalents, improvements and equivalents as may be included within the scope of the invention are intended to be protected by the claims.
Claims (10)
1. A file management method based on abstract syntax trees is characterized by comprising the following steps:
analyzing a forward dependency relationship among project files in a business system by using an abstract syntax tree, and establishing a forward dependency record for the project files to express the forward dependency relationship; the forward dependency represents a reference relationship from a first project file to a second project file, the first project file references the second project file, a storage path of the second project file is contained in an attribute of a forward dependency record of the first project file, and the storage path in the attribute of the forward dependency record in the service system forms a global path object set;
traversing a storage path in the forward dependency record attributes in the global path object set, creating a backward dependency record for a second project file corresponding to the storage path in the attributes, wherein the backward dependency record represents a backward dependency relationship between the project files, and adding a storage path of a first project file referencing the second project file to the attributes of the backward dependency record of the second project file;
when the project file is modified, the project file is reversely searched by utilizing the attribute of the reverse dependency record of the modified project file, the range of the affected project file is determined according to the searched project file, and the affected project file is synchronized to the testing process flow.
2. The method of claim 1, wherein the step of analyzing forward dependencies between project files in a business system using an abstract syntax tree and creating forward dependency records for the project files to represent the forward dependencies comprises:
taking an entry file of the business system as a current entry file;
creating an abstract syntax tree for the current entry file by utilizing a lexical method and a syntax analysis method;
traversing the abstract syntax tree of the current entry file, establishing a forward dependency record for the project file in the abstract syntax tree of the current entry file in the traversing process, taking the project file as a first project file, taking the project file quoted by the project file as a second project file, adding a storage path of the second project file into the attribute of the forward dependency record of the first project file, and simultaneously storing the attribute into the created global path object set;
and taking the next entry file of the business system as a current entry file, and returning to the step of creating the abstract syntax tree for the current entry file by utilizing the lexical and syntactic analysis method until the entry file of the business system is processed.
3. The method of claim 1, wherein between the step of creating a forward dependency record for the project file to represent the forward dependency and the step of traversing the stored path of the forward dependency record attributes in the global path object set, the method further comprises:
and traversing the attributes of the forward dependency records of the project files in the system service, and merging the repeated attributes in the forward dependency records.
4. The method of claim 1, wherein the step of reverse searching the project file using the attributes of the inverse dependency records of the modified project file comprises:
when the project file is modified, taking the modified project file as a current second project file;
determining a corresponding backward dependence record according to the current second project file, and obtaining a storage path of the first project file stored in the attribute of the backward dependence record so as to determine the current first project file searched reversely;
and taking the searched current first project file as a second project file, and then returning to execute the step of determining the corresponding backward dependence record according to the current second project file until the entry file in the service system is searched in a backward direction.
5. A method according to any of claims 1 to 4, wherein, when a function in the business system is taken offline, the method further comprises:
determining an entry file corresponding to a function needing offline, and taking the entry file as an entry file to be offline;
determining the item files needing to be deleted in the business system by using the positive dependency relationship from the entry files to be downloaded, and marking the item files in the attributes of the positive dependency records where the item files are located;
deleting the project file which needs to be deleted in the service system, traversing the attribute of the forward dependence record of the project file, and deleting the reference relation corresponding to the mark which needs to be deleted in the attribute.
6. The method according to claim 5, wherein the step of determining, starting from the pending offline entry file, the item file that needs to be deleted in the business system by using the positive dependency relationship, and marking the item file in the attribute of the positive dependency record where the item file exists comprises:
creating an abstract syntax tree for the entry file to be downloaded by using the lexical method and the syntax analysis method;
traversing the abstract syntax tree of the file to be downlinked, establishing a forward dependency record for the project file in the abstract syntax tree of the file to be downlinked in the traversing process, taking the project file as a first project file, taking the project file quoted by the first project file as a second project file, adding a storage path of the second project file into the attribute of the forward dependency record of the first project file, simultaneously storing the attribute into the created local path object set, and calculating the quoted times of the first project file;
determining item files corresponding to the same storage path in the global path object set and the local path object set; and subtracting the referenced times in the same item file, and taking the difference value 0 as the mark needing to be deleted.
7. An abstract syntax tree based file management apparatus, comprising:
the forward dependency record establishing unit is used for analyzing a forward dependency relationship among project files in a business system by using an abstract syntax tree and establishing a forward dependency record for the project files to express the forward dependency relationship; the forward dependency represents a reference relationship from a first project file to a second project file, the first project file references the second project file, a storage path of the second project file is contained in an attribute of a forward dependency record of the first project file, and the storage path in the attribute of the forward dependency record in the service system forms a global path object set;
the backward dependency record establishing unit is used for traversing a storage path in the attribute of the forward dependency record in the global path object set, creating a backward dependency record for a second item file corresponding to the storage path in the attribute, wherein the backward dependency record represents a backward dependency relationship between the item files, and adding the storage path of a first item file which refers to the second item file to the attribute of the backward dependency record of the second item file;
and the affected range determining unit is used for reversely searching the project files by utilizing the attributes of the reverse dependency records of the modified project files when the project files are modified, determining the range of the affected project files according to the searched project files, and synchronizing the affected project files to the test processing flow.
8. The apparatus according to claim 7, wherein the forward dependency record creating unit comprises:
a first abstract syntax tree establishing subunit, configured to use an entry file of the service system as a current entry file, and establish an abstract syntax tree for the current entry file by using a lexical method and a syntax analysis method;
the first record establishing and executing subunit is used for traversing the abstract syntax tree of the current entry file, establishing a forward dependency record for the project file in the abstract syntax tree of the current entry file in the traversing process, taking the project file as the first project file, taking the project file quoted by the project file as the second project file, adding the storage path of the second project file to the attribute of the forward dependency record of the first project file, and simultaneously storing the attribute into the created global path object set; and taking the next entry file of the business system as a current entry file, and returning to the step of creating the abstract syntax tree for the current entry file by utilizing the lexical and syntactic analysis method until the entry file of the business system is processed.
9. A computer-readable storage medium having stored thereon computer instructions, which when executed by a processor, implement the abstract syntax tree based file management method according to any one of claims 1 to 6.
10. An electronic device, characterized in that the electronic device comprises at least the computer-readable storage medium of claim 13, further comprising a processor;
the processor is configured to read the executable instructions from the computer-readable storage medium and execute the instructions to implement the abstract syntax tree-based file management method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011117804.1A CN112256637A (en) | 2020-10-19 | 2020-10-19 | File management method and device based on abstract syntax tree and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011117804.1A CN112256637A (en) | 2020-10-19 | 2020-10-19 | File management method and device based on abstract syntax tree and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112256637A true CN112256637A (en) | 2021-01-22 |
Family
ID=74244816
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011117804.1A Pending CN112256637A (en) | 2020-10-19 | 2020-10-19 | File management method and device based on abstract syntax tree and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112256637A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113448928A (en) * | 2021-07-09 | 2021-09-28 | 网易(杭州)网络有限公司 | File cleaning method and device, processor and electronic device |
CN114492324A (en) * | 2022-01-28 | 2022-05-13 | 中国工商银行股份有限公司 | Component data statistical method and device |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699488A (en) * | 2013-12-30 | 2014-04-02 | 优视科技有限公司 | Call relation dependence graph based regression testing method and system |
CN104424437A (en) * | 2013-08-28 | 2015-03-18 | 贝壳网际(北京)安全技术有限公司 | Multi-file sample testing method and device and client |
CN107885501A (en) * | 2017-11-03 | 2018-04-06 | 武汉斗鱼网络科技有限公司 | Obtain the method and device of the mutual adduction relationship of component in Android |
CN108614707A (en) * | 2018-04-27 | 2018-10-02 | 深圳市腾讯网络信息技术有限公司 | Static code inspection method, device, storage medium and computer equipment |
CN109033843A (en) * | 2018-08-02 | 2018-12-18 | 南瑞集团有限公司 | Java file dependencies analysis method and module for distributed static detection system |
US20190095491A1 (en) * | 2017-09-25 | 2019-03-28 | Splunk Inc. | Generating a distributed execution model with untrusted commands |
CN109582575A (en) * | 2018-11-27 | 2019-04-05 | 网易(杭州)网络有限公司 | Game test method and device |
CN110618931A (en) * | 2019-08-14 | 2019-12-27 | 重庆金融资产交易所有限责任公司 | Dependency relationship detection method and device, computer equipment and readable storage medium |
CN111666206A (en) * | 2020-04-30 | 2020-09-15 | 北京百度网讯科技有限公司 | Method, device, equipment and storage medium for acquiring influence range of change code |
-
2020
- 2020-10-19 CN CN202011117804.1A patent/CN112256637A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104424437A (en) * | 2013-08-28 | 2015-03-18 | 贝壳网际(北京)安全技术有限公司 | Multi-file sample testing method and device and client |
CN103699488A (en) * | 2013-12-30 | 2014-04-02 | 优视科技有限公司 | Call relation dependence graph based regression testing method and system |
US20190095491A1 (en) * | 2017-09-25 | 2019-03-28 | Splunk Inc. | Generating a distributed execution model with untrusted commands |
CN107885501A (en) * | 2017-11-03 | 2018-04-06 | 武汉斗鱼网络科技有限公司 | Obtain the method and device of the mutual adduction relationship of component in Android |
CN108614707A (en) * | 2018-04-27 | 2018-10-02 | 深圳市腾讯网络信息技术有限公司 | Static code inspection method, device, storage medium and computer equipment |
CN109033843A (en) * | 2018-08-02 | 2018-12-18 | 南瑞集团有限公司 | Java file dependencies analysis method and module for distributed static detection system |
CN109582575A (en) * | 2018-11-27 | 2019-04-05 | 网易(杭州)网络有限公司 | Game test method and device |
CN110618931A (en) * | 2019-08-14 | 2019-12-27 | 重庆金融资产交易所有限责任公司 | Dependency relationship detection method and device, computer equipment and readable storage medium |
CN111666206A (en) * | 2020-04-30 | 2020-09-15 | 北京百度网讯科技有限公司 | Method, device, equipment and storage medium for acquiring influence range of change code |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113448928A (en) * | 2021-07-09 | 2021-09-28 | 网易(杭州)网络有限公司 | File cleaning method and device, processor and electronic device |
CN114492324A (en) * | 2022-01-28 | 2022-05-13 | 中国工商银行股份有限公司 | Component data statistical method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10540350B2 (en) | Source code search engine | |
CN110442847B (en) | Code similarity detection method and device based on code warehouse process management | |
CN112256637A (en) | File management method and device based on abstract syntax tree and storage medium | |
CN112130891B (en) | Method and equipment for continuously deploying database | |
US20080052299A1 (en) | Reverse engineering support system | |
CN110134663B (en) | Organization structure data processing method and device and electronic equipment | |
CN107067200B (en) | Operation method and device for bill of material data | |
CN111143390A (en) | Method and device for updating metadata | |
CN111914066A (en) | Multi-source database global search method and system | |
CN114997414B (en) | Data processing method, device, electronic equipment and storage medium | |
CN118377605B (en) | Task scheduling model construction method and device | |
CN113032642B (en) | Data processing method and device for target object, medium and electronic equipment | |
US7624124B2 (en) | System and method for assisting generation of business specification | |
CN117892811A (en) | Knowledge graph construction system for intelligent design of typical structural member | |
CN114637510A (en) | Code analysis method and related equipment | |
CN116910032A (en) | Method, device, equipment and storage medium for migrating data marts | |
CN114168119B (en) | Code file editing method, device, electronic equipment and storage medium | |
CN111813749B (en) | File filtering method and device, electronic equipment and storage medium | |
CN114328965A (en) | Knowledge graph updating method and device and computer equipment | |
CN108920749B (en) | Pipeline two-dimensional and three-dimensional data updating method and device and computer readable storage medium | |
CN113779030A (en) | Enumerated value query method, readable storage medium and computer program product | |
Hacks et al. | Towards an enterprise architecture model evolution | |
CN110688103B (en) | Code writing method, device, electronic equipment and computer readable storage medium | |
CN112307134A (en) | Entity information processing method, entity information processing device, electronic equipment and storage medium | |
CN111553149A (en) | Text assertion testing method and device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20210323 Address after: 100085 Floor 101 102-1, No. 35 Building, No. 2 Hospital, Xierqi West Road, Haidian District, Beijing Applicant after: Seashell Housing (Beijing) Technology Co.,Ltd. Address before: Unit 05, room 112, 1 / F, block C, comprehensive service area, Nangang Industrial Zone, Tianjin Economic and Technological Development Zone, 300280 Applicant before: BEIKE TECHNOLOGY Co.,Ltd. |
|
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210122 |