Method for updating call link diagram
By registering documentation listener events when the project starts, real-time monitoring of code documentation changes, and generating a call chain graph based on the abstract syntax tree, the problem of inconsistent call relationships during system iteration is solved, achieving efficient and low-cost call relationship maintenance and parsing.
Patent Information
- Application Number
- CN202411075316.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-11-22
AI Technical Summary
During the iterative process of system requirements, the design documents in existing technologies are often missing, which leads to discrepancies between the obtained method call relationships and the actual code call relationships. This makes it difficult to learn and maintain system call relationships, and existing IDE tools have low parsing efficiency, serious duplicate parsing, and significant memory and performance overhead.
Register a documentation listener event when the project starts to monitor code documentation changes in real time, generate a call chain graph based on the abstract syntax tree, store parsed method information through a caching layer, set update conditions to avoid duplicate parsing, and optimize the call chain graph update process by using the abstract syntax tree and caching layer.
Ensuring that the call chain diagram corresponds to the actual call relationships in real time improves parsing efficiency, reduces memory consumption, lowers development costs, and improves code quality and maintainability.
Smart Images

Figure CN119003031A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of IT support technology, and in particular, relates to a method, device, equipment, computer storage medium, and product program for calling link graph update. Background Art
[0002] With the continuous development of the Internet industry, the number of users is growing, which also leads to the continuous growth of user needs. System functions are increasing and becoming more complex, and cluster components are increasing to meet the growing needs of users. In order to improve the readability and maintainability of the code and reduce the learning cost of the project, detailed learning materials need to be provided.
[0003] When learning and mastering the system method calling relationship, existing methods often learn the system methods and functions through the system design documents. However, since the system design documents are relatively complex, the content of the design documents is easily missing during the system requirements iteration process, resulting in the obtained method calling relationship being different from the actual method calling relationship of the code. Summary of the invention
[0004] The embodiments of the present application provide a method, apparatus, device, computer storage medium, and product program for updating a call link graph to solve the problem in the prior art that design document content is easily missing during system requirement iteration, resulting in the obtained call relationship being different from the actual method call relationship of the code.
[0005] In a first aspect, an embodiment of the present application provides a method for calling a link graph update, the method comprising:
[0006] Register the document listening event when the project starts. The document is the code document of the project.
[0007] When monitoring document changes, obtain the document change content;
[0008] When the document changes include changes to the calling methods, the call link graph is updated based on the changes to the calling methods, where the nodes of the call link graph represent the names of the calling methods, the edges of the call link graph represent the calling relationships between the calling methods, and the call link graph is generated based on the abstract syntax tree, where each node in the abstract syntax tree represents the grammatical structure of the code.
[0009] In a second aspect, an embodiment of the present application provides a device for calling a link graph update, the device comprising:
[0010] The registration module is used to register the document listening event when the project starts. The document is the code document of the project.
[0011] The acquisition module is used to obtain the document change content when the document change is monitored;
[0012] An update module is used to update a call link graph based on the changes in the calling method when the document changes include changes in the calling method. The nodes of the call link graph represent the names of the calling methods, the edges of the call link graph represent the calling relationships between the calling methods, and the call link graph is generated based on an abstract syntax tree. Each node in the abstract syntax tree represents the grammatical structure of the code.
[0013] In a third aspect, an embodiment of the present application provides a terminal device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the method for updating the call link graph as in the first aspect is implemented.
[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method for updating a call link graph as in the first aspect is implemented.
[0015] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the method for updating the call link graph as in the first aspect.
[0016] The embodiments of the present application provide a method, apparatus, device, computer storage medium, and product program for updating a call link graph. When a project is started, a document monitoring event is registered. The document is the code document of the project. This ensures that changes to the code document are monitored in real time throughout the project cycle. When document changes are monitored, the document change content is obtained. When the document change content includes a call method change content, the call link graph is updated based on the call method change content, wherein the nodes of the call link graph represent the names of the call methods, the edges of the call link graph represent the call relationships between the call methods, the call link graph is generated based on an abstract syntax tree, and each node in the abstract syntax tree represents a grammatical structure in the code. The call link graph is updated based on the call method change content, and through automated monitoring and updating, it is ensured that the method call relationship in the call link graph is the same as the actual method call relationship in the code. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 It is a flowchart of a method for updating a call link graph provided in an embodiment of the present application;
[0019] Figure 2 It is a schematic diagram of the calling relationship of the calling method provided in the embodiment of the present application;
[0020] Figure 3 This is a callback diagram of a calling method provided in an embodiment of the present application;
[0021] Figure 4 It is a structural schematic diagram of a device for updating a call link graph provided in an embodiment of the present application;
[0022] Figure 5 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0024] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0025] Due to the complexity of the system and the fast iteration speed of requirements, it is difficult to understand the specific functions of the system and sort out the calling relationships of system methods during project handover learning. Currently, the calling methods of system methods are mainly learned through explanations by system developers, learning the design documents of developers, using the integrated development environment (IDE) to debug the system, and using IDE plug-ins to parse the calling relationships. However, the explanation time of system developers is limited, and it is impossible to give a complete explanation of the system and it takes a lot of time. There are many design documents of the system, which are easily missing during the process of requirement iteration and often cannot be updated in time. When debugging the system, the existing IDE tools need to spend a lot of time clicking on each method, which is inefficient. When parsing using the IDEA plug-in, repeated parsing will occur, which causes a large loss of memory and performance, and it is impossible to supplement and debug the interface information.
[0026] In order to solve the problem in the prior art that the call relationship obtained during the iteration process is different from the actual call relationship, this application registers a document monitoring event when the project starts, monitors the code files in the project cycle in real time, and filters and stores the method changes when the code files change, and updates the call relationship in the call chain diagram according to the method changes, to ensure that the obtained call relationship corresponds to the actual call relationship in real time, and sets update conditions, and updates when conditions such as update time or update frequency are met, to avoid repeated updates that damage system performance. Secondly, in order to solve the problem of repeated parsing when parsing calling methods, a cache layer is set to store the call information of the parsed method, and the parsed calling method directly calls the data stored in the cache layer to prevent the same method from generating multiple call information after repeated parsing, thereby reducing memory consumption and improving parsing performance.
[0027] Based on this, the embodiments of the present application provide a method, device, equipment, computer storage medium, and product program for updating a call link graph. When a project is started, a document listening event is registered. The document is the code document of the project, which can ensure real-time monitoring of changes in the code document throughout the project cycle; when a document change is monitored, the document change content is obtained; it is determined whether the document change content includes the call method change content; when the document change content includes the call method change content, the call link graph is updated based on the call method change content, wherein the nodes of the call link graph represent the names of the call methods, the edges of the call link graph represent the call relationships between the call methods, the call link graph is generated based on an abstract syntax tree, and each node in the abstract syntax tree represents a grammatical structure in the code. The call link graph is updated based on the call method change content, and through automated monitoring and updating, it is ensured that the method call relationship in the call link graph is the same as the actual method call relationship in the code.
[0028] The following is an introduction to the method for updating the call link graph provided by an embodiment of the present invention.
[0029] Figure 1 FIG. 1 is a flow chart showing a method for updating a call link graph provided by an embodiment of the present application. Figure 1 As shown, the method may include the following steps: S101 to S104.
[0030] S101, registering a document listening event when the project starts, where the document is the code document of the project.
[0031] In some embodiments, the code document is monitored by configuring a listener.
[0032] By registering document listening events, you can monitor code documents when the project starts and ensure that document changes are obtained in a timely manner.
[0033] S102, when a document change is detected, obtaining the document change content.
[0034] In some embodiments, document changes may include added, deleted, and modified lines of code.
[0035] S103, when the document change content includes the call method change content, the call link graph is updated based on the call method change content, wherein the nodes of the call link graph represent the names of the call methods, the edges of the call link graph represent the call relationships between the call methods, and the call link graph is generated based on the abstract syntax tree, and each node in the abstract syntax tree represents the grammatical structure of the code.
[0036] When it is determined that the document changes include changes to the calling methods, the call chain diagram is selectively updated for changes related to the calling methods, which improves the efficiency of the update, reduces errors and vulnerabilities in the code development process, and improves the quality and maintainability of the code.
[0037] In some embodiments, the calling method change content may include a change in the calling relationship or method parameters. By determining whether the document change content includes the calling method change content, it can be understood whether the document change involves a modification of the calling method.
[0038] In one embodiment, when the call method change content is a call relationship change, the call method nodes involved in the call relationship change content are added or deleted in the call link graph according to the call relationship change content, and the connection between the involved call method nodes is modified. In one example, when the call method change content is to add a call method B to the call method A, the process of updating the call link graph based on the call method change content is: adding a new edge and a node representing the call method B in the call link graph, and connecting the node of the call method A and the node of the call method B through the new edge.
[0039] In one example, when the calling method changes to calling method A and no longer calling method C, the process of updating the call chain graph based on the calling method changes is: removing the edge and corresponding node connecting calling method A and calling method C in the call chain graph.
[0040] In one embodiment, when the change content of the calling method is a change in method parameters, it is determined whether the change in method parameters affects the change in the calling relationship. When the change in method parameters affects the change in the calling relationship, the connection relationship of the method in the call chain diagram is modified according to the change in the calling relationship affected by the change in method parameters.
[0041] In an example, when method A calls sub-method B and the passed parameters x and y are changed to passed parameter z, the original edges representing the passed parameters x and y in the call link graph are deleted, and a new edge representing the passed parameter z is added.
[0042] In one example, when the change of a method parameter is a change of a default value of the method parameter, it has no impact on the call relationship and the call chain graph is not modified.
[0043] A method for updating a call link graph provided in an embodiment of the present application registers a document listening event when a project is started, and the document is the code document of the project, so as to ensure real-time monitoring of changes in the code document throughout the project cycle; when document changes are monitored, the document change content is obtained; when the document change content includes the call method change content, the call link graph is updated based on the call method change content, wherein the nodes of the call link graph represent the names of the call methods, the edges of the call link graph represent the call relationships between the call methods, the call link graph is generated based on an abstract syntax tree, and each node in the abstract syntax tree represents the grammatical structure in the code, and the call link graph is updated based on the call method change content, and through automated monitoring and updating, it is ensured that the method call relationship in the call link graph is the same as the actual method call relationship in the code.
[0044] In some embodiments, when the document change content includes the call method change content, updating the call link graph based on the call method change content includes:
[0045] When the document changes include the calling method changes, storing the calling method changes;
[0046] When the preset update time is reached, the call chain graph is updated based on the changed content of the calling method.
[0047] It determines in real time whether the set update time has been reached and stores the changed content of the calling method when the calling method changes. When the set update time is reached, the call chain graph is updated according to the changed content, that is, the frequency of updating the call chain graph is controlled to avoid system performance loss caused by frequent updates of the call chain graph, and the automatic update of the call chain graph is realized.
[0048] In some embodiments, when the document change content includes the calling method change content, after storing the calling method change content, the following may also be included:
[0049] After the storage call method changes the content, the number of changes increases by one;
[0050] When the preset number of changes is reached, the call chain graph is updated based on the stored call method changes, and the number of changes is cleared after the update is completed.
[0051] By detecting the number of changes in the calling method in real time and updating the call chain diagram when the preset number of changes is reached, the changes in multiple calling methods can be stored and updated in batches after a certain number of changes are reached. This reduces the frequency of update operations in the same way as setting the update time, and helps reduce system performance loss.
[0052] In some embodiments, when the document change content includes the calling method change content, after storing the calling method change content, the following may also be included:
[0053] When a user update request for a call chain graph is received, the call chain graph is updated based on the stored call method change content.
[0054] When a user needs to use the call chain graph, the user can request the call chain graph to be updated by actively sending an update request to the system.
[0055] When it is impossible to know whether the call relationship in the call chain graph is different from the actual call relationship, the user can update the call chain graph by inputting an update request instruction through setting a command line interface or the like.
[0056] In some embodiments, when updating the call link graph, the update time, the number of changes, and the reception of update requests can be used in combination. Developers can set the automatic update mode of the call link graph to be based on the update time or the number of changes. For systems with more daily changes, a shorter update time or a higher number of changes can be set. For systems with fewer daily changes, a longer update time or a fewer number of changes can be set. Developers can also manually request updates to the call link graph when necessary to ensure that developers can always obtain the latest call relationship information. Since the call link graph is automatically updated based on a fixed frequency, when developers perform manual updates, the update content of the call link graph is less or is already the same as the actual call relationship, which reduces the developer's update time and improves update efficiency.
[0057] In some embodiments, when the document change content includes the call method change content, before updating the call chain graph based on the call method change content, the method further includes:
[0058] Obtain an abstract syntax tree, where the nodes of the abstract syntax tree include calling methods, and the edges of the abstract syntax tree include calling relationships of the calling methods;
[0059] Parse the abstract syntax tree to obtain the calling information of the calling method, which includes the calling method name and the calling relationship;
[0060] Generate a call chain graph based on the calling method name and calling relationship.
[0061] Among them, the abstract syntax tree is a structured representation of the source code, which is generated when the project is compiled. It is a tree data structure obtained after the source code undergoes part-of-speech analysis and syntax analysis.
[0062] By parsing the abstract syntax tree to obtain call information, the dependency relationship between calling methods can be accurately reflected. The dependency relationship between calling methods can be generated into a call chain diagram, which shows the calling relationship between calling methods in a visual way, making the calling relationship easier to understand and analyze.
[0063] And by generating a link diagram, it can help developers quickly understand the code structure and business logic, thereby improving development efficiency, shortening the development cycle, and reducing the learning cost of the project, allowing them to become familiar with the logic and requirements of the methods in the code more quickly.
[0064] In some embodiments, the abstract syntax tree is obtained using a Program Structure Interface (PSI) model. The PSI model parses the source code into the form of an abstract syntax tree, represents the grammatical structures of the code, such as classes, methods, variables, and statements, as independent objects, and establishes relationships between grammatical structures. For example, the com.intellij.psi.PsiElement class in IDEA is used to represent the grammatical structure represented by each PSI node in the source code. For method nodes, the com.intellij.psi.PsiMethod in IDEA is used to obtain the calling relationship between methods and calling information such as method name, class, parameter type, etc.
[0065] In some embodiments, a call chain diagram is generated according to the calling method name and the calling relationship, and the call chain diagram is generated through the JavaSwing graphics library or PlantUML.
[0066] In some embodiments, the call chain graph further includes at least one of a call type and a call condition.
[0067] Annotation information can be added as needed, making the call chain diagram more flexible and applicable. Through annotation information, users can more intuitively understand key information such as call type, call conditions and version information, which helps to conduct deeper analysis and understanding.
[0068] In some embodiments, the call chain diagram may also include annotation information such as version information, exception type, and processing method. The annotation information may be set on the link arrows of the call chain diagram.
[0069] In some embodiments, parsing the abstract syntax tree to obtain calling information of the calling method includes:
[0070] Determine whether the preset cache layer includes the call information of the target call method, where the target call method is any method in the call method;
[0071] In a case where the preset cache layer includes the call information of the target call method, obtaining the call information of the target call method from the cache layer;
[0072] In the case that the preset cache layer does not include the calling information of the target calling method, the target calling method is parsed and the calling information is stored in the cache layer.
[0073] The cache layer is a storage space in a pre-set database for storing call information. It can persist the call information. By checking whether the cache layer stores the parsed methods, it can avoid repeated parsing of the same method, reduce memory loss, improve system processing efficiency, and prevent deadlock caused by repeated calling of the method.
[0074] like Figure 2 As shown, after parsing the calling method A, it can be known that when calling the calling method A, it is necessary to call the calling method B, calling method C, calling method D and calling method E inside A, and the calling information of calling method A is stored in the cache layer. After parsing the calling method B, it can be known that when calling B, it is necessary to call the calling method F and calling method G inside B, and the calling information of calling method B is stored in the cache layer. When parsing the calling method F, since the calling information of the calling method A inside F has been stored in the cache layer, the calling information of the calling method A in the cache layer is directly used, otherwise the calling method A, calling method B, calling method E, calling method F and the calling methods inside them that are called again as shown in the figure will be parsed multiple times, wasting memory and performance.
[0075] In some embodiments, when parsing the target calling method, the calling method inside the target calling method is accessed through a recursive method to obtain the calling relationship of the target calling method. For example, the com.intellij.psi.JavaElementVisitor class of IDEA is used to perform a recursive query to obtain the calling relationship of the method.
[0076] In some embodiments, when the preset cache layer does not include the calling information of the target calling method, parsing the target calling method includes:
[0077] The target calling method is called according to the callback mechanism to obtain the calling information of the target calling method. The callback mechanism returns the calling information when the target calling method and the calling method inside it are called.
[0078] When parsing the calling method, a callback mechanism is set for the calling method and its internal methods. When a call is made, a call notification is called back, so that the calling relationship of the sub-methods is called back step by step to the target calling method, and the sub-methods inside the calling method and the calling relationship between the calling method and the sub-methods are obtained, thereby obtaining the calling information of the target calling method.
[0079] Among them, when calling a method, its internal sub-methods are called in parallel. By calling the method in parallel, multiple sub-methods can be called at the same time, which reduces the complexity of a single task and reduces the waiting time, thereby improving the performance of method parsing.
[0080] When calling multiple sub-methods in parallel, each calling thread needs to occupy a certain amount of memory resources. Too many threads will lead to rapid consumption of memory resources. It is necessary to provide the number of cores plus one thread to fully utilize the computer's resources and manage concurrent calls by thread pooling. For example, if the computer has four physical cores, set the number of threads in the thread pool to five to prevent unlimited thread creation. The thread pooling technology fully utilizes the advantages of modern CPU multi-cores and assigns tasks to different threads for parallel execution on multiple CPU cores, thereby improving the parsing performance.
[0081] In one example, the callback mechanism is implemented by overriding the visitMethodCallExpression method. When a PsiMethod object is received, all methods within the method corresponding to the PsiMethod object can receive a method callback notification.
[0082] like Figure 3 As shown, when calling method A, it is divided into subtasks B and C, and the calling method B and calling method C inside A are called in parallel. When calling B and C, it is divided into subtasks D, E and subtasks F, G, and the calling method D, calling method E and calling method F, calling method G inside B and C are called in parallel respectively. After the calling of calling methods D and E is completed, the results and calling relationship are called back to the calling method B. After the calling of calling methods F and G is completed, the results are called back to the calling method C. After the calling of calling methods B and C is completed, the results are called back to the calling method A.
[0083] In some embodiments, the call information also includes the class name of the call method and the call method parameter type, and the call information is stored in the cache layer, including:
[0084] The call information is stored in a key-value format, where the key is generated by the call method name, the class name where the call method is located, and the call method parameter type, and the value is the call method name and the call relationship.
[0085] The call information is stored in the form of key-value pairs to achieve fast search and retrieval of information. The key is generated by the call method name, the class name of the call method, and the call method parameter type. This ensures that each call information has a unique identifier in the cache layer to avoid conflicts in call information of call methods with the same name.
[0086] For example, the key can adopt the structure of fullClassName#methodName#argsType, where fullClass Name is the name of the class where the calling method is located, methodName is the name of the calling method, and argsType is the parameter type of the calling method.
[0087] In some embodiments, generating a call chain graph according to the calling method name and the calling relationship includes:
[0088] Get a collection of target method names, which includes the names of calling methods that need to be hidden and the names of calling methods that need to be deleted;
[0089] Determine whether the target method name collection includes the calling method name;
[0090] Generate a call chain graph according to the calling method names and calling relationships that are not included in the target calling method name collection.
[0091] When generating a call chain graph, the target method name collection is used to determine which call methods need to be hidden or deleted. Developers can set the content in the target method name collection as needed to simplify the call chain graph and make the call relationship of the call chain graph targeted.
[0092] Figure 4 The schematic diagram of the structure of the device for updating the call link graph provided by the embodiment of the present application is shown. Figure 4 As shown, the device may include a registration module 401 , an acquisition module 402 and an update module 403 .
[0093] The registration module 401 is used to register a document listening event when the project is started, and the document is the code document of the project;
[0094] The acquisition module 402 is used to acquire the document change content when the document change is monitored;
[0095] Update module 403 is used to update the call link graph based on the change content of the calling method when the document change content includes the change content of the calling method, wherein the nodes of the call link graph represent the names of the calling methods, the edges of the call link graph represent the calling relationships between the calling methods, and the call link graph is generated based on the abstract syntax tree, and each node in the abstract syntax tree represents the grammatical structure of the code.
[0096] In some embodiments, the acquisition module is further used to store the calling method change content if the document change content includes the calling method change content;
[0097] The judgment module is also used to judge whether the preset update time has been reached;
[0098] The update module is also used to update the call link graph based on the changed content of the calling method when the preset update time is reached and the changed content of the calling method is stored.
[0099] In some embodiments, the acquisition module is further used to acquire an abstract syntax tree, the nodes of the abstract syntax tree include calling methods, and the edges of the abstract syntax tree include calling relationships of calling methods;
[0100] The acquisition module is also used to parse the abstract syntax tree to obtain the calling information of the calling method, and the calling information includes the calling method name and the calling relationship;
[0101] The update module is also used to generate a call chain graph according to the calling method name and the calling relationship.
[0102] In some embodiments, the determination module is further used to determine whether the preset cache layer includes the call information of the target call method, where the target call method is any method in the call method;
[0103] The acquisition module is further used to acquire the call information of the target call method from the cache layer when the preset cache layer includes the call information of the target call method;
[0104] The acquisition module is also used to parse the target calling method and save the calling information in the cache layer when the preset cache layer does not include the calling information of the target calling method.
[0105] In some embodiments, the acquisition module is also used to store the call information in a key-value format, where the key is generated by the call method name, the class name where the call method is located, and the call method parameter type, and the value is the call method name and the call relationship.
[0106] In some embodiments, the acquisition module is further used to acquire a collection of target method names, where the collection of target method names includes the names of the calling methods that need to be hidden or deleted;
[0107] The judging module is also used to judge whether the target method name collection includes the calling method name;
[0108] The update module is also used to generate a call chain graph based on the calling method names and calling relationships that are not included in the target calling method name collection.
[0109] Figure 4 The various modules in the device shown can be implemented Figure 1 Each step in the above steps can achieve the corresponding technical effect, which will not be repeated here for the sake of brevity.
[0110] Figure 5 A schematic diagram of the hardware structure of a terminal device provided in an embodiment of the present application is shown.
[0111] The terminal device may include a processor 501 and a memory 502 storing computer program instructions.
[0112] Specifically, the processor 501 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0113] The memory 502 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 502 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In one example, the memory 502 may include a removable or non-removable (or fixed) medium, or the memory 502 is a non-volatile solid-state memory. The memory 502 may be inside or outside the integrated gateway disaster recovery device.
[0114] In one example, the memory 502 may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method for call link graph update according to the present disclosure.
[0115] The processor 501 reads and executes the computer program instructions stored in the memory 502 to implement Figure 1 The method for updating the call link graph in the illustrated embodiment.
[0116] In one example, the terminal device may further include a communication interface 503 and a bus 504. Figure 5 As shown, the processor 501, the memory 502, and the communication interface 503 are connected via a bus 504 and communicate with each other.
[0117] The communication interface 503 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0118] Bus 504 includes hardware, software or both, and the components of terminal equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (Accelerated Graphics Port, AGP) or other graphics bus, enhanced industry standard architecture (Extended Industry Standard Architecture, EISA) bus, front side bus (Front Side Bus, FSB), Hyper Transport (Hyper Transport, HT) interconnection, industry standard architecture (Industry Standard Architecture, ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 504 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.
[0119] In addition, in combination with the method for updating the call link graph in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the methods for updating the call link graph in the above embodiment is implemented.
[0120] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed, implements any one of the methods for updating a call link graph in the above embodiments.
[0121] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0122] The functional blocks shown in the structural block diagram described above can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), appropriate firmware, plug-in, function card, etc. When implemented in software, the elements of the present application are programs or text segments used to perform the required tasks. The program or text segment can be stored in a machine-readable medium, or transmitted on a transmission medium or communication link via a data signal carried in a carrier. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (Read-Only Memory, ROM), flash memory, erasable read-only memory (Erasable ReadOnly Memory, EROM), floppy disks, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical discs, hard disks, optical fiber media, radio frequency (Radio Frequency, RF) links, etc. The text segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0123] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0124] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0125] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A method for calling link graph update, It is characterized in that include: Register a document listening event when the project starts, the document is the code document of the project; When the document change is detected, the document change content is obtained; In the case where the document change content includes the calling method change content, the call link graph is updated based on the calling method change content, wherein the nodes of the call link graph represent the names of the calling methods, the edges of the call link graph represent the calling relationships between the calling methods, and the call link graph is generated based on an abstract syntax tree, and each node in the abstract syntax tree represents the grammatical structure of the code.
2. The method for updating a call link graph according to claim 1, It is characterized in that When the document change content includes the call method change content, updating the call link graph based on the call method change content includes: When the document change content includes the calling method change content, storing the calling method change content; When the preset update time is reached, the call chain graph is updated based on the changed content of the calling method.
3. The method for updating the call link graph according to claim 1, It is characterized in that In the case where the document change content includes the call method change content, before updating the call chain graph based on the call method change content, the method further includes: Obtain an abstract syntax tree, wherein the nodes of the abstract syntax tree include calling methods, and the edges of the abstract syntax tree include calling relationships of the calling methods; Parsing the abstract syntax tree to obtain calling information of the calling method, wherein the calling information includes the calling method name and the calling relationship; Generate a call chain graph based on the calling method name and calling relationship.
4. The method for updating the call link graph according to claim 3, It is characterized in that The parsing of the abstract syntax tree to obtain the calling information of the calling method includes: Determine whether the preset cache layer includes the calling information of the target calling method, wherein the target calling method is any method in the calling method; In a case where the preset cache layer includes the calling information of the target calling method, acquiring the calling information of the target calling method from the cache layer; In the case that the preset cache layer does not include the calling information of the target calling method, the target calling method is parsed and the calling information is stored in the cache layer.
5. The method for updating the call link graph according to claim 4, It is characterized in that When the preset cache layer does not include the calling information of the target calling method, parsing the target calling method includes: The target calling method is called according to the callback mechanism to obtain the calling information of the target calling method. The callback mechanism returns the calling information when the target calling method and the calling method inside it are called.
6. The method for updating a call link graph according to claim 4, It is characterized in that The calling information also includes the class name of the calling method and the calling method parameter type. The storing of the calling information in the cache layer includes: The calling information is stored in a key-value manner, wherein the key is generated by the calling method name, the class name where the calling method is located, and the calling method parameter type, and the value is the calling method name and the calling relationship.
7. The method for updating a call link graph according to claim 3, It is characterized in that The generating of the call chain diagram according to the calling method name and the calling relationship includes: Obtain a collection of target method names, where the collection of target method names includes the names of calling methods that need to be hidden and the names of calling methods that need to be deleted; Determine whether the target method name collection includes the calling method name; Generate a call chain graph according to the calling method names and calling relationships that are not included in the target calling method name collection.
8. The method for updating a call link graph according to claim 2, It is characterized in that In the case where the document change content includes the call method change content, after storing the call method change content, the method further includes: After the storage call method changes the content, the number of changes increases by one; When the preset number of changes is reached, the call chain graph is updated based on the stored call method changes, and the number of changes is cleared after the update is completed.
9. The method for updating a call link graph according to claim 2, It is characterized in that In the case where the document change content includes the call method change content, after storing the call method change content, the method further includes: When a user update request for a call chain graph is received, the call chain graph is updated based on the stored call method change content.
10. A method for updating a call link graph according to claim 1, It is characterized in that The call chain graph also includes at least one of a call type and a call condition.
