Data Processing Method, Device and System
Through Fair, Flutter source code data is converted into Fair DSL data, component data is extracted and added, and target Fair DSL data is generated, which solves the problem that the Flutter UI interface cannot be updated dynamically, reduces code complexity and maintenance costs, and improves development efficiency.
Patent Information
- Application Number
- CN202110950286.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-18
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2041-08-18
AI Technical Summary
Once released, the UI interface built by Flutter cannot be changed, resulting in complicated code in specific method functions, poor code readability and high maintenance costs.
Through Fair, the Flutter source code data corresponding to the interface to be generated is converted into DSL data for the initial Fair domain specific language, extract the DSL data of the target components and specific method functions, and add component DSL data to the interface DSL data to generate target Fair DSL data and send it to the client for analysis.
It reduces the code complexity of specific method functions, improves code readability and maintenance costs, realizes modular code development, and improves development efficiency.
Smart Images

Figure CN113791779B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a data processing method, apparatus, and system. Background Art
[0002] Flutter is an open-source mobile user interface (UI) framework developed by Google. It can support quickly building high-quality native UI interfaces on various systems such as iOS and Android. However, Flutter does not support dynamicization, that is, once the UI interface built by Flutter is released, it cannot be changed. Therefore, Fair came into being. It is an open-source framework for UI and logic dynamicization designed for Flutter to achieve dynamic updates of UI interfaces built based on the Flutter framework. Among them, developers can use Flutter to write description information and / or logic information of components in the interface to be updated. The electronic device converts the source code data written in Flutter into Fair domain-specific language (DSL) through Fair. The client parses the Fair DSL to generate a new UI interface.
[0003] However, if the Fair DSL generated through Fair can generate a complete interface after parsing, it is necessary to ensure that when writing in Flutter, all code is written into the same specific method function (compilation build method function). This makes the code in the specific method function complicated, resulting in poor readability and high maintenance cost of the code in the specific method function. Summary of the Invention
[0004] In view of this, the present application provides a data processing method, apparatus, and system, which can reduce the code complexity in a specific method function to a certain extent, improve the readability of the code in the specific method function, and reduce the code maintenance cost.
[0005] According to a first aspect of the present application, there is provided a data processing method, the method comprising:
[0006] Converting, through Fair, Flutter source code data corresponding to an interface to be generated into initial Fair domain-specific language DSL data, the Flutter source code data including: first source code data and second source code data, the first source code data being Flutter source code data corresponding to a target component in the interface to be generated, and the second source code data being Flutter source code data written into a specific method function, the second source code data including a call statement for the first source code data;
[0007] Extract the component Fair DSL data corresponding to the target component and the interface Fair domain-specific language (DSL) data corresponding to the specific method function from the initial Fair DSL data. The interface Fair DSL data includes: the target component identifier corresponding to the target component in the interface to be generated;
[0008] Add the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate target Fair DSL data;
[0009] Send the target Fair DSL data to the client so that the client can parse the target Fair DSL data to generate an interface.
[0010] According to a second aspect of the present application, there is provided a data processing method, the method comprising:
[0011] Receive the target Fair DSL data of the interface to be generated sent by the server, where the target Fair DSL data is generated by the server using the data processing method described in the foregoing first aspect;
[0012] Parse the target Fair DSL data to generate an interface.
[0013] According to a third aspect of the present application, there is provided a data processing device, the device comprising:
[0014] A generation module for converting the Flutter source code data corresponding to the interface to be generated into initial Fair domain-specific language (DSL) data through Fair. The Flutter source code data includes: first source code data and second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated, and the second source code data is the Flutter source code data written with a specific method function, and the second source code data includes a call statement for the first source code data;
[0015] An extraction module for extracting the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data. The interface Fair DSL data includes: the target component identifier corresponding to the target component;
[0016] An addition module for adding the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate target Fair DSL data;
[0017] A sending module, configured to send the target Fair DSL data to a client, so that the client parses the target Fair DSL data to generate an interface.
[0018] According to a fourth aspect of the present application, there is provided a data processing device, the device includes:
[0019] A receiving module, configured to receive target Fair DSL data to be used for generating an interface sent by a server, where the target Fair DSL data is generated by the server using the data processing method according to any one of claims 1 to 6;
[0020] An analysis module, configured to analyze the target Fair DSL data to generate an interface.
[0021] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the data processing method according to any one of the first aspect or the second aspect are implemented.
[0022] In a sixth aspect, the present application provides an electronic device including: a processor, a memory, and a computer program stored on the memory and executable on the processor, and when the processor executes the program, the steps of the data processing method according to any one of the first aspect or the second aspect are implemented.
[0023] For the prior art, the present application has the following advantages:
[0024] The data processing method provided by the embodiments of this application converts the Flutter source code data corresponding to the interface to be generated into initial Fair domain-specific language (DSL) data through Fair. Component Fair DSL data corresponding to the target component and interface Fair DSL data corresponding to specific method functions are extracted from the initial Fair DSL data. And the component Fair DSL data corresponding to the target component is added to the interface Fair DSL data to generate target Fair DSL data. Then, the target Fair DSL data is sent to the client so that the client can parse the target Fair DSL data to generate an interface. In this technical solution, the Flutter source code data includes: first source code data and second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated. The second source code data is the Flutter source code data written with specific method functions, and the second source code data includes a call statement for the first source code data. By calling the component Fair DSL data corresponding to the target component in the interface Fair DSL data, it is possible to generate a complete interface through Fair based on the Flutter source code data corresponding to the independently encapsulated target component and the Flutter source code data of specific method functions. Compared with the prior art, it is not necessary to write all the Flutter source code data corresponding to all the interfaces to be generated, including each component of the interface, into the specific method function, which reduces the complexity of the code in the specific method function, improves the readability of the code in the specific method function, and reduces the maintenance cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 is a schematic structural diagram of a data processing system provided by the embodiments of this application;
[0026] Figure 2 is a flowchart of a data processing method provided by the embodiments of this application;
[0027] Figure 3 is a flowchart of a data generation method provided by the embodiments of this application;
[0028] Figure 4 is a schematic flowchart of a method for generating a method dictionary and a DSL dictionary provided by the embodiments of this application;
[0029] Figure 5 is a flowchart of another data processing method provided by the embodiments of this application;
[0030] Figure 6 is a flowchart of a method for parsing target Fair DSL data provided by the embodiments of this application;
[0031] Figure 7It is a block diagram of a data processing device provided by an embodiment of the present application;
[0032] Figure 8 It is a block diagram of a data processing device provided by an embodiment of the present application;
[0033] Figure 9 It is a block diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0034] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0035] Please refer to Figure 1 , which shows a data processing system provided by an embodiment of the present application. As Figure 1 shown, the data processing system includes: a client 101 and a server 102. The client 101 and the server 102 are connected through a wired network or a wireless network. It should be noted that one or more clients may be included in this implementation environment. Figure 1 For example, it is described by taking the implementation environment including only one client as an example.
[0036] Among them, the server 102 can be used to generate target Fair DSL data of the interface to be generated. Send the generated target Fair DSL data to the client 101. Among them, the target Fair DSL data can be a structure description file corresponding to the interface to be generated. The client 101 can receive the target Fair DSL data sent by the server 102. Parse the target Fair DSL data to generate an interface, that is, display the generated interface on the client. Optionally, after receiving the target Fair DSL data sent by the server 102, the client 101 can store the target Fair DSL data of the interface to be generated. In response to an interface display instruction triggered by the user, obtain the stored target Fair DSL data, so as to display the interface. Or, the client 101 can generate an interface display request in response to a trigger display operation of the user for the page to be generated. Send the interface display request to the server to receive the target Fair DSL data corresponding to the interface to be generated sent by the server in response to the interface display request, so as to display the interface. Optionally, the client 101 can be installed on a terminal. The terminal can be a mobile phone, a tablet computer, a wearable device, etc. The server 102 can be a single server, or can also be a service cluster composed of multiple servers.
[0037] Please refer toFigure 2 , which shows a flowchart of a data processing method provided by an embodiment of the present application. The data processing method can be applied to Figure 1 the data processing system shown in Figure 1 and is executed by the server in the data processing system shown in Figure 2 . As shown in
[0038] Step 201, convert the Flutter source code data corresponding to the interface to be generated into initial Fair DSL data through Fair. The Flutter source code data includes: the first source code data and the second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated, and the second source code data is the Flutter source code data written with specific method functions, and the second source code data includes a call statement for the first source code data.
[0039] In the embodiment of the present application, the server uses Flutter and Fair to write the interface to be generated and compiles it using the Flutter compiler to obtain the initial Fair DSL data. Among them, the interface to be generated is a Flutter interface, that is, a UI interface constructed using Flutter. The data structure of the Flutter interface is a component (Widget) tree structure, that is, a tree-shaped data structure composed of multiple components. The basic construction element of the Flutter interface is a Widget, and each Widget can also include one or more Widgets. Through the wrapping of Widgets layer by layer, the Widget tree that constitutes the interface is obtained.
[0040] Among them, the interface can include multiple UI components. There is a type of Widget that can be used to encapsulate UI components. The component Fair DSL data corresponding to this type of Widget can be used to describe the structure of the UI component, so that after parsing the component Fair DSL data, the UI component can be drawn. Optionally, the target component (target Widget) can refer to an independent component used to encapsulate the UI component. The Flutter source code data corresponding to the independent component is not written with specific method functions.
[0041] In the embodiment of the present application, the server can use the Flutter compiler to convert the Flutter source code data corresponding to the interface to be generated into the initial Fair DSL data through Fair. Among them, in the process of converting the second source code data written with specific method functions, the first source code data is called through the call statement for the first source code data to convert the first source code data. The conversion of all the Flutter source code data corresponding to the interface to be generated into the initial Fair DSL data is realized.
[0042] Step 202: Extract the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data. The interface Fair DSL data includes: the target component identifier corresponding to the target component.
[0043] In an alternative implementation, as Figure 3 shown, the process by which the server extracts the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data may include:
[0044] Step 301: The server converts the initial Fair DSL data into abstract syntax tree data.
[0045] In the embodiments of the present application, the server may perform an abstract syntax tree (AST) analysis on the initial Fair DSL data to obtain the AST data corresponding to the initial Fair DSL data. The AST is an abstract representation of the syntactic structure of source code data (also known as source code). It represents the syntactic structure of a programming language in a tree-like form, and each node on the tree represents a structure in the source code data.
[0046] Step 302: The server extracts the component data corresponding to the target component under the component label node in the AST, and generates the component Fair DSL data corresponding to the target component identifier based on the component data.
[0047] In the embodiments of the present application, the component label node refers to the node used to indicate the corresponding structure of the Flutter source code data for describing the target component. The server may traverse each node in the AST data and filter out the component data corresponding to the target component under the component label node. In an alternative implementation, when the target component is an independent component for encapsulating a UI component, the component label node refers to the node used to indicate the structure of the independent Flutter source code data.
[0048] Optionally, when the object of the target component is a function, that is, the target component is a packaged function. The component identifier corresponding to the target component may be the function name (className). The component label node may include: a node of the function declaration (FunctionDeclaration) type, and / or a node of the method declaration (MethodDeclaration) type. For the sake of convenience of description, the function declaration node is used to indicate the node of the function declaration type. The method declaration node is used to indicate the node of the method declaration type. Then the component label node includes: a function declaration node and / or a method declaration node. It should be noted that when the component label node is of the method declaration type, the component identifier of the target component does not include the function name of a specific method function (the build method function).
[0049] The process for the server to extract the component data corresponding to the target component under the component label node in the AST may include: the server extracts the component data (function data, argument) corresponding to each function name under the function declaration node in the AST, and among each function under the method declaration node, except for the function name of the specific method function, the component data (function data) corresponding to each function name.
[0050] In the embodiments of the present application, the server converts the component data corresponding to the target component into component Fair DSL data using the component Fair DSL standard format. Optionally, the data format of the component Fair DSL data may be JSON. For example, the component Fair DSL standard format may be:
[0051] "{"className":"target component identifier",
[0052] "na":{component data}}"
[0053] Among them, if the component data indicates that the target component indicated by the target component identifier has sub-components (i.e., nested dynamic components), the component Fair DSL standard format may be:
[0054]
[0055] Step 303: The server extracts the target data other than the component data corresponding to the target component under each node in the AST, and generates the interface Fair DSL data based on the target data.
[0056] In the embodiments of the present application, the server can traverse each node in the AST data and filter out the target data except the component data corresponding to the target component under each node. The server converts the target data into interface Fair DSL data in the standard format of interface Fair DSL. Among them, the standard format of interface Fair DSL can be set according to actual business requirements.
[0057] For example, Figure 4 As shown, the server generates initial Fair DSL data and traverses each node in the AST data corresponding to the initial Fair DSL data. For any node, the server determines whether the node is a function declaration node. If the node is a function declaration node (FunctionDeclaration), the server extracts each function name and the component data corresponding to the function name under the function declaration node, and generates component Fair DSL data corresponding to each function name. If the node is not a function declaration node, the server determines whether the node is a method declaration node (MethodDeclaration). If the node is not a method declaration node, the server extracts the target data under the node and generates interface Fair DSL data. If the node is a method declaration node, for the component data under the method declaration node, the server determines whether the function name corresponding to the component data is the specific function name (build) of a specific method function, that is, determines whether the function corresponding to the component data is a specific method function. If the function name is not the specific function name, the server extracts the function name and the component data corresponding to the function name, and generates component Fair DSL data corresponding to the function name. If the function name is the specific function name, the server extracts the target data corresponding to the specific function name and generates interface Fair DSL data. The server writes each function name and the corresponding component Fair DSL data into a method dictionary (methodMap), and writes the interface Fair DSL data into a DSL dictionary (Map).
[0058] In another alternative implementation, the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function can be manually extracted from the initial Fair DSL data.
[0059] Step 203: Add the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate target Fair DSL data.
[0060] Optionally, there are multiple implementation manners for the server to add the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate target Fair DSL data. In the embodiments of the present application, three examples are used for illustration.
[0061] In a first alternative implementation, the process for the server to add the component Fair DSL data corresponding to the target component to the interface Fair DSL data may include: The server adds first mapping data to the interface Fair DSL data to obtain the target Fair DSL data. The first mapping data includes: the target component identifier and the component Fair DSL data stored in association with the target component.
[0062] Among them, the server may, based on the target component identifier, obtain the component Fair DSL data stored in association with the target component identifier from the stored component Fair DSL data of each component, and generate the first mapping data. Optionally, the data format of the first mapping data may be a dictionary format. The first mapping data may be referred to as a method dictionary (methodMap). The first mapping data includes a first key-value pair, where the key field of the first key-value pair is used to store the target component identifier, and the value field is used to store the corresponding component Fair DSL data.
[0063] In a second alternative implementation, the process for the server to add the component Fair DSL data corresponding to the target component to the interface Fair DSL data may include: generating second mapping data. The second mapping data includes: a method dictionary identifier and the first mapping data stored in association. Adding the second mapping data to the interface Fair DSL data to obtain the target Fair DSL data. Among them, the method dictionary identifier is used to indicate that the component Fair DSL data in the first mapping data supports being called.
[0064] Among them, the server may generate the second mapping data after generating the first mapping data. The generation process of the first mapping data may refer to the generation process of the first mapping data in the foregoing second alternative implementation. This is not elaborated again in the embodiments of the present application. Optionally, the data format of the second mapping data may be a dictionary format. The second mapping data includes a second key-value pair, where the key field of the second key-value pair is used to store the method dictionary identifier, and the value field is used to store the corresponding first mapping data.
[0065] In a third alternative implementation, the process for the server to add the component Fair DSL data corresponding to the target component to the interface Fair DSL data may include: The server directly adds the component Fair DSL data corresponding to the target component to the interface Fair DSL data to obtain the target Fair DSL data.
[0066] Among them, the server can extract the component Fair DSL data associated with the target component identifier from the stored Fair DSL data of each component based on the target component identifier. Thus, the component Fair DSL data is added to the interface Fair DSL data to obtain the target Fair DSL data. The target Fair DSL data is used to completely describe the structure corresponding to the interface to be generated. It should be noted that after the server adds the component Fair DSL data to the interface Fair DSL data, the target component identifier originally included in the interface Fair DSL data can be deleted. In this way, when parsing the target Fair DSL data subsequently, in the case where the target Fair DSL data includes the component Fair DSL data corresponding to the target component and the target component identifier, the duplicate parsing and generation of the component Fair DSL data are avoided. The accuracy of interface generation is guaranteed.
[0067] Step 204: Send the target Fair DSL data to the client so that the client parses the target Fair DSL data to generate an interface.
[0068] In the embodiment of the present application, the server can encapsulate the target Fair DSL data into a DSL dictionary (DSLMap) and send the DSL dictionary including the target Fair DSL data to the client at a set time. So that after receiving the DSL dictionary, the client parses the DSL dictionary to obtain the target Fair DSL data, parses the target Fair DSL data, and generates an interface. Among them, the set time can be the interface update time triggered by the developer. For example, for the interface of an application, the interface update time is the version update time of the application. The server can add the target Fair DSL data to the installation package corresponding to the application and send it to the client. Thus, when the client receives the trigger display operation of the user for the interface to be generated, the target Fair DSL data is obtained and parsed to generate an interface. Or, the set time can be the receiving time when the server receives the interface display request for the interface to be generated. That is to say, after receiving the interface display request for the interface to be generated sent by the client, the server can send the target Fair DSL data to the client.
[0069] In summary, the data processing method provided by the embodiments of this application converts the Flutter source code data corresponding to the interface to be generated into initial Fair domain-specific language (DSL) data through Fair. Component Fair DSL data corresponding to the target component and interface Fair DSL data corresponding to specific method functions are extracted from the initial Fair DSL data. The component Fair DSL data corresponding to the target component is added to the interface Fair DSL data to generate target Fair DSL data. Then, the target Fair DSL data is sent to the client so that the client can parse the target Fair DSL data to generate an interface. In this technical solution, the Flutter source code data includes: first source code data and second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated. The second source code data is the Flutter source code data written with specific method functions, and the second source code data includes a call statement for the first source code data. By calling the component Fair DSL data corresponding to the target component in the interface Fair DSL data, a complete interface can be generated through Fair based on the Flutter source code data corresponding to the independently encapsulated target component and the Flutter source code data of specific method functions. Compared with the prior art, it is not necessary to write all the Flutter source code data corresponding to all the interfaces to be generated, including each component of the interface, into a specific method function, which reduces the complexity of the code in the specific method function, improves the readability of the code in the specific method function, and reduces the maintenance cost.
[0070] Moreover, since it is not necessary to write all the code into the same specific method function. Therefore, the Flutter source code data corresponding to different components in the interface can be developed by different personnel. Finally, it can be achieved by calling through the interface Fair DSL data, realizing modular development of the code, which is more in line with the design ideas of developers, improves the interface design experience of developers, and improves the development efficiency.
[0071] Please refer to Figure 5 , which shows a flowchart of another data processing method provided by the embodiments of this application. The data processing method can be applied to Figure 1 the data processing system shown, and is executed by the client in the data processing system. As Figure 5 shown, the method includes:
[0072] Step 501, receive the target Fair DSL data of the interface to be generated sent by the server.
[0073] In the embodiments of the present application, the target Fair DSL data is generated by the server using the data processing method provided in the embodiments of the present application. The server can encapsulate the target Fair DSL data into a DSL dictionary (DSLMap) and send the DSL dictionary including the target Fair DSL data to the client at a set timing. So that after receiving the DSL dictionary, the client can parse the DSL dictionary to obtain the target Fair DSL data. Parse the target Fair DSL data to generate an interface. Among them, the set timing can be the interface update timing triggered by the developer. For example, for the interface of an application, the update timing of the interface is the version update timing of the application. The server can add the target Fair DSL data to the installation package corresponding to the application and send it to the client. Thus, when the client receives a trigger display operation from the user for the interface to be generated, it can obtain the target Fair DSL data and parse the target Fair DSL data to generate an interface. Or, the set timing can be the receiving timing when the server receives an interface display request for the interface to be generated. That is to say, after receiving the interface display request for the interface to be generated sent by the client, the server can send the target Fair DSL data to the client.
[0074] Step 502: Parse the target Fair DSL data to generate an interface.
[0075] In the embodiments of the present application, the client can respond to a trigger display operation from the user for the interface to be generated, and obtain the target Fair DSL data sent by the server received by the client. Parse the target Fair DSL data to generate an interface. Among them, different generation methods of the target Fair DSL data correspond to different methods of parsing the target Fair DSL data. The embodiments of the present application will respectively describe the methods of parsing the target Fair DSL data corresponding to the foregoing three implementation methods for generating the target Fair DSL data.
[0076] The first optional implementation method. As Figure 6 shown, the target Fair DSL data includes first mapping data. The process of the client parsing the target Fair DSL data to generate an interface may include:
[0077] Step 601: The client extracts the first mapping data from the target Fair DSL data, and deletes the first mapping data from the target Fair DSL data to obtain the interface Fair DSL data. The interface Fair DSL data includes: the target component identifier corresponding to the target component in the interface to be generated.
[0078] Optionally, when the first mapping data is added to the interface Fair DSL data, it can be added to a set position. For example, the first or the last position. Then the client can extract the first mapping data from the set position in the target Fair DSL data, and delete the first mapping data from the target Fair DSL data to obtain the interface Fair DSL data. This is to avoid repeated parsing of the target Fair DSL data corresponding to the target component.
[0079] Exemplarily, the client stores a loader (loader.dart), a decoder (decoder.dart), and a runner (builder.dart). The client receives a DSL dictionary sent by the server, which includes the target Fair DSL data. The loader can be driven to load the DSL dictionary. And the loaded DSL dictionary is transmitted to the decoder. The decoder extracts a method dictionary (the first mapping data) from the DSL dictionary and deletes the method dictionary from the DSL dictionary. The extracted method dictionary and the DSL field after deleting the method dictionary are transmitted to the runner. The runner decodes the DSL dictionary and recursively obtains the interface Fair DSL data line by line.
[0080] Step 602, the client parses the interface Fair DSL data.
[0081] In the embodiments of the present application, the interface Fair DSL data can be called line by line through the runtime mechanism of the Dart programming language of Flutter to parse the interface Fair DSL data.
[0082] Among them, the interface Fair DSL data includes the target component identifier of the target component. When the interface Fair DSL data is called line by line, it can be determined whether the call object exists in the first mapping data, that is, whether the call object is the target component identifier.
[0083] If so, it indicates that the interface Fair DSL data does not include the specific Fair DSL data required for the call. This specific Fair DSL data is the component Fair DSL data corresponding to the target component identifier in the first mapping data. If not, it indicates that the interface Fair DSL data includes the specific Fair DSL data required for the call. Continue to call the interface Fair DSL data line by line.
[0084] Optionally, when the object of the target component is a function, the client can determine whether the function name being called exists in the key fields of each key-value pair included in the first mapping data. If so, step 603 is executed; if not, the client continues to make a line-by-line call to the interface Fair DSL data. In an optional implementation, the client can use the Function.apply dynamic call method to make a line-by-line call to the interface Fair DSL data.
[0085] Step 603: When the component identifier obtained by parsing exists in the first mapping data, the client extracts the component Fair DSL data corresponding to the component identifier from the first mapping data and parses the component Fair DSL data corresponding to the component identifier.
[0086] In the embodiment of the present application, the client can make a line-by-line call to the target Fair DSL data corresponding to the target component extracted from the first mapping data.
[0087] Step 604: The client uses the Flutter engine to draw the interface based on the interface Fair DSL data and the parsing result of the component Fair DSL data corresponding to the component identifier existing in the first mapping data.
[0088] In the embodiment of the present application, the client uses the Flutter engine to draw the interface based on the interface Fair DSL data and the call result of the component Fair DSL data corresponding to the component identifier existing in the first mapping data. Thus, the parsing of the DSL dictionary including the method dictionary to the drawing is completed.
[0089] The second optional implementation. The target Fair DSL data includes the second mapping data. The process by which the client parses the target Fair DSL data to generate the interface is basically the same as the generation process in the first optional implementation. The difference is that in step 601, the process by which the client extracts the first mapping data from the target Fair DSL data includes: based on the method dictionary identifier in the second mapping data, extracting the corresponding first mapping data from the target Fair DSL data. In this way, by using the method of mapping the method dictionary identifier and the first mapping data to the target Fair DSL data, it is convenient for the client to extract the first mapping data from the target Fair DSL data based on the method dictionary identifier, improving the data extraction efficiency.
[0090] The third optional implementation, the client can directly parse the target Fair DSL data to generate the interface. Among them, the process of parsing the target Fair DSL data can refer to the foregoing step 602, and the embodiment of the present application will not elaborate on this.
[0091] In summary, the data processing method provided by the embodiments of the present application receives the target Fair DSL data of the interface to be generated sent by the server, parses the target Fair DSL data, and generates an interface. Among them, the server converts the Flutter source code data corresponding to the interface to be generated into initial Fair domain-specific language DSL data through Fair. The component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function are extracted from the initial Fair DSL data. And the component Fair DSL data corresponding to the target component is added to the interface Fair DSL data to generate the target Fair DSL data. In this technical solution, the Flutter source code data includes: the first source code data and the second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated. The second source code data is the Flutter source code data written with the specific method function, and the second source code data includes a call statement for the first source code data. By calling the component Fair DSL data corresponding to the target component in the interface Fair DSL data, a complete interface can be generated through Fair based on the Flutter source code data corresponding to the independently encapsulated target component and the Flutter source code data of the specific method function. Compared with the prior art, it is not necessary to write all the Flutter source code data corresponding to all the interfaces to be generated, including each component of the interface, into the specific method function, which reduces the complexity of the code in the specific method function, improves the readability of the code in the specific method function, and reduces the maintenance cost.
[0092] Another data processing method provided by the embodiments of the present application can be applied to Figure 1 the data processing system shown in the figure. The method includes:
[0093] Step 701, the server converts the Flutter source code data corresponding to the interface to be generated into initial Fair domain-specific language DSL data through Fair. The Flutter source code data includes: the first source code data and the second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated. The second source code data is the Flutter source code data written with the specific method function, and the second source code data includes a call statement for the first source code data.
[0094] Step 702, the server extracts the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data. The interface Fair DSL data includes: the target component identifier corresponding to the target component.
[0095] Step 703: The server adds the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate the target Fair DSL data.
[0096] Step 704: The server sends the target Fair DSL data to the client.
[0097] The explanations and implementation manners of Steps 701 to 704 can refer to the explanations and implementation manners in the foregoing Steps 201 to 204 in sequence, and the embodiments of the present invention will not elaborate thereon.
[0098] Step 705: The client parses the target Fair DSL data to generate an interface.
[0099] The explanation and implementation manner of Step 705 can refer to the explanation and implementation manner in the foregoing Step 502, and the embodiments of the present invention will not elaborate thereon.
[0100] In summary, the data processing method provided by the embodiments of the present application converts the Flutter source code data corresponding to the interface to be generated into the initial Fair domain-specific language DSL data through Fair. The component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function are extracted from the initial Fair DSL data. And the component Fair DSL data corresponding to the target component is added to the interface Fair DSL data to generate the target Fair DSL data. Then the target Fair DSL data is sent to the client so that the client parses the target Fair DSL data to generate an interface. In this technical solution, the Flutter source code data includes: the first source code data and the second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated. The second source code data is the Flutter source code data written with the specific method function, and the second source code data includes a call statement for the first source code data. By calling the component Fair DSL data corresponding to the target component in the interface Fair DSL data, it is possible to generate a complete interface through Fair based on the Flutter source code data corresponding to the independently encapsulated target component and the Flutter source code data of the specific method function. Compared with the technology, it is not necessary to write all the Flutter source code data corresponding to all the interfaces to be generated including each component of the interface into the specific method function, which reduces the complexity of the code in the specific method function, improves the readability of the code in the specific method function, and reduces the maintenance cost.
[0101] Moreover, since it is not necessary to write all the code into the same specific method function, the Flutter source code data corresponding to different components in the interface can be developed by different personnel. Finally, it can be achieved by calling the Fair DSL data in the interface, realizing modular development of the code, which is more in line with the design ideas of developers, improving the interface design experience of developers and the development efficiency.
[0102] Please refer to Figure 7 , which shows a block diagram of a data processing device provided in an embodiment of the present application. As Figure 7 shown, the data processing device 800 includes: a generation module 801, an extraction module 802, an addition module 803, and a sending module 804.
[0103] The generation module 801 is configured to convert the Flutter source code data corresponding to the interface to be generated into initial Fair domain-specific language DSL data through Fair. The Flutter source code data includes: first source code data and second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated, and the second source code data is the Flutter source code data written into the specific method function. The second source code data includes a call statement for the first source code data;
[0104] The extraction module 802 is configured to extract the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data. The interface Fair DSL data includes: the target component identifier corresponding to the target component;
[0105] The addition module 803 is configured to add the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate target Fair DSL data;
[0106] The sending module 804 is configured to send the target Fair DSL data to the client so that the client parses the target Fair DSL data to generate an interface.
[0107] Optionally, the addition module 803 is further configured to:
[0108] Add first mapping data to the interface Fair DSL data to obtain target Fair DSL data. The first mapping data includes: the target component identifier and the component Fair DSL data associated with and stored for the target component.
[0109] Optionally, the addition module 803 is further configured to:
[0110] Generate second mapping data, where the second mapping data includes: a method dictionary identifier and the first mapping data stored in association, and the method dictionary identifier is used to indicate that the Fair DSL data in the first mapping data supports being called;
[0111] Add the second mapping data to the interface Fair DSL data to obtain target Fair DSL data.
[0112] Optionally, the data format of the first mapping data and / or the second mapping data is a dictionary format.
[0113] Optionally, the extraction module 802 is further configured to:
[0114] Convert the initial Fair DSL data into abstract syntax tree (AST) data;
[0115] Extract the component data corresponding to the target component under the component label node in the AST, and generate component Fair DSL data corresponding to the target component identifier based on the component data;
[0116] Extract the target data other than the component data corresponding to the target component under each node in the AST, and generate interface Fair DSL data based on the target data.
[0117] Optionally, the object of the target component is a function, and the component identifier of the target component is the function name; the types of the component label nodes include: function declaration and / or device declaration; wherein, when the component label node is of the device declaration type, the component identifier of the target component does not include the function name of a specific device function.
[0118] In summary, the data processing device provided by the embodiments of the present application converts the Flutter source code data corresponding to the interface to be generated into initial Fair domain-specific language (DSL) data through Fair. Extract the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data. And add the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate the target Fair DSL data. Then send the target Fair DSL data to the client so that the client can parse the target Fair DSL data to generate the interface. In this technical solution, the Flutter source code data includes: the first source code data and the second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated. The second source code data is the Flutter source code data written with the specific method function, and the second source code data includes a call statement for the first source code data. By calling the component Fair DSL data corresponding to the target component in the interface Fair DSL data, it is possible to generate a complete interface through Fair based on the Flutter source code data corresponding to the independently encapsulated target component and the Flutter source code data of the specific method function. Compared with the prior art, it is not necessary to write all the Flutter source code data corresponding to all the interfaces to be generated including each component of the interface into the specific method function, which reduces the complexity of the code in the specific method function, improves the readability of the code in the specific method function, and reduces the maintenance cost.
[0119] Please refer to Figure 8 , which shows a block diagram of a data processing device provided by the embodiments of the present application. As Figure 8 shown, the data processing device 900 includes: a receiving module 901 and an analysis module 902.
[0120] The receiving module 901 is configured to receive the target Fair DSL data of the interface to be generated sent by the server, and the target Fair DSL data is generated by the server using any data processing method provided by the embodiments of the present application;
[0121] The analysis module 902 is configured to analyze the target Fair DSL data to generate an interface.
[0122] Optionally, the analysis module 902 is further configured to:
[0123] Extract the first mapping data from the target Fair DSL data, and delete the first mapping data from the target Fair DSL data to obtain the interface Fair DSL data. The interface Fair DSL data includes: the target component identifier corresponding to the target component in the interface to be generated;
[0124] Parse the interface Fair DSL data;
[0125] When the component identifier obtained by parsing exists in the first mapping data, extract the component Fair DSL data corresponding to the component identifier from the first mapping data, and parse the component Fair DSL data corresponding to the component identifier;
[0126] Adopt the Flutter engine, and draw the interface based on the parsing results of the interface Fair DSL data and the component Fair DSL data corresponding to the component identifier.
[0127] Optionally, the parsing module 902 is further configured to: extract the corresponding first mapping data from the target Fair DSL data based on the method dictionary identifier in the second mapping relationship.
[0128] In summary, the data processing device provided by the embodiment of the present application receives the target Fair DSL data of the interface to be generated sent by the server, parses the target Fair DSL data to generate an interface. Among them, the server converts the Flutter source code data corresponding to the interface to be generated into the initial Fair domain-specific language DSL data through Fair. Extract the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data. And add the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate the target Fair DSL data. In this technical solution, the Flutter source code data includes: the first source code data and the second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated. The second source code data is the Flutter source code data written with a specific method function, and the second source code data includes a call statement to the first source code data. By calling the component Fair DSL data corresponding to the target component in the interface Fair DSL data, it is possible to generate a complete interface through Fair based on the independently encapsulated Flutter source code data corresponding to the target component and the Flutter source code data of the specific method function. Compared with the technology, it is not necessary to write all the Flutter source code data corresponding to all the interfaces to be generated including each component of the interface into the specific method function, which reduces the complexity of the code in the specific method function, improves the readability of the code in the specific method function, and reduces the maintenance cost.
[0129] The data processing device provided by the embodiment of the present application has a functional module corresponding to executing the data processing method, can execute any data processing method provided by the embodiment of the present application, and can achieve the same beneficial effects.
[0130] In yet another embodiment provided by the present application, an electronic device is further provided. The electronic device may include: a processor, a memory, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements each process of the above-mentioned data processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.
[0131] Exemplarily, as Figure 9 shown, the electronic device may specifically include: a processor 1001, a storage device 1002, a display screen 1003 with a touch function, an input device 1004, an output device 1005, and a communication device 1006. The number of processors 1001 in the electronic device may be one or more, Figure 9 and one processor 1001 is taken as an example here. The processor 1001, storage device 1002, display screen 1003, input device 1004, output device 1005, and communication device 1006 of the electronic device may be connected through a bus or other means.
[0132] In yet another embodiment provided by the present application, a computer-readable storage medium is further provided. Instructions are stored in the computer-readable storage medium. When it runs on a computer, it causes the computer to execute any one of the data processing methods in the above embodiments.
[0133] In yet another embodiment provided by the present application, a computer program product containing instructions is further provided. When it runs on a computer, it causes the computer to execute any one of the data processing methods in the above embodiments.
[0134] It should be noted that in this article, 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 also includes 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 another identical element in the process, method, article or device including the element.
[0135] It should be noted that in this text, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, article or device comprising such element.
[0136] From the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to enable a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in various embodiments of the present invention.
[0137] The embodiments of the present invention have been described above in conjunction with the accompanying drawings. However, the present invention is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present invention, those of ordinary skill in the art can also make many forms without departing from the spirit and scope protected by the present invention and the claims, and all of them belong to the protection scope of the present invention.
[0138] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in connection with the embodiments disclosed in the embodiments of the present invention can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians 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 the present invention.
[0139] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be repeated here.
[0140] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections between each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.
[0141] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0142] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.
[0143] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or this part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical discs that can store program codes.
[0144] The above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A data processing method, characterized in that, The method includes: Converting the Flutter source code data corresponding to the interface to be generated into initial Fair domain-specific language (DSL) data through Fair. The Flutter source code data includes: first source code data and second source code data. The first source code data is the Flutter source code data corresponding to the target component in the interface to be generated, and the second source code data is the Flutter source code data written with a specific method function. The second source code data includes a call statement for the first source code data; Extracting the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data. The interface Fair DSL data includes: the target component identifier corresponding to the target component; Adding the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate target Fair DSL data; Sending the target Fair DSL data to the client so that the client parses the target Fair DSL data to generate an interface; Wherein, the specific method function is the build method function.
2. The method according to claim 1, wherein The adding the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate target Fair DSL data includes: Adding first mapping data to the interface Fair DSL data to obtain target Fair DSL data. The first mapping data includes: the target component identifier and the component Fair DSL data stored in association corresponding to the target component.
3. The method according to claim 2, characterized in that, The adding first mapping data to the interface Fair DSL data to obtain target Fair DSL data includes: Generating second mapping data. The second mapping data includes: a method dictionary identifier and the first mapping data stored in association. The method dictionary identifier is used to indicate that the component Fair DSL data in the first mapping data supports calls; Adding the second mapping data to the interface Fair DSL data to obtain target Fair DSL data.
4. The method according to claim 3, characterized in that, The data format of the first mapping data and / or the second mapping data is a dictionary format.
5. The method according to claim 1, wherein The extracting the component Fair DSL data corresponding to the target component and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data includes: Converting the initial Fair DSL data into abstract syntax tree (AST) data; Extracting the component data corresponding to the target component under the component label node in the AST, and generating the component Fair DSL data corresponding to the target component identifier based on the component data; Extracting the target data other than the component data corresponding to the target component under each node in the AST, and generating the interface Fair DSL data based on the target data.
6. The method according to claim 5, characterized in that, The object of the target component is a function, and the component identifier of the target component is the function name; the types of the component label nodes include: function declarations and / or method declarations; wherein, when the component label node is of the method declaration type, the component identifier of the target component does not include the function name of the specific method function.
7. A data processing method, characterized in that, The method includes: Receiving target Fair DSL data of an interface to be generated sent by a server, where the target Fair DSL data is generated by the server using the data processing method according to any one of claims 1 to 6; Parsing the target Fair DSL data to generate an interface.
8. The method according to claim 7, characterized in that, The target Fair DSL data includes first mapping data, and parsing the target Fair DSL data to generate an interface includes: Extracting the first mapping data from the target Fair DSL data, and deleting the first mapping data from the target Fair DSL data to obtain interface Fair DSL data, where the interface Fair DSL data includes: the target component identifier corresponding to the target component; Parsing the interface Fair DSL data; When the parsed component identifier exists in the first mapping data, extracting the component Fair DSL data corresponding to the component identifier from the first mapping data, and parsing the component Fair DSL data corresponding to the component identifier; Using a Flutter engine, based on the interface Fair DSL data and the parsing result of the component Fair DSL data corresponding to the component identifier, to draw an interface.
9. The method according to claim 8, characterized in that, The target Fair DSL data includes second mapping data, and extracting the first mapping data from the target Fair DSL data includes: Based on the method dictionary identifier in the second mapping data, extracting the corresponding first mapping data from the target Fair DSL data.
10. A data processing device, characterized in that, The device includes: A generation module, configured to convert Flutter source code data corresponding to an interface to be generated into initial Fair domain-specific language DSL data through Fair, where the Flutter source code data includes: first source code data and second source code data, the first source code data is the Flutter source code data corresponding to the target component in the interface to be generated, the second source code data is the Flutter source code data written with a specific method function, and the second source code data includes a call statement for the first source code data; An extraction module, configured to extract the component Fair DSL data corresponding to the target component, and the interface Fair DSL data corresponding to the specific method function from the initial Fair DSL data, where the interface Fair DSL data includes: the target component identifier corresponding to the target component; An addition module, configured to add the component Fair DSL data corresponding to the target component to the interface Fair DSL data to generate target Fair DSL data; A sending module, configured to send the target Fair DSL data to a client, so that the client parses the target Fair DSL data to generate an interface; Wherein, the specific method function is the build method function.
11. A data processing device, characterized in that, The device includes: A receiving module, configured to receive the target Fair DSL data to be used for generating an interface sent by a server, where the target Fair DSL data is generated by the server using the data processing method according to any one of claims 1 to 6; A parsing module, configured to parse the target Fair DSL data to generate an interface.
12. An electronic device, characterized in that, It includes: A processor, a memory, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps of the data processing method according to any one of claims 1 to 6, or implements the data processing method according to any one of claims 7 to 9.
13. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, it implements the steps of the data processing method according to any one of claims 1 to 6, or implements the data processing method according to any one of claims 7 to 9.
14. A data processing system, characterized in that, The system includes: a server and a client. The server communicates with the client. The server is configured to implement the steps of the data processing method according to any one of claims 1 to 6, and the client is configured to implement the steps of the data processing method according to any one of claims 7 to 9.
Citation Information
Patent Citations
User interface file generation method and device
CN112612470A
Dynamic updating method and device of Flutter component, electronic equipment and storage medium
CN112667263A