Custom component processing method and device, electronic equipment and readable storage medium
By scanning the code files of the target software project and building a custom component library, the problem of developers being unable to quickly become familiar with and use custom components is solved, thus improving development efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-25
- Publication Date
- 2026-03-10
AI Technical Summary
In existing technologies, developers cannot quickly become familiar with and use custom components, resulting in low development efficiency.
By performing an initial scan of the target code files in the target software project, information on custom components is obtained, a custom component library is built, and template and attribute information are updated to assist developers in code editing.
It improves developers' familiarity with and efficiency in using custom components, and enhances code editing capabilities.
Smart Images

Figure CN121636026A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of front-end software, and in particular to a processing method and device of a custom component, an electronic device, and a readable storage medium. BACKGROUND
[0002] A web front-end webpage can provide an interactive interface to a user, which usually includes many controls for the user to operate. For example, a "submit" control is clicked to submit a form. Each control corresponds to a component in the front-end software code to provide display, operation response, and the like of the control.
[0003] In the prior art, in the process of developing front-end software, when a developer inputs part of a character of a name of an open source component, a software development tool can find at least one open source component name matching the part of the character, so that the user selects an open source component name as a currently used component.
[0004] However, the above scheme cannot assist the developer to quickly familiarize and use the custom component, and the development efficiency is low. SUMMARY
[0005] Embodiments of the present application aim to provide a processing method and device of a custom component, an electronic device, and a readable storage medium to assist a developer to quickly familiarize and use the custom component and improve the development efficiency. The specific technical solutions are as follows. In a first aspect of the embodiments of the present application, a processing method of a custom component is provided first, and the method comprises: performing a first scan on a target code file in a target software project to obtain first information of a target custom component, and recording the first information of the target custom component, the target code file including a file where the custom component is located, the target custom component including a custom component that is used and not introduced by installation dependency, and the first information including an introduction path, a usage method, and a relative path of the target code file where the target custom component is located; performing a second scan on the target code file in the target software project based on the first information of the target custom component, and when each target code file is scanned, updating a usage template of the target custom component in a custom component library according to a usage method of the target custom component in the target code file, and obtaining a scan identifier of the target custom component; when the scan identifier corresponding to the target custom component indicates that the target custom component has not been scanned, updating attribute information of the target custom component to the custom component library; and performing code assisted editing on the target software project based on the custom component library.
[0006] Optionally, the usage template of the target custom component in the custom component library is updated according to a usage method of the target custom component in the target code file, comprising: The usage method and at least one of the usage templates are matched to obtain at least one matching degree; when the matching degree is greater than or equal to a preset matching degree threshold, the usage times of the usage template are updated; when each of the matching degrees is less than the preset matching degree threshold, a usage template is created in the custom component library according to the usage method, and the usage times of the usage template are initialized.
[0007] Optionally, the method further comprises: A first code context of the target custom component in the target code file is obtained; and a usage context of the usage template is updated according to the first code context.
[0008] Optionally, the code auxiliary editing of the target software project based on the custom component library comprises: When an input component identifier is received in the target software project, input component information is obtained from the custom component library according to the input component identifier, and the input component information is displayed; when a confirmation operation on the input component information is received, an identifier of a target custom component included in the input component information is input into the target software project; and when a confirmation operation on a usage template included in the input component information is received, the usage template is input into the target software project.
[0009] Optionally, the input component information is displayed, comprising: A second code context corresponding to the input component identifier is obtained; the second code context and a usage context of a usage template of the target custom component in the custom component library are matched to obtain a context matching degree; and the usage template in the input component information is displayed according to the context matching degree and the usage times.
[0010] Optionally, the method further comprises: A target code file that has changed in the target software project is obtained; when the target code file that has changed is a newly added file, the step of obtaining the first information of the target custom component by performing the first scan on the target code file in the target software project is returned; and when the target code file that has changed is not a newly added file, change content is obtained from the target code file, and the custom component library is updated according to change usage methods and change attribute information of custom components included in the change content.
[0011] In a second aspect of the application, a processing device of a custom component is provided, comprising: The first scanning module is configured to perform a first scan on a target code file in a target software project to obtain first information of a target custom component, and record the first information of the target custom component, the target code file including a file in which the custom component is located, the target custom component including a custom component that is used and not installed and introduced by dependency, and the first information including an introduction path, a usage method, and a relative path of the target code file.
[0012] The second scanning module is configured to perform a second scan on the target code file in the target software project based on the first information of the target custom component, and update a usage template of the target custom component in the custom component library according to a usage method of the target custom component in the target code file, and obtain a scan identifier of the target custom component each time the target code file is scanned.
[0013] The attribute updating module is configured to update attribute information of the target custom component to the custom component library when the scan identifier corresponding to the target custom component indicates that the target custom component has not been scanned.
[0014] The auxiliary module is configured to perform code auxiliary editing on the target software project based on the custom component library.
[0015] Optionally, the second scanning module is further configured to: match the usage method with at least one usage template to obtain at least one matching degree, update a usage frequency of the usage template when the matching degree is greater than or equal to a preset matching degree threshold, and create a usage template in the custom component library according to the usage method and initialize a usage frequency of the usage template when each matching degree is less than the preset matching degree threshold.
[0016] Optionally, the second scanning module is further configured to: obtain a first code context of the target custom component in the target code file, and update a usage context of the usage template according to the first code context.
[0017] Optionally, the auxiliary module is further configured to: receive an input component identifier in the target software project, obtain input component information from the custom component library according to the input component identifier, and display the input component information, input an identifier of a target custom component included in the input component information into the target software project when a confirmation operation on the input component information is received, and input a usage template included in the input component information into the target software project when a confirmation operation on the usage template is received.
[0018] Optionally, the auxiliary module is further configured to: obtain a second code context corresponding to the input component identifier; match the second code context and a usage context of the usage template of the target custom component in the custom component library to obtain a context matching degree; and display the usage template in the input component information according to the context matching degree and the usage times.
[0019] Optionally, the apparatus further includes an incremental update module configured to: obtain a target code file that has changed in the target software project; return the first scanning module when the target code file that has changed is a newly added file; obtain change content from the target code file that has changed when the target code file that has changed is not a newly added file; and update the custom component library according to a changed usage method and changed attribute information of a custom component included in the change content.
[0020] In a third aspect of the embodiments of the present application, an electronic device is further provided, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus; the memory is used to store a computer program; and the processor is used to execute the program stored in the memory to implement the method in the first aspect.
[0021] In a fourth aspect of the embodiments of the present application, a computer readable storage medium is further provided, which stores instructions, and when the instructions are run on a computer, the computer executes the method in the first aspect.
[0022] In a fifth aspect of the embodiments of the present application, a computer program product including instructions is further provided, and when the instructions are run on a computer, the computer executes the method in the first aspect.
[0023] The processing method and device of the custom component, the electronic device and the readable storage medium provided by the embodiments of the present application perform first scanning on a target code file in a target software project to obtain first information of a target custom component, and record the first information of the target custom component, the target code file including a file in which the custom component is located, the target custom component including a custom component that is used and not installed and dependency introduced, and the first information including an introduction path, a usage method and a relative path of the target code file in which the target custom component is located; second scanning is performed on the target code file in the target software project based on the first information of the target custom component, and when each target code file is scanned, a usage template of the target custom component in a custom component library is updated according to a usage method of the target custom component in the target code file, and a scanning identifier of the target custom component in the target code file is obtained; when the scanning identifier corresponding to the target custom component indicates that the target custom component has not been scanned, attribute information of the target custom component is updated to the custom component library; and code auxiliary editing is performed on the target software project based on the custom component library. In this way, the custom component library is constructed and can assist code editing, so that the developer can quickly familiarize and use the custom component, and the development efficiency is improved. BRIEF DESCRIPTION OF DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced.
[0025] Figure 1 A schematic diagram of a relationship between front-end software and components according to an embodiment of the present application; Figure 2 A flowchart of steps of a processing method of a custom component according to an embodiment of the present application; Figure 3 A schematic diagram of a tree-shaped storage structure of first information according to an embodiment of the present application; Figure 4 A flowchart of a processing method of a custom component according to another embodiment of the present application; Figure 5 A schematic diagram of a structure of a processing device of a custom component according to an embodiment of the present application; Figure 6 A schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0027] This application's embodiments are applied to front-end software development scenarios. Components used in front-end software development can originate from open-source component libraries. However, the open-source components provided by these libraries cannot meet personalized needs; custom components can fulfill these needs. (Refer to...) Figure 1 As shown, the components used in front-end software include two types: open-source components and custom components. Open-source components are public components provided by open-source component libraries and can be used by the public, while custom components are components developed and used internally. Custom components are usually customized according to the needs of software projects to meet specific UI (User Interface) designs and functions. They are usually encapsulated from multiple basic components and have personalized attribute information and usage methods.
[0028] However, these custom components introduce some problems to the development process. Developers need to be familiar with the usage and properties of each custom component in order to accurately select the appropriate one during development. This prevents developers from quickly becoming familiar with and using custom components, resulting in lower development efficiency.
[0029] To address the aforementioned technical issues, embodiments of this application can scan target software projects to build a custom component library, which stores the attributes and usage templates of custom components. During front-end software development, this library can assist developers in code editing, enabling them to quickly become familiar with and use custom components, thereby improving development efficiency.
[0030] The processing method of the custom components in this application will be described in detail below through specific embodiments.
[0031] Figure 2 A flowchart illustrating the steps of a custom component processing method provided in this application embodiment is shown below. Figure 2 As shown, the method may include: S101. Perform a first scan on the target code files in the target software project to obtain the first information of the target custom components, and record the first information of the target custom components. The target code files include the files where the custom components are located. The target custom components include custom components that are used and are not imported as installation dependencies. The first information includes: import path, usage method and relative path of the target code file.
[0032] S102. Based on the first information of the target custom component, perform a second scan of the target code files in the target software project. When scanning a target code file, update the usage template of the target custom component in the custom component library according to the usage method of the target custom component in the target code file, and obtain the scan identifier of the target custom component.
[0033] S103. When the scan identifier corresponding to the target custom component indicates that it has not been scanned, update the attribute information of the target custom component to the custom component library.
[0034] S104. Assist code editing for the target software project based on a custom component library.
[0035] The target software project is a software system under development or maintenance that provides a set of service functions. A software project may include at least one code file, with the custom component residing in the target code file. Target code files can be identified by their file extensions; for example, in the Vue framework (a JavaScript framework), files with the ".vue" extension are target code files. Therefore, this application only needs to scan the target code files when building the custom component library, avoiding the scanning of irrelevant files, thus improving scanning efficiency and consequently improving the construction efficiency of the custom component library.
[0036] Furthermore, in this embodiment, only the initial information of the target custom component needs to be recorded during the first scan, rather than the initial information of all custom components. The target custom component is a custom component that is used and not imported as an installation dependency. In this way, the custom components in the custom component library are those that will be used in the project, reducing the number of custom components in the custom component library. This not only saves storage space but also improves the retrieval efficiency of the custom component library and enhances the efficiency of code editing assistance.
[0037] During the initial scan, whether a custom component is used is determined by the component registration information and the runtime logic information in the target code file. Specifically, if a custom component exists in the component registration information but not in the runtime logic information, then the custom component is not used in the target code file; if a custom component exists in both the component registration information and the runtime logic information, then the custom component is used in the target code file.
[0038] Whether a custom component is included as a dependency is determined by the dependency package. The dependency package stores the custom components that the software project depends on during installation. These custom components are not entered through code editing, so no code-assisted editing is required. If the custom component exists in the dependency package, it is included as a dependency; if it does not exist, it is not included as a dependency.
[0039] This application embodiment performs a coarse scan in the first scan to obtain initial information about the target custom component, preparing for the second scan. This effectively reduces the number of target custom components corresponding to the second scan, i.e., the fine scan, thus improving the efficiency of the second scan.
[0040] The aforementioned first piece of information can be stored in a tree structure. The first-level nodes store the relative paths of the target code files. The child nodes of the first-level nodes (i.e., the second-level nodes) store the component identifiers within the target code files. The child nodes of the second-level nodes (i.e., the third-level nodes) store the import paths and usage methods of custom components. This allows for the repeated storage of the relative paths of the target code files, saving storage space and facilitating subsequent second scans, enabling scanning on a per-target-file basis.
[0041] Figure 3 This is a schematic diagram of a tree-like storage structure for first information provided in an embodiment of this application.
[0042] Reference Figure 3 As shown, two first-level nodes are provided as an example, each corresponding to a target code file, which respectively store the relative paths of target code file F1 and target code file F2.
[0043] Reference Figure 3 As shown, an example is provided with five second-level nodes, each corresponding to a target custom component. Specifically, the two second-level nodes of the first-level node corresponding to target code file F1 store the component identifiers P1 and P2 of the target custom component in target code file F1, respectively. Similarly, the three second-level nodes of the first-level node corresponding to target code file F2 store the component identifiers P3, P4, and P5 of the target custom component in target code file F2, respectively.
[0044] Reference Figure 3As shown, an example is provided with 10 third-level nodes, each corresponding to an import path or an import method. Specifically, the two third-level nodes of the second-level node corresponding to the target custom component P1 store the import path and import method of target custom component P1, respectively; the two third-level nodes of the second-level node corresponding to the target custom component P2 store the import path and import method of target custom component P2, respectively; the two third-level nodes of the second-level node corresponding to the target custom component P3 store the import path and import method of target custom component P3, respectively; the two third-level nodes of the second-level node corresponding to the target custom component P4 store the import path and import method of target custom component P4, respectively; and the two third-level nodes of the second-level node corresponding to the target custom component P5 store the import path and import method of target custom component P5.
[0045] It should be noted that the relative path of the target code file mentioned above can be the path of the target code file relative to the reference directory. This reference directory can be the common parent directory of all target code files. Therefore, the relative path starts from the reference directory. For example, if the reference directory is root\J1\J2, and the absolute path of the target code file is root\J1\J2\J3\J4, then the relative path of the target code file is J3\J4.
[0046] The aforementioned import path is the path of the target custom component relative to the target code file. Therefore, during the second scan, the location of the target custom component can be determined based on the relative path of the target code file and the import path of the target custom component. This allows for quick location of the corresponding custom component within the target software project based on the recorded target custom component information.
[0047] When a target custom component matches a custom component in one of the target code files, the usage template and usage method of that target custom component in the custom component library can be updated based on the information of the target custom component in that target code file. Specifically, this needs to be divided into two scenarios based on the scanning identifier.
[0048] In the first scenario, the scanning identifier corresponding to the target custom component indicates that the target custom component has not been scanned and has not been added to the custom component library. Therefore, the custom component library does not contain a record of the target custom component, including but not limited to: usage templates and attribute information. In this case, it is necessary not only to generate usage templates based on the usage methods of the target custom component in the target code file to add to the custom component library, but also to update its attribute information in the custom component library based on the attribute information of the target custom component in the target code file. Attribute information may include, but is not limited to: attribute passing parameters and the initial default value of each parameter, functions exposed by the component and the meaning of the functions, function usage methods and corresponding parameters, and whether the target custom component has slots.
[0049] In the second scenario, the scan identifier corresponding to the target custom component indicates that the target custom component has been scanned and has been added to the custom component library. Since the attribute information of the target custom component is fixed, it does not need to be updated. However, the usage of the same target custom component may differ in different scenarios; therefore, the usage template for the target custom component may need to be updated.
[0050] Specifically, the usage template of the target custom component is updated based on its usage method in the target code file. This includes matching the usage method of the target custom component in the target code file with its usage template in the custom component library. If the match is successful, it means that the usage template corresponding to the usage method has already been stored in the custom component library and does not need to be stored again. If the match is unsuccessful, it means that the usage template corresponding to the usage method has not been stored in the custom component library and a usage template needs to be generated based on the usage method to be stored in the custom component library.
[0051] It should be noted that a target custom component can be represented by its identifier, which may include the file path defining the target custom component and the name of the target custom component. The usage of the same target custom component may differ or be the same in different target code files, and one or more usage methods may be identical or different. Identical usage methods correspond to a usage template, while different usage methods correspond to different usage methods. Therefore, the same target custom component can correspond to one or more usage templates. A usage template is a unified usage specification for these one or more usage methods, including the same text content for one or more usage methods.
[0052] Each of the aforementioned target custom components has a corresponding scan identifier, which is initially set to unscanned. After the first update of the target custom component's attribute information and template based on the target custom component in the target code file, the scan identifier of the target custom component is updated to scanned to indicate that its attribute information will no longer be updated.
[0053] The matching degree between the usage method and the usage template can be achieved through text matching, and can be represented as the ratio of the number of identical text contents in both to the number of text contents in the usage method. When the matching degree between the usage method and the usage template is greater than or equal to a preset matching degree threshold, it means that the two correspond; otherwise, it means that the two do not correspond.
[0054] When generating a usage template based on a usage method, dynamic text content related to the current usage scenario can be filtered out from the usage method to obtain the usage template corresponding to that usage method. Similarly, dynamic text content in the property information of the target custom component in the target code file can be filtered out, which means storing the static content in the property information in the custom component library.
[0055] In the custom component library, the relevant information of the target custom component can be stored using the identifier of the target custom component as an index, including but not limited to the template and attribute information mentioned above.
[0056] In some possible implementations, the usage template of the target custom component in the custom component library is updated based on how the target custom component is used in the target code file, including: Match the usage method with at least one usage template to obtain at least one matching degree; when the matching degree is greater than or equal to the preset matching degree threshold, update the usage count of the usage template; when all matching degrees are less than the preset matching degree threshold, create a usage template in the custom component library according to the usage method and initialize the usage count of the usage template.
[0057] The usage count of the target custom component's template is initialized to 1. Specifically, when the matching degree between all the target custom component's templates and the target custom component's usage method in the target code file is less than a preset matching degree threshold, it means that the target custom component's usage method in the target code file is a new usage method, and at this time, a new usage template needs to be added based on this usage method.
[0058] When the matching degree between the usage method of the target custom component in a target code file and the usage template of the target custom component is greater than or equal to the preset matching degree threshold, it means that the usage method of the target custom component corresponds to the usage template of the target custom component. Therefore, it is not necessary to add a new usage template for the target custom component, but to increment the usage count of the usage template of the target custom component by 1.
[0059] This application embodiment can record the number of times a template for a target custom component is used, thereby indicating the usage of the template and providing a reference for developers so that they can prioritize the most frequently used template.
[0060] In some examples, for each template, the first matching usage method can be stored as an example in a custom component library. This better assists users in editing code by referring to the usage method, helping to improve code development efficiency.
[0061] In some possible implementations, the method further includes: obtaining the first code context of the target custom component in the target code file; and updating the usage context of the template based on the first code context.
[0062] The first code context is the text content preceding and following the use of the target custom component. Key information can be extracted from this text to determine the usage scenario of the target custom component. Later, during code editing, the usage context can prompt developers about the appropriate use case for the template, allowing them to select the correct template based on the current second code context. This further assists developers in quickly finding suitable templates and improves development efficiency.
[0063] The aforementioned custom component library can be built using the process described above. This build process can be executed periodically or incrementally updated upon receiving code commit or pull operations for the target software project. The update process includes: Retrieve the target code files that have been modified in the target software project; if the modified target code file is a newly added file, return to the step of performing the first scan of the target code files in the target software project to obtain the first information of the target custom component; if the modified target code file is not a newly added file, retrieve the modified content from the target code file, and update the custom component library according to the modified usage method and modified attribute information of the custom component included in the modified content.
[0064] As can be seen, the embodiments of this application perform incremental updates to the custom component library, which can improve update efficiency.
[0065] Specifically, the target code file that has been changed can be provided by the code development tool, or it can be obtained based on the last update time and the current time provided by the code development tool. The target code file whose last update time is between the last update time and the current time is selected as the target code file that has been changed. This can greatly reduce the number of files involved in the update.
[0066] It is understandable that when the target code file is a newly added file, the target code file did not exist when the custom database was last created or updated. Therefore, the newly added target code file can be scanned for the first time and the second time according to the process S101 to S103 when creating the custom component library, so as to update the custom component library.
[0067] If the target code file is not a newly added file, and the changes in the target code file do not involve components, then the custom component library does not need to be updated. If the changes in the target code file involve components, the custom component library should be updated according to the changed usage methods and changed attribute information of the custom components included in the changes. Changed usage methods can include usage methods for newly added target custom components, newly added usage methods for existing target custom components, modified usage methods for existing target custom components, and usage methods before modification. Similarly, changed attribute information includes attribute information for newly added custom components, newly added attribute information for existing custom components, modified attribute information for existing target custom components, and attribute information before modification.
[0068] The usage methods and attribute information of the newly added target custom components are updated according to the procedures S102 and S103 during the second scan, so as to add the usage methods and attribute information of the newly added target custom components to the custom component library.
[0069] For a new usage method of an existing target custom component, the new usage method is matched with the corresponding usage template of the target custom component. If the match is successful, the usage count of the usage template is updated. If the match fails to match any usage template of the target custom component, the new usage method generates a usage template and adds it to the custom component library.
[0070] To add new attribute information to an existing custom component, simply add it to the custom component library.
[0071] For existing custom component usage methods (both before and after modification), the usage methods can be matched against usage templates to find matching templates. If the matching templates are the same, no modification is needed. If they are different, the usage count of the template for the usage method before modification should be decremented by 1, and the usage count of the template for the usage method after modification should be incremented by 1. Of course, if no matching template exists for the usage method after modification, a usage template should be generated based on the modified usage method, and its usage count should be set to 1.
[0072] For both the modified and unmodified attribute information of an existing target custom component, the unmodified attribute information of the existing target custom component in the custom component library can be changed to the modified attribute information.
[0073] Of course, redundant templates for the target custom component in the custom component library can also be periodically deleted. Specifically, redundant templates should be used 0 times.
[0074] After the custom component library has undergone the creation and / or update processes described above, code editing can be assisted based on the custom component library. Specifically, in some possible implementations, code editing of the target software project is assisted based on the custom component library, including: When an input component identifier is received in the target software project, the input component information is retrieved from the custom component library based on the input component identifier and displayed. When a confirmation operation for the input component information is received, the identifier of the target custom component included in the input component information is entered into the target software project. When a confirmation operation for using a template included in the input component information is received, the template is used and entered into the target software project.
[0075] The input component identifier can be part or all of the characters of the identifier of a custom component. When the input component identifier is received, it is matched with the identifiers of each target custom component in the custom component library. The relevant information of the successfully matched target custom component in the custom component library is used as the input component information, including but not limited to: template used, attribute information, number of times the template is used, and usage examples corresponding to the template.
[0076] When displaying input component information, the input component information can be organized into a target format, such as JSON (JavaScript Object Notation).
[0077] As can be seen, the embodiments of this application can not only complete the identification of the target custom component, but also support the automatic import of templates, which can improve development efficiency as much as possible.
[0078] The input component information mentioned above may include one or more usage templates, which can be arranged and displayed according to certain rules. Specifically, the displayed input component information includes: Obtain the second code context corresponding to the input component identifier; match the second code context with the usage template of the target custom component in the usage context of the custom component library to obtain the context matching degree; display the usage template in the input component information according to the context matching degree and the number of times it is used.
[0079] The aforementioned second code context can be the content before and after the input position of the input component identifier, or it can be the key content of the content before and after, or the semantic parsing result of the key content, thereby accurately representing the semantic scene in which the input component identifier is located.
[0080] When displaying templates based on context matching and usage frequency, they can be sorted in descending order of these two metrics. Templates with higher context matching and usage frequency are displayed earlier, while those with lower context matching and usage frequency are displayed later. This allows developers to prioritize templates with higher context matching and usage frequency.
[0081] In summary, the embodiments of this application allow for the separate construction of custom component libraries for each software project, with different custom component libraries corresponding to different software projects. This not only facilitates the management of custom component libraries but also reduces the data volume of each custom component library, thereby improving the efficiency of retrieving input component information during assisted editing and ultimately enhancing assisted editing efficiency.
[0082] Figure 4 This is a flowchart illustrating the steps of another custom component processing method in an embodiment of this application, referred to... Figure 4 As shown, the processing method for the above custom component includes the following steps: S201. Perform a first scan of the target code files in the target software project to obtain the first information of the target custom component, and record the first information of the target custom component.
[0083] The target code file includes the file containing the custom component, and the target custom component includes the custom component that is used and is not imported as an installation dependency. The first information includes: the import path, the usage method, and the relative path of the target code file.
[0084] S202. Based on the first information of the target custom component, perform a second scan on the target code files in the target software project. When scanning a target code file, match the usage method with at least one usage template to obtain at least one matching degree.
[0085] S203. When the matching degree is greater than or equal to the preset matching degree threshold, update the number of times the template is used.
[0086] S204. When all matching degrees are less than the preset matching degree threshold, create a usage template in the custom component library according to the usage method, and initialize the usage number of the usage template.
[0087] S205. Obtain the first code context of the target custom component in the target code file, and update the usage context of the template based on the first code context.
[0088] S206. Obtain the scan identifier of the target custom component, and when the scan identifier of the target custom component indicates that it has not been scanned, update the attribute information of the target custom component to the custom component library.
[0089] S207. Obtain the target code files that have been modified in the target software project.
[0090] S208. When the target code file that has been changed is a newly added file, return to the step of performing the first scan of the target code file in the target software project to obtain the first information of the target custom component.
[0091] S209. When the target code file that has been changed is not a newly added file, obtain the changed content from the target code file, and update the custom component library according to the changed usage method and changed attribute information of the custom component included in the changed content.
[0092] S210. When an input component identifier is received in the target software project, the input component information is obtained from the custom component library based on the input component identifier, and the second code context corresponding to the input component identifier is obtained.
[0093] S211. Match the second code context and the usage template of the target custom component in the usage context of the custom component library to obtain the context matching degree, and display the usage template in the input component information according to the context matching degree and the number of times it is used when displaying the input component information.
[0094] S212. Upon receiving a confirmation operation for the input component information, the identifier of the target custom component included in the input component information is entered into the target software project.
[0095] S213. Upon receiving a confirmation operation for using a template included in the input component information, the template will be used to input the target software project.
[0096] It should be noted that S201 to S213 described above can be referred to the foregoing embodiments for explanation, and will not be repeated here. In addition, the order of S201 to S213 can be flexibly adjusted on the basis of mutual independence, and the embodiments of this application do not limit the order of them.
[0097] Figure 5 This is a schematic diagram of the structure of a processing device for a custom component according to an embodiment of this application, such as... Figure 5 As shown, the processing device 400 for the custom component may include: The first scanning module 401 is used to perform a first scan on the target code file of the target software project to obtain the first information of the target custom component, and record the first information of the target custom component. The target code file includes the file where the custom component is located, and the target custom component includes the custom component that is used and is not imported as an installation dependency. The first information includes: import path, usage method and relative path of the target code file.
[0098] The second scanning module 402 is used to perform a second scan on the target code files in the target software project based on the first information of the target custom component. When scanning a target code file, it updates the usage template of the target custom component in the custom component library according to the usage method of the target custom component in the target code file, and obtains the scan identifier of the target custom component.
[0099] The attribute update module 403 is used to update the attribute information of the target custom component to the custom component library when the scan identifier corresponding to the target custom component indicates that it has not been scanned.
[0100] Auxiliary module 404 is used to assist in code editing of the target software project based on a custom component library.
[0101] Optionally, the second scanning module 402 is also used for: Match the usage method with at least one usage template to obtain at least one matching degree; when the matching degree is greater than or equal to the preset matching degree threshold, update the usage count of the usage template; when all matching degrees are less than the preset matching degree threshold, create a usage template in the custom component library according to the usage method and initialize the usage count of the usage template.
[0102] Optionally, the second scanning module 402 is also used for: Get the first code context of the target custom component in the target code file; based on the first code context, update the usage context of the template.
[0103] Optionally, the auxiliary module 404 is also used for: When an input component identifier is received in the target software project, the input component information is retrieved from the custom component library based on the input component identifier and displayed. When a confirmation operation for the input component information is received, the identifier of the target custom component included in the input component information is entered into the target software project. When a confirmation operation for using a template included in the input component information is received, the template is used and entered into the target software project.
[0104] Optionally, the auxiliary module 404 is also used for: Obtain the second code context corresponding to the input component identifier; match the second code context with the usage template of the target custom component in the usage context of the custom component library to obtain the context matching degree; display the usage template in the input component information according to the context matching degree and the number of times it is used.
[0105] Optionally, the above apparatus further includes an incremental update module for: Retrieve the target code files that have been modified in the target software project; if the modified target code file is a newly added file, return to the first scanning module; if the modified target code file is not a newly added file, retrieve the modified content from the target code file, and update the custom component library based on the modified usage methods and modified attribute information of the custom components included in the modified content.
[0106] This application also provides an electronic device 900, such as... Figure 6 As shown, it includes a processor 9001, a communication interface 9002, a memory 9003, and a communication bus 9004. The processor 9001, communication interface 9002, and memory 9003 communicate with each other via the communication bus 9004. The memory 9003 is used to store computer programs; the processor 9001 is used to execute the program stored in the memory 9003 to implement the processing method of the custom component provided in the above embodiments.
[0107] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0108] The communication interface is used for communication between the aforementioned terminal and other devices.
[0109] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0110] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0111] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform the processing method of any of the custom components described in the above embodiments.
[0112] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform the processing method of any of the custom components described in the above embodiments.
[0113] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0114] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0115] It should be noted that the various data-related processes in the embodiments of this application are carried out in compliance with the relevant data protection laws and policies of the country where the location is located, and with the authorization granted by the owner of the corresponding device.
[0116] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0117] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. A method of processing a custom component, the method comprising: The method comprises: performing a first scan on a target code file in a target software project to obtain first information of a target custom component, and recording the first information of the target custom component, the target code file comprising a file in which the custom component is located, the target custom component comprising a custom component that is used and not installed and dependency introduced, and the first information comprising an introduction path, a usage method, and a relative path of the target code file in which the target custom component is located; performing a second scan on the target code file in the target software project based on the first information of the target custom component, and updating a usage template of the target custom component in a custom component library according to a usage method of the target custom component in the target code file each time a target code file is scanned, and obtaining a scan identifier of the target custom component; updating attribute information of the target custom component to the custom component library when the scan identifier corresponding to the target custom component indicates that the target custom component has not been scanned; performing code auxiliary editing on the target software project based on the custom component library.
2. The method of claim 1, wherein, The updating of the usage template of the target custom component in the custom component library according to the usage method of the target custom component in the target code file comprises: matching the usage method with at least one usage template to obtain at least one matching degree; updating a usage frequency of the usage template when the matching degree is greater than or equal to a preset matching degree threshold; creating a usage template in the custom component library according to the usage method and initializing a usage frequency of the usage template when each matching degree is less than the preset matching degree threshold.
3. The method of claim 2, wherein, The method further comprises: obtaining a first code context of the target custom component in the target code file; updating a usage context of the usage template according to the first code context.
4. The method of claim 3, wherein, The performing of the code auxiliary editing on the target software project based on the custom component library comprises: when an input component identifier is received in the target software project, obtaining input component information from the custom component library according to the input component identifier, and displaying the input component information; when a confirmation operation on the input component information is received, inputting an identifier of a target custom component included in the input component information into the target software project; when a confirmation operation on a usage template included in the input component information is received, inputting the usage template into the target software project.
5. The method of claim 4, wherein, The displaying of the input component information comprises: obtaining a second code context corresponding to the input component identifier; matching the second code context with a usage context of the usage template of the target custom component in the custom component library to obtain a context matching degree; displaying the usage template in the input component information according to the context matching degree and the usage frequency.
6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: obtaining a target code file in which a change occurs in the target software project; When the changed target code file is a new file, the first information of the target custom component is obtained by scanning the target code file in the target software project for the first time; When the changed target code file is not a new file, the change content is obtained from the target code file, and the custom component library is updated according to the change usage method and the change attribute information of the custom component included in the change content.
7. A processing device for customizing components, characterized by The device comprises: The first scanning module is configured to scan target code files in a target software project for the first time to obtain first information of a target custom component, and record the first information of the target custom component, wherein the target code files include files in which custom components are located, the target custom component includes a custom component that is used and not installed and dependent on, and the first information includes an introduction path, a usage method, and a relative path of a target code file in which the target custom component is located. The second scanning module is configured to scan the target code files in the target software project for the second time based on the first information of the target custom component, and update a usage template of the target custom component in the custom component library according to a usage method of the target custom component in the target code file, and obtain a scanning identifier of the target custom component when each target code file is scanned. The attribute updating module is configured to update attribute information of the target custom component to the custom component library when the scanning identifier corresponding to the target custom component indicates that the target custom component has not been scanned. The auxiliary module is configured to perform code auxiliary editing on the target software project based on the custom component library.
8. An electronic device, comprising: The device comprises a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus. The memory is configured to store a computer program. The processor is configured to execute the program stored in the memory to implement the method of any one of claims 1 to 6.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1 to 6.
10. A computer program, characterized in that, The computer program is executed by the computer to implement the method of any one of claims 1 to 6. The computer program is executed by the computer to implement the method of any one of claims 1 to 6.