Method, apparatus, device and product for introducing signals into code

By traversing files, semantic analysis and rule library conversion in old projects, the problem of inaccurate signal introduction location is solved, fast and high-quality code conversion and subsequent maintenance convenience is achieved, and the maintainability and performance of the code is improved.

CN120315690BActive Publication Date: 2025-08-26KYLIN CORP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510804419.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-17
Publication Date
2025-08-26
Estimated Expiration
2045-06-17

AI Technical Summary

Technical Problem

When introducing signal characteristics in old projects, the workload is large and it is difficult to accurately identify the location, resulting in poor code quality and maintainability, lack of unified standards, and affecting the performance optimization effect.

Method used

By traversing the project files, determining the reconstructible files, conducting semantic analysis, establishing a rule library, using the rule library to convert the state management method into a signal method, and using unified rules to refactor code to ensure consistency of the code style.

Benefits of technology

It realizes fast and accurate signal introduction, ensures high quality of code conversion, facilitates subsequent maintenance, and improves the maintainability and performance of code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120315690B_ABST
    Figure CN120315690B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, apparatus, device, and product for introducing signals into code, including: traversing original files in a project to determine reconfigurable files; determining key nodes in the reconfigurable files; establishing a rule base; matching the code in the reconfigurable files with the rules in the rule base; and converting the state management method for writing code in the reconfigurable files into a signal method for writing code. The present invention discloses a method, apparatus, device, and product for introducing signals into code. These methods can accurately locate original files that may be reconstructed in a project, eliminating the need for developers to manually search for them one by one. At the same time, they employ unified rules for code reconstructing, ensuring consistency in the style of the reconstructed and replaced code, making it easier for subsequent maintenance personnel to understand and modify the code. The methods have the advantages of fast code conversion speed, high conversion quality, and ease of later maintenance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer software, and in particular relates to a method, apparatus, device and product for introducing a signal into a code. Background Art

[0002] In the field of front-end development, signals, as an emerging responsive programming feature, have attracted much attention. Emerging with the continuous evolution of frameworks, signals provide a more direct way to handle application state. Developers can easily define and update signal values, and due to their responsive nature, any changes to signal values ​​are reflected in the application's behavior in real time, making the application's responsive logic clearer, easier to understand, and easier to maintain. At the same time, by precisely controlling state updates and propagation paths, signals can avoid unnecessary rendering and calculation processes. In complex application scenarios, this performance optimization can significantly improve application efficiency and reduce resource waste. Under existing technical conditions, introducing signals is not an easy task for many legacy software projects developed before the advent of the signal feature. These legacy projects often contain massive amounts of code, involving a variety of components, services, and complex business logic. This makes it difficult for subsequent maintainers to manually introduce signals into legacy projects, resulting in heavy workloads, inaccurate signal introduction locations, and difficulties in ensuring code quality and subsequent maintainability. Summary of the Invention

[0003] In view of this, the present invention aims to overcome the defects in the prior art and proposes a method, device, equipment and product for introducing a signal into a code.

[0004] To achieve the above object, the technical solution of the present invention is achieved as follows:

[0005] In a first aspect, the present invention discloses a method for introducing a signal into a code, comprising:

[0006] Traversing the original files in the project, and if the original files meet the first preset condition, determining that the original files are reconstructible files;

[0007] Performing semantic analysis on the code of the reconfigurable file to determine key nodes in the reconfigurable file, wherein the key nodes are nodes that meet the second preset condition;

[0008] Establish a rule base that includes rules for replacing state management code with signal management code for different types of key nodes.

[0009] The code in the reconfigurable file is matched with the rules in the rule base, and the state management mode of the code in the reconfigurable file is converted into signal mode of the code using the matched rules.

[0010] In one embodiment of the present invention, the first preset condition is that the original file can simultaneously meet the following requirements:

[0011] The file type of the original file matches the type of the project;

[0012] Ability to obtain the source files and dependent files of the original files;

[0013] Ability to determine the initial node in the original file;

[0014] Ability to recursively search upwards based on the initial node in the original file, querying the parent node until the class declaration node in the original file is found;

[0015] A class declares a node with input directives or components.

[0016] In one embodiment of the present invention, the second preset condition includes:

[0017] If the node is a variable declaration node, and the variable of the variable declaration node is read several times throughout the application and the change of its value affects the behavior of several components, then the variable declaration node is a key node;

[0018] If the node is a function call node, and the function of the function call node is used to update the component state and its call logic matches the signal usage pattern, then the function call node is a key node;

[0019] If the node is an attribute access node, and the write operation of the attribute access node affects the display or behavior of the component and conforms to the signal-driven update mode, then the attribute access node is a key node.

[0020] In one embodiment of the present invention, using the matched rules, converting the state management mode coding in the reconfigurable file into signal mode coding includes:

[0021] Based on the matched rules, a template is created. The template includes the standard code structure and logic for converting the state management mode of code into the signal mode of code.

[0022] By using the template, the state management mode code matching the template in the reconfigurable file is converted into the signal mode code.

[0023] In one embodiment of the present invention, the method further includes: if the function of converting the code into the signal mode in the reconfigurable file is abnormal, restoring the code into the original state management mode and rematching the rules in the rule base.

[0024] In one embodiment of the present invention, the rules in the rule base are manually set and / or created by crawling from a third-party data source using an automated script.

[0025] In one embodiment of the present invention, if the function of the code written in the signal mode converted in the reconfigurable file is abnormal, the method further includes: recording the abnormal function in an error log.

[0026] In a second aspect, the present invention discloses a device for introducing a signal into a code, the device comprising:

[0027] A reconfigurable file determination module is used to traverse the original files in the project and determine that the original file is a reconfigurable file if the original file meets a first preset condition;

[0028] A key node determination module is used to perform semantic analysis on the code of the reconfigurable file to determine the key nodes in the reconfigurable file, wherein the key nodes are nodes that meet the second preset condition;

[0029] Establish a rule base module for establishing a rule base, which includes rules for replacing state management code with signal code corresponding to different types of key nodes;

[0030] The code conversion module is used to match the code in the reconfigurable file with the rules in the rule base, and use the matched rules to convert the state management mode of the code in the reconfigurable file into the signal mode of the code.

[0031] In a third aspect, the present invention discloses an electronic device comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above method.

[0032] In a fourth aspect, the present invention discloses a computer program product, comprising a computer program, which implements the above method when executed by a processor.

[0033] Compared with the prior art, the present invention has the following advantages:

[0034] The present invention discloses a method, apparatus, device, and product for introducing signals into code, including: traversing original files in a project to determine reconfigurable files; determining key nodes in the reconfigurable files; establishing a rule base; matching the code in the reconfigurable files with the rules in the rule base; and converting the state management method for writing code in the reconfigurable files into a signal method for writing code. The present invention discloses a method, apparatus, device, and product for introducing signals into code, which can accurately locate original files that may be reconstructed in a project without requiring developers to manually search for them one by one. At the same time, unified rules are used for code reconstructing, ensuring consistency in the style of the reconstructed and replaced code, making it easier for subsequent maintenance personnel to understand and modify the code. The method has the advantages of fast code conversion speed, high conversion quality, and convenient later maintenance. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0036] In the attached figure:

[0037] Figure 1 A schematic diagram of a method for introducing a signal into a code according to an embodiment of the present invention;

[0038] Figure 2 A schematic diagram of determining a reconfigurable file for a method for introducing a signal into code according to an embodiment of the present invention;

[0039] Figure 3 A schematic diagram of determining key nodes in a method for introducing signals into code according to an embodiment of the present invention;

[0040] Figure 4 A schematic diagram of a device for introducing a signal into a code according to an embodiment of the present invention;

[0041] Figure 5 The figure is a schematic diagram of an electronic device for introducing signals into code according to an embodiment of the present invention. DETAILED DESCRIPTION

[0042] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0043] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the present invention.

[0044] In the description of the present invention, it should be noted that, unless otherwise expressly specified or limited, the terms "mounted," "connected," and "connected" should be understood in a broad sense. For example, they may refer to fixed connections, detachable connections, or integral connections; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; and internal communication between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.

[0045] In the description of the present invention, it should be further clarified that the terms "first," "second," etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature specified as "first," "second," etc. may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "plurality" means two or more.

[0046] Under existing technical conditions, in the process of introducing signals into projects, manual methods are mainly used. Developers must check and modify each code position involving relevant state management or responsive behavior one by one. This method of manually introducing signals is huge in the face of old projects with a large amount of code and complex logic. It takes a lot of time and energy and is extremely inefficient. In addition, manual operation makes it difficult to accurately identify all locations suitable for introducing signals. Omissions or misjudgments may occur, resulting in incomplete signal introduction or introduction of signals at inappropriate locations, which makes it impossible to give full play to the advantages of signal characteristics. At the same time, in projects, manual introduction of signals is manual due to the lack of unified standards and specifications. Different developers may have different modification methods, and the code style cannot be completely unified, making it difficult to ensure the quality of the code and its later maintainability. The present invention discloses a method, device, equipment and product for introducing signals into code, which can accurately locate the original files that may be reconstructed in the project without the need for developers to manually search one by one. At the same time, unified rules are used for code reconstructing to ensure the consistency of the code style after the reconstruction and replacement, making it convenient for subsequent maintenance personnel to understand and modify the code. The method has the advantages of fast code conversion speed, high conversion quality and convenient later maintenance.

[0047] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0048] In one embodiment of the present invention, Figure 1 As shown, a method for introducing a signal in a code includes:

[0049] Step S101, traversing the original files in the project, and if the original file meets a first preset condition, determining that the original file is a reconstructible file;

[0050] Step S102, performing semantic analysis on the code of the reconfigurable file to determine key nodes in the reconfigurable file, wherein the key nodes are nodes that meet the second preset condition;

[0051] In this embodiment, semantic analysis is performed on the code of the reconfigurable file by using an Abstract Syntax Tree (AST) algorithm to perform semantic analysis on the code and obtain key nodes related to state management.

[0052] In this embodiment, the key node is a node involved in state management.

[0053] In this embodiment, key nodes in the reconfigurable file are determined through semantic analysis, thereby achieving the location of the code that can be replaced by the signal writing method in the reconfigurable file.

[0054] Step S103: Establish a rule base, which includes rules for replacing state management mode coding with signal mode coding corresponding to different types of key nodes;

[0055] In this embodiment, the rules in the rule base are managed using a hierarchical classification architecture. First, a first-level classification is performed according to the common state management modes in front-end development, which are divided into different types of state management modes such as event-driven, data binding, and global variables. For each mode, a second-level classification is performed. For example, for button click event processing and form submission event processing in the event-driven mode, each rule defines in detail the applicable code structure characteristics, the variables involved, the function call mode, and other information, which is used to replace the state management mode code corresponding to the key nodes with the signal mode code.

[0056] In this embodiment, the establishment of a rule base ensures that the introduced signals are based on unified standards and specifications, making the code style consistent, making it easier for subsequent maintenance personnel to understand and modify the code, and reducing the subsequent maintenance costs.

[0057] In this embodiment, the rules in the rule base are manually set and / or created by crawling from third-party data sources using automated scripts.

[0058] For example, we maintain close contact with the front-end technology community, open source projects, and industry standards, regularly scan new code practices and technology trends, use automated scripts to capture new cases involving signal usage and state management optimization from relevant technical forums and code repositories, and add new rules to the rule base at any time.

[0059] Step S104: Match the code in the reconfigurable file with the rules in the rule base, and use the matched rules to convert the state management mode code in the reconfigurable file into the signal mode code.

[0060] Furthermore, step S104 also includes: establishing a template based on the matched rules, the template including a standard code structure and logic for converting the state management mode written code into the signal mode written code; using the template, converting the state management mode written code that matches the template in the reconfigurable file into the signal mode written code.

[0061] Exemplarily, in the reconfigurable file, the state management mode coding corresponding to the determined key nodes is converted into signal mode coding by using the template corresponding to the matching rule.

[0062] In this embodiment, the code structure and logic in the template are appropriately abstracted, the common parts are extracted, and the variable parts are parameterized. For example, for different types of variable declarations, the basic structure of the converted signals is similar, but the variable type, name, and initial value may be different. By parameterizing these variables, the same template can be applied to multiple similar situations, improving the template's applicability.

[0063] In this embodiment, information such as the reconstructed code location, applied rules and templates, and code snippets before and after replacement is backed up and recorded to facilitate subsequent rollback operations.

[0064] Based on the previous embodiment, in another embodiment of the present invention, the method further includes: if the function of the code written in the signal mode converted in the reconfigurable file is abnormal, then the code is restored to the original state management mode, and the rules in the rule base are re-matched, and at the same time, the abnormal function is recorded in the error log.

[0065] In this embodiment, the rules in the rule base are supplemented according to the records in the error log.

[0066] In another embodiment of the present invention, Figure 2As shown, the first precondition is that the original file can simultaneously meet the following requirements:

[0067] The file type of the original file matches the type of the project;

[0068] Exemplarily, the project type is determined based on features such as the project's file structure, dependency, and code style, and it is further determined whether the file type of the original file belongs to the project type.

[0069] In this embodiment, the corresponding rule library and template can be loaded according to the determined project type. For small single-page application projects, a lighter-weight signal introduction strategy is adopted; while for large enterprise-level projects, a signal introduction strategy that focuses on performance optimization and architecture compatibility is adopted.

[0070] The source file and dependent files of the original file can be obtained to determine whether the code replacement of the file is meaningful.

[0071] Ability to determine the initial node in the original file to determine if the file is corrupted.

[0072] In this embodiment, the method for determining the initial node is: determining the starting position of the file to be searched, and finding the minimum grammatical unit node containing the starting position, which is the initial node.

[0073] It is possible to recursively search upwards based on the initial node in the original file to query the parent node until the class declaration node in the original file is found to determine whether the file is within the valid class definition range and can be reconstructed.

[0074] The class declaration node carries input instructions or components to ensure that the file is not a tool class or a mathematical calculation class file.

[0075] In another embodiment of the present invention, Figure 3 As shown, the second preset condition includes:

[0076] If the node is a variable declaration node, and the variable of the variable declaration node is read several times throughout the application and the change of its value affects the behavior of several components, then the variable declaration node is a key node;

[0077] If the node is a function call node, and the function of the function call node is used to update the component state and its call logic matches the signal usage pattern, then the function call node is a key node;

[0078] For example, for a function call node, check its specific function call example in the code, for example, a function for updating component status, check whether the called function is related to status management and whether the way the function parameters are passed complies with the logic of signal usage.

[0079] For example, whether the function parameter passing method conforms to the logic used by the signal can be to update the state according to specific conditions and trigger the re-rendering of related components.

[0080] If the node is an attribute access node, and the write operation of the attribute access node affects the display or behavior of the component and conforms to the signal-driven update mode, then the attribute access node is a key node.

[0081] like Figure 4 As shown, the present invention also discloses a device for introducing a signal into a code, comprising:

[0082] The reconfigurable file determination module 401 is configured to traverse the original files in the project and determine that the original file is a reconfigurable file if the original file meets a first preset condition;

[0083] A key node determination module 402 is configured to perform semantic analysis on the code of the reconfigurable file to determine key nodes in the reconfigurable file, wherein the key nodes are nodes that meet a second preset condition;

[0084] A rule base establishment module 403 is used to establish a rule base, which includes rules for replacing state management mode coding with signal mode coding corresponding to different types of key nodes;

[0085] The code conversion module 404 is used to match the code in the reconfigurable file with the rules in the rule library, and convert the state management mode code in the reconfigurable file into the signal mode code using the matched rules.

[0086] The present invention also discloses an electronic device, such as Figure 5 As shown, an embodiment is disclosed, which is a block diagram of an electronic device for introducing a signal into a code.

[0087] The electronic device 50 of this embodiment includes a processor 501, which can perform various appropriate actions and processes according to the program stored in the ROM 502 or the program loaded from the storage part 508 into the RAM 503. The processor 501 may include, for example, a general-purpose microprocessor, an instruction set processor and / or a related chipset and / or a dedicated microprocessor, etc. The processor 501 may also include onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present invention.

[0088] RAM 503 stores various programs and data required for the operation of electronic device 50. Processor 501, ROM 502, and RAM 503 are interconnected via bus 504. Processor 501 executes the programs in ROM 502 and / or RAM 503 to perform various operations according to the method flow of the embodiment of the present invention. It should be noted that the programs may also be stored in one or more memories other than ROM 502 and RAM 503, and processor 501 may also execute the programs stored in one or more memories to perform various operations according to the method flow of the embodiment of the present invention.

[0089] According to an embodiment of the present invention, the electronic device 50 may further include an I / O interface 505, which is also connected to the bus 504. The electronic device 50 may further include one or more of the following components connected to the I / O interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube, a liquid crystal display, and a speaker; a storage portion 508 including a hard disk; and a communication portion 509 including a network interface card such as a LAN card or a modem. The communication portion 509 performs communication processing via a network such as the Internet. A drive 5010 is also connected to the I / O interface 505 as needed. A removable medium 5011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed in the drive 5010 as needed, so that a computer program read therefrom can be installed into the storage portion 508 as needed.

[0090] The present invention also provides a computer-readable storage medium.

[0091] The computer-readable storage medium may be included in the electronic device / device system described in the above embodiments, or may exist independently and not be incorporated into the electronic device / device. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of the present invention.

[0092] According to an embodiment of the present invention, a computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples include, but are not limited to, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) or flash memory, a portable compact disk read-only memory (CDROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0093] Embodiments of the present invention also include a computer program product.

[0094] The computer program product includes a computer program, which contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the method provided by the embodiment of the present invention.

[0095] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal over a network medium. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0096] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written by any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level procedural and / or object-oriented programming languages. Programming languages ​​include, but are not limited to, Java, C++, Python, C language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network or a wide area network, or can be connected to an external computing device.

[0097] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of the systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the boxes may occur in an order different from that marked in the accompanying drawings. For example, two boxes shown in succession may actually be executed substantially in parallel, or they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, as well as the combination of boxes in the block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or may be implemented using a combination of dedicated hardware and computer instructions. It will be understood by those skilled in the art that the features described in the various embodiments and / or claims of the present invention may be combined and / or coupled in various ways, even if such combinations or couplings are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments and / or claims of the present invention may be combined and / or coupled in various ways, and all such combinations and / or couplings fall within the scope of the present invention.

[0098] The embodiments of the present invention have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present invention. Although each embodiment has been described above separately, this does not mean that the measures in each embodiment cannot be advantageously used in combination. The scope of the present invention is defined by the appended claims and their equivalents. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A method for introducing a signal into a code, characterized in that include: Traversing original files in the project, and determining that the original file is a reconstructible file if the original file meets a first preset condition; Performing semantic analysis on the code of the reconfigurable file to determine key nodes in the reconfigurable file, wherein the key nodes are nodes that meet a second preset condition; Establishing a rule base, the rule base including rules for replacing codes written in a state management mode with codes written in a signal mode corresponding to different types of key nodes; Matching the code in the reconfigurable file with the rules in the rule base, and using the matched rules to convert the state management mode written code in the reconfigurable file into signal mode written code; The first preset condition is that the original file can simultaneously meet the following requirements: The file type of the original file matches the type of the project; Ability to obtain the source file and dependent files of the original file; capable of determining an initial node in said original file; It is possible to recursively search upwards based on the initial node in the original file to query the parent node until the class declaration node in the original file is found; The class declaration node carries an input instruction or component; The second preset condition includes: If the node is a variable declaration node, and the variable of the variable declaration node is read several times in the entire application and the change of its value affects the behavior of several components, then the variable declaration node is the key node; If the node is a function call node, and the function of the function call node is used to update the component state and its call logic matches the signal usage pattern, then the function call node is the key node; If the node is an attribute access node, and a write operation of the attribute access node affects the display or behavior of the component and complies with a signal-driven update mode, then the attribute access node is the key node.

2. A method for introducing a signal into a code according to claim 1, characterized in that: The method of converting the state management mode coding in the reconfigurable file into signal mode coding by using the matched rules includes: Creating a template based on the matched rules, the template including a standard code structure and logic for converting a code written in a state management mode into a code written in a signal mode; The template is used to convert the state management mode coding that matches the template in the reconfigurable file into signal mode coding.

3. A method for introducing a signal into a code according to claim 1, characterized in that: The method further includes: if the function of writing code in the signal mode converted in the reconfigurable file is abnormal, restoring the code to the original state management mode and re-matching the rules in the rule base.

4. A method for introducing a signal into a code according to claim 1, characterized in that: The rules in the rule base are manually set and / or created by crawling from third-party data sources using automated scripts.

5. A method for introducing a signal into a code according to claim 3, characterized in that: If the function of writing the code in the signal mode converted in the reconfigurable file is abnormal, the method further includes: recording the abnormal function in an error log.

6. A device for introducing a signal into a code, characterized in that: The device comprises: a module for determining a reconfigurable file, configured to traverse original files in a project and determine that the original file is a reconfigurable file if the original file meets a first preset condition; a key node determination module, configured to perform semantic analysis on the code of the reconfigurable file to determine key nodes in the reconfigurable file, wherein the key nodes are nodes that meet a second preset condition; Establishing a rule base module, which is used to establish a rule base, wherein the rule base includes rules for replacing codes written in a state management mode with codes written in a signal mode corresponding to different types of key nodes; A code conversion module is used to match the code in the reconfigurable file with the rules in the rule library, and use the matched rules to convert the state management mode of the code in the reconfigurable file into signal mode of code; the first preset condition is that the original file can simultaneously meet the following conditions: the file type of the original file matches the type of the project; the source file and dependent files of the original file can be obtained; the initial node can be determined in the original file; the parent node can be recursively queried based on the initial node in the original file until the class declaration node in the original file is found; the class declaration node has an input instruction or component ; The second preset condition includes: if the node is a variable declaration node, and the variable of the variable declaration node is read several times in the entire application and the change of its value affects the behavior of several components, then the variable declaration node is the key node; if the node is a function call node, and the function of the function call node is used to update the component state and its calling logic matches the signal usage pattern, then the function call node is the key node; if the node is an attribute access node, and the write operation of the attribute access node affects the display or behavior of the component, and conforms to the signal-driven update pattern, then the attribute access node is the key node.

7. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are caused to perform the method according to any one of claims 1 to 5.

8. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Code conversion method and device, computer equipment and storage medium

    CN119621074A