Code editing method and device, electronic equipment and storage medium

By building a tree-like model tree and displaying the hierarchical relationship of the model, the problems of low code positioning efficiency and unclear model structure in existing simulation software are solved, and the modeling efficiency of simulation engineers is improved.

CN120068192APending Publication Date: 2025-05-30CHENGDU GONGDING TECHNOLOGY CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510236248.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-28
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

When existing simulation software builds complex models, the general editor cannot quickly locate the code locations that need to be modified, and cannot clearly display the hierarchical structure of the model, resulting in a reduced modeling efficiency for simulation engineers.

Method used

By obtaining the object code and parsing its model type and model name, building a tree-like structured model tree and displaying the hierarchical relationship of the model tree, it is convenient for users to quickly locate the required lines of code.

Benefits of technology

It realizes rapid code positioning and clear display of model structure, improving the modeling efficiency of simulation engineers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120068192A_ABST
    Figure CN120068192A_ABST
Patent Text Reader

Abstract

The invention provides a code editing method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining target codes which are codes of the same part; analyzing the target code, and determining a model type and a model name in the target code; based on the components, the model types and the model names, a model tree is constructed, the model tree comprises nodes of a first hierarchy formed by the components, nodes of a second hierarchy formed by the model types and nodes of a third hierarchy formed by the model names, and the model tree is of a tree structure; and performing editing operation on the target code based on the model tree. According to the code editing method provided by the invention, quick positioning of codes can be realized, and the modeling efficiency of engineers is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of simulation technology, and particularly to a code editing method, apparatus, electronic device, and storage medium. Background Art

[0002] Simulation engineers need to use simulation software to build models during work. Currently, mainstream simulation software all supports the method of building models using code. When simulation engineers use code to build complex models, they usually need to input hundreds or thousands of lines of code. At this time, general editors cannot quickly locate the code positions related to the specific model to be modified, and also cannot display a clearly hierarchical model structure, which will reduce the modeling efficiency of simulation engineers. Summary of the Invention

[0003] To solve the above technical problems, this application provides a code editing method, apparatus, electronic device, and storage medium to achieve rapid code positioning and improve the modeling efficiency of engineers.

[0004] According to the first aspect of the embodiments of this application, a code editing method is provided. The method includes:

[0005] Obtain target code, where the target code is the code of the same component;

[0006] Parse the target code to determine the model type and model name in the target code;

[0007] Based on the component, model type, and model name, construct a model tree. The model tree includes nodes at the first level composed of components, nodes at the second level composed of model types, and nodes at the third level composed of model names. The model tree is a tree structure;

[0008] Perform an editing operation on the target code based on the model tree.

[0009] In an alternative embodiment, performing an editing operation on the target code based on the model tree includes:

[0010] In response to an operation of selecting a node in the model tree, determine the line number corresponding to the selected node;

[0011] Display the code corresponding to the line number.

[0012] In an alternative embodiment, displaying the code corresponding to the line number includes:

[0013] Obtain the number of lines of code that can be accommodated in the code editing area;

[0014] Based on the number of lines of code that can be accommodated and the line number, determine the display area of the code so that the distance between the display area and the upper and lower boundaries of the code editing area is equal.

[0015] In an alternative embodiment, determining the line number corresponding to the selected node includes:

[0016] Obtaining a mapping relationship, where the mapping relationship is the mapping relationship between the model name and component and the code line number;

[0017] Determining the line number corresponding to the selected node according to the mapping relationship and the selected node.

[0018] In an alternative embodiment, presenting the code corresponding to the line number includes:

[0019] Sliding to the code corresponding to the line number in the target code based on the line number;

[0020] Performing a marking process on the code corresponding to the line number;

[0021] Presenting the marked code.

[0022] In an alternative embodiment, performing an editing operation on the code based on the model tree includes:

[0023] Responding to the selection operation of the target code and the operation of presenting the node, determining the node corresponding to the selected code;

[0024] Presenting the node corresponding to the selected code.

[0025] In an alternative embodiment, determining the node corresponding to the selected code includes:

[0026] Obtaining the line number corresponding to the selected code;

[0027] Determining the node corresponding to the line number according to the line number corresponding to the key-value pair stored in the container; the key-value pair includes the node corresponding to the line number.

[0028] In an alternative embodiment, presenting the node corresponding to the selected code includes:

[0029] Determining the level of the node corresponding to the selected code in the model tree;

[0030] Sliding to the model name corresponding to the selected code based on the level, and performing a marking process on the model name;

[0031] Presenting the marked model name.

[0032] According to the second aspect of the embodiments of the present application, there is provided a code editing device, the device includes:

[0033] An obtaining unit, configured to obtain target code, where the target code is the code of the same component;

[0034] A first determination unit, configured to parse the target code to determine the model type and model name in the target code;

[0035] A construction unit, configured to construct a model tree based on components, model types, and model names. The model tree includes nodes at a first level composed of components, nodes at a second level composed of model types, and nodes at a third level composed of model names, and the model tree is a tree structure;

[0036] An editing unit, configured to perform an editing operation on the code based on the model tree.

[0037] According to a third aspect of the embodiments of the present application, an electronic device is provided, including a memory and a processor;

[0038] The memory is connected to the processor and is used to store programs;

[0039] The processor is configured to implement the code editing method as described in the first aspect or any one of the embodiments of the first aspect by running the programs in the memory.

[0040] According to a fourth aspect of the embodiments of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is run by a processor, the code editing method as described in the first aspect or any one of the embodiments of the first aspect is implemented.

[0041] The code editing method, device, electronic device, and storage medium provided by the present application parse the target code of the same component to obtain the model type and model name in the target code, and construct a model tree using the components, model types, and model names, so that the model tree can clearly display the hierarchical relationship of the models. Among them, the model tree includes nodes at a first level composed of components, nodes at a second level composed of model types, and nodes at a third level composed of model names. Through the hierarchical tree structure of the model tree, the hierarchical structure of the model can be clearly displayed, facilitating the user to quickly locate the required code line and improving the code modeling efficiency of simulation engineers. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0043] Figure 1 It is a flowchart of the code editing method provided by the embodiments of the present application;

[0044] Figure 2Schematic diagram of the model tree provided by the embodiments of the present application;

[0045] Figure 3 Structural block diagram of the code editing device provided by the embodiments of the present application;

[0046] Figure 4 Structural schematic diagram of the code editing system provided by the embodiments of the present application;

[0047] Figure 5 Structural diagram of the electronic device provided by the embodiments of the present invention. Detailed implementation manners

[0048] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0049] Simulation engineers need to use simulation software to build models in their work. Currently, mainstream simulation software supports the method of building models using code. When simulation engineers use code to build complex models, they usually need to input hundreds or thousands of lines of code. At this time, the general editor cannot quickly locate the code position related to the specific model that needs to be modified, and it also cannot display a clearly hierarchical model structure, which will reduce the modeling efficiency of simulation engineers.

[0050] The code editing method, device, electronic device, and storage medium provided by the embodiments of the present application parse the target code of the same component to obtain the model type and model name in the target code, and use the component, model type, and model name to build a model tree, so that the model tree can clearly display the hierarchical relationship of the model. Among them, the model tree includes nodes at the first level composed of components, nodes at the second level composed of model types, and nodes at the third level composed of model names. Through the hierarchical tree structure of the model tree, the hierarchical structure of the model can be clearly displayed, which is convenient for users to quickly locate the required code lines and improves the code modeling efficiency of simulation engineers.

[0051] Exemplary method

[0052] Figure 1 Flowchart of the code editing method provided by the embodiments of the present application. Please refer to Figure 1 , in an exemplary embodiment, a code editing method is provided, which may include the following steps:

[0053] S110: Obtain target code, where the target code is the code of the same component.

[0054] Multi-body dynamics (MBD) simulation software is used to simulate the motion and interaction of complex mechanical systems. This type of software allows users to build models by defining the various components in the system and their relationships, and then perform simulations to analyze the dynamic behavior of these systems.

[0055] The components can be any components in the system, such as: vehicle frame, body, suspension system, etc.

[0056] S130: Parse the target code to determine the model type and model name in the target code.

[0057] In practical applications, a parser can be written to parse the target code to obtain the model type and model name in the target code text. The model type can be the attribute information of the component. For example: the model type can be: rigid body, flexible body, joint, constraint condition, force element, etc. Figure 2 This is the schematic diagram of the model tree provided by the embodiment of the present application. As Figure 2 shown, the model types in the code of component 1 can include API types of groudpart and point. In the groundpart type of model, it can include an element with the model name of ground. In the point type of model, it can include elements with the model names of lca_front and lca_rear. The model types in component 2 can include marker type and part type.

[0058] S150: Build a model tree based on the component, model type, and model name;

[0059] The model tree includes nodes at the first level composed of components, nodes at the second level composed of model types, and nodes at the third level composed of model names. The model tree is a tree structure. As Figure 2 shown, the model tree can use the component as a segmentation unit to segment the code and display the code in hierarchical levels.

[0060] S170: Perform an editing operation on the target code based on the model tree.

[0061] The editing operation on the target code can include jumping to the code by selecting nodes in the model tree and jumping to the nodes in the model tree by selecting the code.

[0062] The code editing method provided by the embodiments of the present application classifies the simulation model code according to components, parses the target code of the same component to obtain the model type and model name in the target code, and constructs a model tree using the components, model types, and model names, so that the model tree can clearly display the hierarchical relationship of the models. When editing the code, it is possible to realize code jumping by selecting a node or jumping from the selected code to the corresponding node in the model tree, which facilitates the user to quickly locate the required code line for code editing work and improves the code modeling efficiency of simulation engineers.

[0063] In an alternative embodiment, the editing operation on the target code based on the model tree may include:

[0064] In response to an operation of selecting a node in the model tree, determine the line number corresponding to the selected node;

[0065] Display the code corresponding to the line number.

[0066] It should be noted that the line numbers corresponding to the code are saved in both the components at the first level and the model names at the third level in the model tree of the embodiments of the present application. The selected node can be displayed in the user's UI interface, but the line numbers are not displayed on the UI interface. The purpose of saving the line numbers is to implement the jump function in code editing. When the node is selected, it jumps to the corresponding line.

[0067] Since when positioning and jumping to the API code line in the editor, an unstable jumping method may cause the position of the code to be at random positions such as the top or bottom of the editor page when jumping to that line of code. To keep the code line at the center of the editor after jumping, the code editing method provided by the embodiments of the present application may include, when displaying the code corresponding to the line number:

[0068] Obtain the number of lines of code that can be accommodated in the code editing area;

[0069] Based on the number of lines of code that can be accommodated and the line number, determine the display area of the code so that the distance between the display area and the upper and lower boundaries of the code editing area is equal.

[0070] In practical applications, since the scaling ratio of the code editing area is different, the size of the editing area is not fixed. The number of lines of code that can be accommodated in the code editing area can be determined by dividing the width H of the editing area by the line height L_H. If the number of lines of code that can be accommodated in the code editing area is T, then t = T / 2, that is, t is half of the number of lines that can be accommodated. Obtain the maximum value max of the vertical sliding module of the code editing area. When the line number L is less than t, slide to the top. When the line number L is greater than max - t, slide to the bottom. When the line number L is greater than t and less than max - t, when sliding to the position of [(L - t) / (L_max - T)] * max, this line just slides to the middle position of the code editor area.

[0071] Place the code in the middle of the editor area for display, which is convenient for users to read the code and improves the user experience.

[0072] In an alternative embodiment, determining the line number corresponding to the selected node includes:

[0073] Obtain the mapping relationship, where the mapping relationship is the mapping relationship between the model name and components and the code line number;

[0074] Determine the line number corresponding to the selected node according to the mapping relationship and the selected node.

[0075] In practical applications, code jumping can be implemented through the slider module. The mapping relationship, that is, the corresponding relationship between the line number and the value stored in the sliding module, is stored in the slider module. For example: when the line number is 16, the value corresponding to the sliding module is 106. Through the corresponding relationship between the line number and the value stored in the sliding module, code jumping can be realized after the node is selected.

[0076] In order to improve the recognition of the code, the code editing method provided in the embodiments of the present application when displaying the code corresponding to the line number may include:

[0077] Slide to the code corresponding to the line number in the target code based on the line number;

[0078] Perform a marking process on the code corresponding to the line number;

[0079] Display the marked code.

[0080] In practical applications, the marking process may include marking the font of the code with different colors or styles. For example: highlighting the code.

[0081] Through the marking of the code, users can more easily determine the corresponding code and increase the readability of the code.

[0082] In an alternative embodiment, editing the code based on the model tree includes:

[0083] In response to the selection operation on the target code and the operation of displaying nodes, determine the node corresponding to the selected code;

[0084] Display the node corresponding to the selected code.

[0085] It should be noted that the model tree in the embodiments of this application contains codes at different levels. By selecting the target code, it is possible to reverse-locate the nodes in the model tree for display.

[0086] In an alternative embodiment, determining the node corresponding to the selected code includes:

[0087] Obtain the line number corresponding to the selected code;

[0088] Determine the node corresponding to the line number according to the line numbers corresponding to the key-value pairs stored in the container; the key-value pairs include the nodes corresponding to the line numbers.

[0089] In practical applications, a map container can be constructed to store key-value pairs <line number - node object> in the container, where the key is the line number and the value is an object containing node data. When the user selects the line where the code is located and triggers a shortcut key or the corresponding reverse-location button, the editing page will automatically obtain the current line number, and the node object can be queried in the Map container using this line number. Then, using the function of the model tree control, it can be directly scrolled to the position of the corresponding node object.

[0090] In an alternative embodiment, displaying the node corresponding to the selected code includes:

[0091] Determine the level of the node corresponding to the selected code in the model tree;

[0092] Based on the level, scroll to the model name corresponding to the selected code and perform a marking process on the model name;

[0093] Display the marked model name.

[0094] In practical applications, the marking process may include marking the font of the model name with different colors or styles. For example, highlighting the model name.

[0095] By marking the model name, it enables the user to more easily determine the corresponding node, reduces the user's search time, and improves the efficiency of simulation.

[0096] To further improve the speed and accuracy of model tree construction, the code editing method provided in the embodiments of this application may further include:

[0097] Obtain a model list; the model list is a modeling API list for complementing APIs according to preset characters included in the code.

[0098] When characters in the input code that match those in the model list are recognized, based on the user's selection operation, the models with the same characters in the model list are added to the model tree, and the model tree is updated.

[0099] For example, when the user inputs "p", the model list can be called up. As the user continues to type, the model list continuously filters out APIs with the same prefix and prompts to automatically complete the subsequent API content. For example, when typing "pySimSDK.CreateG", only "pySimSDK.CreateGroundPart(Parameter 1: Name, Parameter 2)" will be displayed. When typing "p", all APIs, namely "pySimSDK.CreateGroundPart(Parameter 1: Name, Parameter 2)", "pySimSDK.CreatePoint(Parameter 1: Name, Parameter 2)", and "pySimSDK.CreateMarker(Parameter 1: Name, Parameter 2)", will be prompted. The model list can match the API list in real time according to the user's input and update the API list in the pop-up window, which facilitates the user to perform modeling using the code API.

[0100] Exemplary device

[0101] Correspondingly, an embodiment of the present application further provides a code editing device. Figure 3 It is a structural block diagram of the code editing device provided by the embodiment of the present application. As Figure 3 shown, the device includes:

[0102] An acquisition unit 320, configured to acquire a target code, where the target code is the code of the same component;

[0103] A first determination unit 340, configured to parse the target code to determine the model type and model name in the target code;

[0104] A construction unit 360, configured to construct a model tree based on the component, the model type, and the model name. The model tree includes nodes at the first level composed of components, nodes at the second level composed of model types, and nodes at the third level composed of model names. The model tree is a tree structure;

[0105] An editing unit 380, configured to perform an editing operation on the code based on the model tree.

[0106] The code editing device provided in this embodiment belongs to the same inventive concept as the code editing method provided in the above embodiments of the present application. It can execute the code editing method provided in any of the above embodiments of the present application and has the corresponding functional modules and beneficial effects for executing the code editing method. For technical details not described in detail in this embodiment, reference can be made to the specific processing content of the code editing method provided in the above embodiments of the present application, which will not be elaborated here.

[0107] The functions implemented by the above-mentioned acquisition unit 320, first determination unit 340, construction unit 360, and editing unit 380 can be implemented by the same or different processors respectively, which is not limited in the embodiments of the present application.

[0108] It should be understood that the acquisition unit 320, first determination unit 340, construction unit 360, and editing unit 380 in the above device can be implemented in the form of a processor calling software. For example, the device includes a processor, the processor is connected to a memory, and instructions are stored in the memory. The processor calls the instructions stored in the memory to implement any of the above methods or the functions of each unit of the device. The processor can be a general-purpose processor, such as a CPU or a microprocessor, etc., and the memory can be a memory inside or outside the device. Alternatively, the units in the device can be implemented in the form of a hardware circuit. By designing the hardware circuit, the functions of some or all of the units can be realized. This hardware circuit can be understood as one or more processors. For example, in one implementation, the hardware circuit is an ASIC, and by designing the logical relationship of the components in the circuit, the functions of some or all of the above units are realized. Another example is that in another implementation, the hardware circuit can be implemented by a PLD. Taking an FPGA as an example, it can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured through a configuration file to realize the functions of some or all of the above units. All the units of the above device can be all implemented in the form of a processor calling software, or all implemented in the form of a hardware circuit, or some are implemented in the form of a processor calling software, and the remaining part is implemented in the form of a hardware circuit.

[0109] In an embodiment of the present application, a processor is a circuit with signal processing capabilities. In one implementation, the processor can be a circuit with instruction reading and running capabilities, such as a CPU, microprocessor, GPU, or DSP, etc.; in another implementation, the processor can achieve certain functions through the logical relationship of a hardware circuit, and the logical relationship of this hardware circuit is fixed or can be reconfigured. For example, the processor is a hardware circuit implemented by an ASIC or PLD, such as an FPGA, etc. In a reconfigurable hardware circuit, the process of the processor loading a configuration document to implement the configuration of the hardware circuit can be understood as the process of the processor loading instructions to implement the functions of some or all of the above units. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as a type of ASIC, such as an NPU, TPU, DPU, etc.

[0110] It can be seen that each unit in the above device can be one or more processors (or processing circuits) configured to implement the above method. For example: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.

[0111] In addition, each unit in the above device can be integrated in whole or in part, or can be independently implemented. In one implementation, these units are integrated together and implemented in the form of an SOC. The SOC can include at least one processor for implementing any of the above methods or the functions of each unit of the device. The types of the at least one processor can be different. For example, it includes a CPU and an FPGA, a CPU and an artificial intelligence processor, a CPU and a GPU, etc.

[0112] Exemplary system

[0113] Figure 4 It is a schematic structural diagram of the code editing system provided by the embodiment of the present application, as Figure 4 shown. The system includes an editing page module, a toolbar, an auto-completion module, a model tree, a sliding module, and a TAB page. Among them, the editing page module incorporates the common functions in a general editor, including functions such as programming language code parsing and keyword highlighting. At the same time, the editing page module can also provide various types of interfaces for external calls, which facilitates the cooperation with other plugin modules to achieve functions customized to meet specific scenario usage requirements. The functions included in the toolbar are functions such as save as, save, and new. The sliding module is built into the editor page module and can not only slide normally but also cooperate with the model tree to achieve quick code positioning.

[0114] The auto - completion module matches the Application Programming Interface (API for short) and identifies whether the current line input matches the API in the API documentation. If there is a match, it provides options for the user to select the API that needs to be auto - completed, facilitating the user to use code for modeling.

[0115] The model tree stores the model information created using code in all editing pages, clearly showing the hierarchical structure of the models, facilitating the user to quickly locate the required code lines and view the created model information.

[0116] The functions of the TAB page include creating and deleting editing pages, and at the same time binding different plugins to the editing page of the current TAB page according to the switching signal. When switching the editing page, the model tree, toolbar, and sliding module will be re - bound to the editing page of the current TAB page to implement the specific functions of the plugin module.

[0117] Exemplary electronic device

[0118] Another embodiment of this application also proposes an electronic device. Refer to Figure 5 As shown, the device includes:

[0119] A memory 500 and a processor 510;

[0120] Among them, the memory 500 is connected to the processor 510 and is used to store programs;

[0121] The processor 510 is used to implement the code editing method disclosed in any of the above embodiments by running the program stored in the memory 500.

[0122] Specifically, the above - mentioned electronic device may further include: a bus, a communication interface 520, an input device 530, and an output device 550.

[0123] The processor 510, the memory 500, the communication interface 520, the input device 530, and the output device 550 are interconnected through the bus. Among them:

[0124] The bus may include a path for transmitting information between various components of the computer system.

[0125] The processor 510 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the solution of the present invention. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0126] The processor 510 may include a main processor, and may also include a baseband chip, a modem, etc.

[0127] The memory 500 stores a program for executing the technical solution of the present invention, and may also store an operating system and other key services. Specifically, the program may include program code, and the program code includes computer operation instructions. More specifically, the memory 500 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk memory, a flash memory, etc.

[0128] The input device 530 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer or a gravity sensor, etc.

[0129] The output device 550 may include a device for allowing information to be output to a user, such as a display screen, a printer, a speaker, etc.

[0130] The communication interface 520 may include a device of any transceiver type for communicating with other devices or communication networks, such as Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc.

[0131] The processor 510 executes the program stored in the memory 500 and calls other devices, and can be used to implement each step of any code editing method provided in the above embodiments of the present application.

[0132] An embodiment of the present application also proposes a chip, which includes a processor and a data interface. The processor reads and runs a program stored on a memory through the data interface to execute the code editing method introduced in any of the above embodiments. For the specific processing process and its beneficial effects, reference can be made to the embodiments of the above code editing method.

[0133] Exemplary computer program product and storage medium

[0134] In addition to the above methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions. When the computer program instructions are run by a processor, the processor is caused to execute the steps in the code editing method according to various embodiments of the present application described in any of the above embodiments of this specification.

[0135] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the embodiments of the present application. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, executed as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0136] In addition, an embodiment of the present application may also be a storage medium, on which a computer program is stored. The computer program is executed by a processor to perform the steps in the code editing method according to various embodiments of the present application described in any of the above embodiments of this specification. Specifically, the following steps may be implemented:

[0137] S110: Obtain target code, where the target code is the code of the same component.

[0138] S130: Parse the target code to determine the model type and model name in the target code.

[0139] S150: Build a model tree based on the component, model type, and model name;

[0140] S170: Perform an editing operation on the target code based on the model tree.

[0141] For the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps may be in other sequences or performed simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0142] It should be noted that the embodiments in this specification are all described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the similarities between the embodiments, reference can be made to each other. For the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method embodiments.

[0143] The steps in the methods of the embodiments of the present application can be adjusted, combined, and deleted according to actual needs. The technical features recorded in each embodiment can be replaced or combined.

[0144] The modules and sub-modules in the devices and terminals in the embodiments of the present application can be combined, divided, and deleted according to actual needs.

[0145] In several embodiments provided by the present application, it should be understood that the disclosed terminals, devices, and methods can be implemented in other ways. For example, the terminal embodiments described above are merely illustrative. For example, the division of modules or sub-modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple sub-modules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of devices or modules can be in electrical, mechanical, or other forms.

[0146] The modules or sub-modules described as separate components may or may not be physically separated. The components as modules or sub-modules may or may not be physical modules or sub-modules, that is, they can be located in one place, or distributed to multiple network modules or sub-modules. Some or all of the modules or sub-modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0147] In addition, the functional modules or sub-modules in each embodiment of the present application can be integrated in a processing module, or each module or sub-module can exist physically alone, or two or more modules or sub-modules can be integrated in one module. The above-mentioned integrated modules or sub-modules can be implemented in the form of hardware or in the form of software functional modules or sub-modules.

[0148] Those skilled in the art may further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0149] The steps of the methods or algorithms described in combination with the embodiments disclosed herein can be directly implemented by hardware, software units executed by a processor, or a combination of the two. The software units can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.

[0150] Finally, it should also be noted that in this document, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.

[0151] The above description of the disclosed embodiments enables those skilled in the art to implement or use this application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application will not be limited to the embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A code editing method, characterized in that: include: Obtaining a target code, wherein the target code is a code of the same component; Parsing the target code to determine the model type and model name in the target code; Based on the components, the model types and the model names, construct a model tree, wherein the model tree includes nodes of a first level formed by the components, nodes of a second level formed by the model types and nodes of a third level formed by the model names, and the model tree is a tree structure; The target code is edited based on the model tree.

2. The code editing method according to claim 1, characterized in that: The editing operation on the target code based on the model tree includes: In response to an operation of selecting a node in the model tree, determining a row number corresponding to the selected node; Displays the code corresponding to the line number.

3. The code editing method according to claim 2, characterized in that: The code corresponding to the line number is displayed, including: Get the number of lines that can be accommodated in the code editing area; Based on the number of lines that can accommodate code and the line number, a display area of ​​the code is determined so that the display area is equidistant from an upper boundary and a lower boundary of the code editing area.

4. The code editing method according to claim 2, characterized in that: The determining the row number corresponding to the selected node includes: Obtaining a mapping relationship, wherein the mapping relationship is a mapping relationship between the model name and the component and the code line number; According to the mapping relationship and the selected node, a row number corresponding to the selected node is determined.

5. The code editing method according to claim 4, characterized in that: The code corresponding to the line number is displayed, including: Slide to the code corresponding to the line number in the target code based on the line number; Marking the code corresponding to the line number; Shows the code after the markup.

6. The code editing method according to claim 1, characterized in that: The editing operation on the code based on the model tree includes: In response to an operation of selecting the target code and an operation of displaying the node, determining a node corresponding to the selected code; The node corresponding to the selected code is displayed.

7. The code editing method according to claim 6, characterized in that: The step of determining the node corresponding to the selected code includes: Get the line number corresponding to the selected code; According to the row number corresponding to the key-value pair stored in the container, the node corresponding to the row number is determined; the key-value pair includes the node corresponding to the row number.

8. The code editing method according to claim 7, characterized in that: The displaying of the node corresponding to the selected code includes: Determine the level of the node corresponding to the selected code in the model tree; Sliding to a model name corresponding to the selected code based on the level, marking the model name; Displays the model name after the marker.

9. A code editing device, characterized in that: include: An acquisition unit, used for acquiring a target code, wherein the target code is a code of the same component; A first determining unit, configured to parse the target code to determine a model type and a model name in the target code; A construction unit, configured to construct a model tree based on the components, the model types and the model names, wherein the model tree includes nodes of a first level formed by the components, nodes of a second level formed by the model types and nodes of a third level formed by the model names, and the model tree is a tree structure; The editing unit is used to edit the code based on the model tree.

10. An electronic device, characterized in that: including memory and processor; The memory is connected to the processor and is used to store programs; The processor is used to implement the code editing method according to any one of claims 1 to 8 by running the program in the memory.

11. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the code editing method according to any one of claims 1 to 8 is implemented.