Code query method, device, electronic device and storage medium
By using code query identifiers in the code repository to query the target code and its library information, the problem of difficulty in quickly querying dependent applications when the application interface changes is solved, and the effect of quickly querying dependent application code is achieved.
Patent Information
- Application Number
- CN202111393845.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-23
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2041-11-23
AI Technical Summary
When the interface of the application changes, it is difficult to quickly query all other application codes using the interface, resulting in unnecessary impact on the dependent application.
By receiving code query instructions, using code query identifiers to query the target code and its entry information in the preset code repository, generate code query results and return them to the terminal.
It realizes that when an application needs to modify the interface, it quickly querys all other application codes and their library information using the interface, reducing the impact of interface changes on dependent applications.
Smart Images

Figure CN114115895B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a code query method, device, electronic equipment and storage medium. Background Art
[0002] With the rapid development of computer technology, there are more and more applications, the dependencies between different applications are gradually increasing, and the coupling degree between applications is getting higher and higher.
[0003] Currently, if an application that provides an interface to the outside world changes its interface, it is easy to affect other applications that use the interface. Therefore, a solution that can quickly query the corresponding dependency relationship is needed, so that when the application interface changes, all applications currently using the interface can be queried. Summary of the invention
[0004] The embodiment of the present invention provides a code query method, device, electronic device and storage medium, which can quickly query all other application codes currently using the interface and generate code query results when the application needs to modify the interface.
[0005] An embodiment of the present invention provides a code query method, including:
[0006] receiving a code query instruction, wherein the code query instruction includes at least one code query identifier, and the code query identifier corresponds to the code identifier of the target code;
[0007] Based on the code query identifier, query the target code with the code identifier and the code storage information corresponding to the target code in a preset code repository;
[0008] Generate a code query result according to the code storage information and the code identifier;
[0009] Based on the code query result, code query result information is sent to the terminal that sent the code query instruction.
[0010] Accordingly, an embodiment of the present invention provides a code query device, including:
[0011] An instruction receiving unit, configured to receive a code query instruction, wherein the code query instruction includes at least one code query identifier, and the code query identifier corresponds to a code identifier of a target code;
[0012] An identification query unit, configured to query the target code having the code identification and the code storage information corresponding to the target code in a preset code repository based on the code query identification;
[0013] A result generating unit, used for generating a code query result according to the code storage information and the code identifier;
[0014] The result returning unit is used to send code query result information to the terminal that sends the code query instruction based on the code query result.
[0015] Optionally, before the identification query unit, a code repository creation unit is also included, which is used to create the code repository;
[0016] The code query device further includes a feature extraction unit, which is used to extract code features from the code in response to a code storage request, and determine a code identifier of the code;
[0017] After the feature extraction unit, a feature information generation unit is also included, which is used to generate code feature information of the code based on the code identifier;
[0018] The code query device provided by the embodiment of the present invention further includes a code storage unit, which is used to store the code in the code warehouse based on the code feature information.
[0019] Optionally, before the feature extraction unit, a code monitoring unit is also included, which is used to configure a monitoring code for the code warehouse and monitor the code storage information of the code;
[0020] Correspondingly, the code storage unit is used to store the code in the code warehouse based on the code feature information and the code storage information.
[0021] Optionally, the code storage information includes code project information, and before the feature extraction unit, a code comparison unit is also included, which is used to compare the historical code with the code when there is a historical code in the code warehouse that is the same as the code project information of the code;
[0022] If there is a code update between the historical code and the code, the code identifier of the historical code is adjusted based on the code update, and the adjusted code identifier of the historical code is determined as the code identifier of the code.
[0023] Optionally, the code update includes code deletion, code addition and code modification, and the code comparison unit in the code query device is used to delete the code identifier in the historical code corresponding to the deleted code if the code update is code deletion;
[0024] If the code update is a code addition, code feature extraction is performed on the added difference code to generate first feature information, and the code identifier of the historical code is adjusted based on the first feature information;
[0025] If the code update is a code modification, code feature extraction is performed on the modified code to generate second feature information, and the code identifier of the historical code is adjusted based on the second feature information.
[0026] Optionally, the feature extraction unit is used to determine the code language type corresponding to the code;
[0027] Based on the code language type, obtaining a preset syntax tree analysis tool, wherein the syntax tree analysis tool corresponds to the code language type;
[0028] Analyze the code based on the syntax tree analysis tool to determine the code features of the code;
[0029] The code feature is matched with a preset code feature type, and a code identifier of the code is determined based on the matching result.
[0030] Optionally, the result generating unit is used to determine the position of the code identifier in the target code according to the code identifier;
[0031] A code query result is generated according to the location and the code storage information.
[0032] Correspondingly, an embodiment of the present invention further provides an electronic device, including a memory and a processor; the memory stores an application, and the processor is used to run the application in the memory to execute the steps in any code query method provided in the embodiment of the present invention.
[0033] In addition, an embodiment of the present invention further provides a storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in any one of the code query methods provided in the embodiments of the present invention.
[0034] By adopting the scheme of the embodiment of the present invention, a code query instruction can be received, which includes at least one code query identifier, and the code query identifier corresponds to the code identifier of the target code. Based on the code query identifier, the target code with the code identifier and the code entry information corresponding to the target code are queried in a preset code repository, and a code query result is generated according to the code entry information and the code identifier. Since the target code with the code identifier and the code entry information of the target code can be queried in the code repository through the code identifier, when the application needs to modify the interface, all other application codes currently using the interface and the code entry information can be quickly queried through the code identifier corresponding to the interface to generate a code query result. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 is a schematic diagram of a scenario of a code query method provided by an embodiment of the present invention;
[0037] Figure 2 is a flow chart of a code query method provided by an embodiment of the present invention;
[0038] Figure 3 is a schematic diagram of a flow chart of code identification update provided by an embodiment of the present invention;
[0039] Figure 4 is another schematic diagram of a flow chart of code identification update provided by an embodiment of the present invention;
[0040] Figure 5 is a schematic diagram of the structure of a code query device provided by an embodiment of the present invention;
[0041] Figure 6 is another structural schematic diagram of a code query device provided by an embodiment of the present invention;
[0042] Figure 7 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0044] The embodiments of the present invention provide a code query method, device, electronic device and storage medium. Specifically, the embodiments of the present invention provide a code query method applicable to a code query device, and the code query device can be integrated in an electronic device.
[0045] The electronic device can be a terminal or other device, including but not limited to a mobile terminal and a fixed terminal. For example, a mobile terminal includes but is not limited to a smart phone, a smart watch, a tablet computer, a laptop computer, a smart car-mounted terminal, etc., wherein a fixed terminal includes but is not limited to a desktop computer, a smart TV, etc.
[0046] The electronic device can also be a server or other device. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, as well as big data and artificial intelligence platforms, but is not limited to these.
[0047] The code query method of the embodiment of the present invention may be implemented by a server, or may be implemented by a terminal and a server together.
[0048] The method is described below by taking the example of a terminal and a server jointly implementing the code query method.
[0049] like Figure 1 As shown, the code query system provided by the embodiment of the present invention includes a terminal 10 and a server 20, etc.; the terminal 10 and the server 20 are connected via a network, for example, via a wired or wireless network connection, etc., wherein the terminal 10 can exist as a terminal for a user (developer) to send a code available for query to the server 20.
[0050] The terminal 10 may be a terminal for a user to upload a code for query, and / or the terminal 10 may be a terminal for a user to send a code query instruction to the server 20 .
[0051] The server 20 can be used to receive a code query instruction, which includes at least one code query identifier, which corresponds to the code identifier of the target code. Based on the code query identifier, the target code with the code identifier and the code storage information corresponding to the target code are searched in a preset code repository, and the code storage result is generated according to the code storage information and the code identifier.
[0052] The server 20 may send code query result information to the terminal that sent the code query instruction based on the code query result. For example, after generating the code query result, the code query result may be sent to the terminal 10 that sent the code query instruction, or a preset reminder message may be sent to the terminal 10 that uploaded the target code. The present invention does not limit the content of the reminder message.
[0053] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0054] The embodiment of the present invention will be described from the perspective of a code query device, which may be integrated in a server or a terminal.
[0055] like Figure 2As shown, the specific process of the code query method of this embodiment can be as follows:
[0056] 201. Receive a code query instruction, where the code query instruction includes at least one code query identifier, and the code query identifier corresponds to a code identifier of a target code.
[0057] The code query identifier may be generated according to the needs of the code query user. For example, the code query user may need to query other applications that access a certain interface of a certain application, and so on.
[0058] For example, application A can design its own interface access rules, such as setting a specific interface name. When application A modifies its own interface, it can send a reminder message to all other applications that access the interface.
[0059] At this time, application A can generate a code query identifier according to the aforementioned interface name, and query whether there is a code identifier corresponding to the code query identifier in all codes.
[0060] In some examples, the code query identifier may also include a code package name, a class name, a method name, a method input parameter type and / or an output parameter type, etc. The present invention does not limit the specific identifier type and identifier content.
[0061] In some optional embodiments, developers can pre-set one or more code feature types. For example, the code feature types can include method call code feature type (MethodCallExpr), object creation code feature type (ObjectCreationExpr), method definition / override code feature type (MethodDeclaration) and / or symbol code feature type (NameExpr), etc.
[0062] Among them, the method call code feature type (MethodCallExpr) can limit the code feature type of other developers calling a method that has been written for developers, the object creation code feature type (ObjectCreationExpr) can limit the code feature type of other developers creating new objects in the code for developers, the method definition / override code feature type (MethodDeclaration) can limit the code feature type of other developers defining a new method or overriding a method in the code for developers, the symbol code feature type (NameExpr) can limit the code feature type of other developers writing symbol string code in the code for developers, and so on.
[0063] Furthermore, for different code feature types, developers can limit the method names, method input parameter types, etc. corresponding to different code feature types.
[0064] For example, for the method call code feature type (MethodCallExpr), you can set that when calling a method, you must use the methodFromJars parameter and String array type data to call the jar package where the method is located and the jar package where the method input / output parameter type is located (except for Java basic types), or use the methods parameter and Object type data to match existing methods, or use the methodName parameter and String array type data to determine the method name to be called, or use the classPackageName parameter and String array type data to determine the package name of the class where the method to be called is located (the package name includes the class). The specifics can be shown in the following table:
[0065]
[0066]
[0067] The setting of the object creation code feature type (ObjectCreationExpr) can be shown in the following table, and the present invention will not repeat this setting any more:
[0068]
[0069] The setting of the method definition / rewriting code feature type (MethodDeclaration) can be shown in the following table, and the present invention will not repeat this setting:
[0070]
[0071] The setting of the symbol code feature type (NameExpr) can be shown in the following table, and the present invention will not repeat this setting any more:
[0072]
[0073]
[0074] 202. Based on the code query identifier, query the preset code repository for the target code with the code identifier and the code storage information corresponding to the target code.
[0075] The code repository is a database that can store code. It is understandable that, in addition to the stored code, the code repository can also include code storage information, code identification, and so on.
[0076] In some optional examples, in addition to the storage function of information such as code, code identification, and code entry information, the code repository may also include a management function for the stored information. For example, a user with code repository management authority can delete the code stored in the code repository, modify the code identification of the stored code, and / or view the code entry information, etc.
[0077] For example, Gitlab can be used as a code repository, or a database built by developers themselves can be used as a code repository, and the present invention is not limited to this.
[0078] In actual application, since the accessed application of the called interface or function may correspond to one or more access applications that call the interface or function, correspondingly, there may be one or more groups of target codes with code identifiers. The present invention does not limit the number of queried target codes.
[0079] Among them, code entry information refers to information collected during the code entry process. For example, code entry information may include but is not limited to information collected when the code is submitted to the code repository, including the submission time of the code, the hash value generated according to the submission operation, the code submission user ID, the submitted code project name, the submitted code file and / or the code change type, etc.
[0080] It is understandable that in order to improve the accuracy of the query, there can be multiple code query identifiers. When performing a query, the target code that has code identifiers corresponding to multiple code query identifiers can be queried according to the preset query conditions, or the target code that has a code identifier corresponding to any code query identifier can be queried.
[0081] 203. Generate a code query result according to the code storage information and the code identifier.
[0082] In some optional embodiments, in order to facilitate the access application to adjust the calling relationship, after generating the code query result, the code repository or the accessed application can notify the user who submitted the code based on the code entry information in the code query result, for example, sending a prompt message to the user who submitted the code, etc. The present invention does not limit the content and form of the notification.
[0083] Specifically, in order to facilitate the user who submitted the code to adjust the calling relationship in the code, the position of the code identifier in the code can be first obtained, and the position is also added to the code query result, so that the user who queries the code or the user who submits the code can determine the position of the code identifier and adjust the code. That is, step 203 may include:
[0084] According to the code identifier, determine the position of the code identifier in the target code;
[0085] Generate code query results based on the location and code storage information.
[0086] The generated code query result may directly include the specific line number of the code identifier in the target code, or may also be the line number range of the code identifier in the target code, and so on.
[0087] In the actual application process, in order to ensure the association between the code and the code identifier, the code feature extraction can be performed on the code during the storage process of each group of codes. After the code identifier is generated, the code identifier and the code are stored together in the code warehouse. That is, before the step of "receiving the code query instruction", it can also include:
[0088] Create a code repository;
[0089] In response to a code storage request, extract code features from the code and determine a code identifier of the code;
[0090] Based on the code identifier, code feature information of the code is generated;
[0091] Based on the code feature information, the code is stored in the code repository.
[0092] The code feature extraction for the code may be to directly read the type, method name and other information in the code, or may be to analyze the code components as the code features. In an example, the step of "extracting the code features for the code and determining the code identifier of the code" may include:
[0093] Determine the code language type corresponding to the code;
[0094] Based on the code language type, a preset syntax tree analysis tool is obtained, where the syntax tree analysis tool corresponds to the code language type;
[0095] Analyze the code based on the syntax tree analysis tool to determine the code features;
[0096] The code feature is matched with a preset code feature type, and a code identifier of the code is determined based on the matching result.
[0097] Among them, the syntax tree is a graphical representation of the sentence structure, which represents the derivation result of the programming statements in the code, and is helpful for understanding the hierarchy of the programming statement structure. In other words, the syntax tree can be a tree formed when deducing according to a certain rule.
[0098] The step of “analyzing the code based on the syntax tree analysis tool to determine the code features of the code” may specifically include:
[0099] The code is split into components through the syntax tree analysis tool to obtain the grammatical components of the code.
[0100] For example, the syntax tree analysis tool can be an existing syntax tree analysis tool, such as the Java language code can be analyzed by the JavaParser tool. The syntax tree analysis tool can also be a tool generated according to the analysis method designed by the developer. For example, the analysis method can be to first perform lexical analysis on the program code, perform grammatical analysis on the program syntax based on the lexical analysis, and construct the program abstract syntax tree by combining the lexical analysis results and the grammatical analysis results, and finally mark the nodes of the syntax tree, etc.
[0101] Furthermore, the step of “matching the code feature with a preset code feature type and determining the code identifier of the code based on the matching result” may include:
[0102] Perform feature matching of each grammatical component of the code with a preset reference grammatical component;
[0103] If the match is successful, a corresponding code identifier is determined for the successfully matched grammatical component.
[0104] Among them, the grammatical components can be keywords, identifiers, separators, comments, etc. in the code, such as keywords such as if used for judgment, class used for class declaration, return used for return statement in JAVA language, and separators such as space, comma, or semicolon used to separate two grammatical components, etc.
[0105] In some embodiments, other grammatical components related to the accessed application can be further determined based on grammatical components such as fixed keywords, identifiers, separators, comments, etc. of the programming language, such as the aforementioned class name, input parameter type, output parameter type, etc. for the method call code feature type (MethodCallExpr), object creation code feature type (ObjectCreationExpr), method definition / override code feature type (MethodDeclaration) and / or symbol code feature type (NameExpr).
[0106] In order to facilitate the rapid query of the corresponding project and the storage information corresponding to the code feature according to the tag when the interface or specific code feature needs to be queried, before the step of "responding to the storage request of the code, extracting the code feature of the code and determining the code identifier of the code", it may also include:
[0107] Configure monitoring code for the code repository and monitor the code entry information of the code;
[0108] Correspondingly, the step of “storing the code into the code repository based on the code feature information” may include:
[0109] Based on the code feature information and code storage information, the code is stored in the code repository.
[0110] The monitoring code may be a code that implements the monitoring function of the code warehouse itself, and the user may directly use the code monitoring function, or configure the monitoring code of the code warehouse according to actual usage requirements. In other embodiments, the user may configure the monitoring code for the code warehouse for the code warehouse, such as setting a monitoring component, etc., to realize the recording of the operation of the information in the code warehouse.
[0111] It is understandable that with the increase in user needs and the improvement of application functions, the code for accessing applications may change continuously. In order to save storage resources and computing resources during search, and to avoid storing the code once in the code repository every time the code changes, it is possible to detect whether the code to be stored requested to be stored in the code repository is already stored code. If the code to be stored corresponds to a group of stored codes and a unified access application, the code identifier can be updated based on the stored code.
[0112] Therefore, the code storage information may include code project information, and before the step of "extracting code features from the code and determining the code identifier of the code", the following may also be included:
[0113] When there is historical code in the code repository that has the same code project information as the code, the historical code is compared with the code;
[0114] If there is a code update between the historical code and the code, the code identifier of the historical code is adjusted based on the code update, and the code identifier of the adjusted historical code is determined as the code identifier of the code.
[0115] The code project information may include but is not limited to at least one of a code project identification number, a code project name, project creation information, a project creation user, and the like.
[0116] In some optional embodiments, the code update may include but is not limited to at least one of code deletion, code addition and reduction, and code modification. That is, the code update may include code deletion, code addition, and code modification;
[0117] Correspondingly, the step of “adjusting the code identification of the historical code based on the code update” may include:
[0118] If the code update is code deletion, the code identifier in the historical code corresponding to the deleted code is deleted;
[0119] If the code update is code addition, code feature extraction is performed on the added difference code to generate first feature information, and the code identifier of the historical code is adjusted based on the first feature information;
[0120] If the code update is a code modification, code feature extraction is performed on the modified code to generate second feature information, and the code identifier of the historical code is adjusted based on the second feature information.
[0121] For example, Figure 3 As shown, after the code is stored in the repository, the code project information is first compared with the code project information of the historical code in the code repository. If there is no identical code information, the code feature extraction is performed on the code to determine the code identifier of the code.
[0122] If the same code information exists, the historical code is compared with the code. If the code is updated to be deleted, the code identifier corresponding to the deleted code in the historical code is deleted for the deleted code.
[0123] If the code update is not a code deletion, it can be further determined whether the code update is a code modification. If the code update is a code modification, the code identifier corresponding to the modified code in the historical code is adjusted for the modified code.
[0124] Generally speaking, if the code update is not a code deletion and / or code modification, the code update can be considered as a code addition, and the historical code is compared with the code, and the code identifier of the historical code is adjusted for the added code.
[0125] In some examples, the added code may not have a preset code feature, and the code identifier of the historical code may not be adjusted. If the added code may have a preset code feature, a corresponding code identifier may be added to the historical code.
[0126] It is understandable that the code update may include at least two of code deletion, code modification and code addition. The specific order of detecting the code update is not limited, or the detection may be performed simultaneously through multiple threads, which is not limited in the present invention.
[0127] For example, Figure 4 As shown, the type of code update can be directly marked when the code is entered into the repository. If the code update type is to delete all historical codes, you do not need to perform code comparison and other steps, and directly delete all codes, code identifiers and code entry information corresponding to the code project information. If the code update type is not to delete all historical codes, you can adjust the code identifiers in the code repository through steps similar to the above.
[0128] 204. Based on the code query result, send code query result information to the terminal that sends the code query instruction.
[0129] The code query result may be the same as the code query result information, or may be different from the code query result information.
[0130] For example, the code query result may include a code identifier of the target code, etc., and the code query result information may directly be the code query result.
[0131] For another example, before returning the code query result information, the code query result can be further processed, for example, the code query result can be presented in a table to obtain the code query result information; or, based on the code query result, the developer information of the target code can be further queried, and the developer information and the code query result can be used together as the code query result information.
[0132] It is understandable that after obtaining the code query result, the code query result information may not be sent to the terminal that sent the code query instruction, but the interface modification information may be directly sent to the developer corresponding to the target code, and so on.
[0133] As can be seen from the above, an embodiment of the present invention can receive a code query instruction, the code query instruction includes at least one code query identifier, the code query identifier corresponds to the code identifier of the target code, based on the code query identifier, the target code with the code identifier and the code entry information corresponding to the target code are queried in a preset code repository, and a code query result is generated according to the code entry information and the code identifier; since the target code with the code identifier and the code entry information of the target code can be queried in the code repository through the code identifier, therefore, when the application needs to modify the interface, all other application codes currently using the interface and the code entry information can be quickly queried through the code identifier corresponding to the interface to generate a code query result.
[0134] In order to better implement the above method, accordingly, an embodiment of the present invention further provides a code query device.
[0135] refer to Figure 5 , the device may include:
[0136] The instruction receiving unit 501 may be used to receive a code query instruction, wherein the code query instruction may include at least one code query identifier, and the code query identifier corresponds to the code identifier of the target code;
[0137] The identifier query unit 502 may be used to query the target code having the code identifier and the code storage information corresponding to the target code in a preset code repository based on the code query identifier;
[0138] A result generating unit 503 may be used to generate a code query result according to the code storage information and the code identifier;
[0139] The result returning unit 504 is configured to send code query result information to the terminal that sent the code query instruction based on the code query result.
[0140] Optionally, before the identification query unit 502, a code repository creation unit 505 may be included, which may be used to create the code repository;
[0141] like Figure 6 As shown, the code query device may further include a feature extraction unit 506, which may be used to extract code features from the code in response to a code storage request, and determine a code identifier of the code;
[0142] After the feature extraction unit 506, a feature information generation unit 507 may be included, which may be used to generate code feature information of the code based on the code identifier;
[0143] The code query device provided by the embodiment of the present invention may further include a code storage unit 508, which may be used to store the code into the code repository based on the code feature information.
[0144] Optionally, before the feature extraction unit 506, a code monitoring unit 509 may be included, which may be used to configure a monitoring code for the code warehouse and monitor the code storage information of the code;
[0145] Correspondingly, the code storage unit 508 can be used to store the code in the code warehouse based on the code feature information and the code storage information.
[0146] Optionally, the code storage information may include code project information. Before the feature extraction unit 506, a code comparison unit 510 may be included, which may be used to compare the historical code with the code when there is a historical code in the code repository that has the same code project information as the code;
[0147] If there is a code update between the historical code and the code, the code identifier of the historical code is adjusted based on the code update, and the adjusted code identifier of the historical code is determined as the code identifier of the code.
[0148] Optionally, the code update may include code deletion, code addition and code modification, and the code comparison unit 510 in the code query device may be used to delete the code identifier in the historical code corresponding to the deleted code if the code update is code deletion;
[0149] If the code update is a code addition, code feature extraction is performed on the added difference code to generate first feature information, and the code identifier of the historical code is adjusted based on the first feature information;
[0150] If the code update is a code modification, code feature extraction is performed on the modified code to generate second feature information, and the code identifier of the historical code is adjusted based on the second feature information.
[0151] Optionally, the feature extraction unit 506 may be used to determine a code language type corresponding to the code;
[0152] Based on the code language type, obtaining a preset syntax tree analysis tool, wherein the syntax tree analysis tool corresponds to the code language type;
[0153] Analyze the code based on the syntax tree analysis tool to determine the code features of the code;
[0154] The code feature is matched with a preset code feature type, and a code identifier of the code is determined based on the matching result.
[0155] Optionally, the result generating unit 503 may be used to determine the position of the code identifier in the target code according to the code identifier;
[0156] A code query result is generated according to the location and the code storage information.
[0157] As can be seen from the above, through the code query device, a code query instruction can be received through the instruction receiving unit, the code query instruction includes at least one code query identifier, the code query identifier corresponds to the code identifier of the target code, and the identifier query unit queries the target code with the code identifier and the code entry information corresponding to the target code in the preset code warehouse based on the code query identifier, and the result generating unit generates a code query result according to the code entry information and the code identifier; since the target code with the code identifier and the code entry information of the target code can be queried in the code warehouse through the code identifier, therefore, when the application needs to modify the interface, the code identifier corresponding to the interface can be used to quickly query all other application codes currently using the interface and the code entry information to generate a code query result.
[0158] In addition, an embodiment of the present invention further provides an electronic device, which may be a terminal or a server, etc. Figure 7 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:
[0159] The electronic device may include a radio frequency (RF) circuit 701, a memory 702 including one or more computer-readable storage media, an input unit 703, a display unit 704, a sensor 705, an audio circuit 706, a wireless fidelity (WiFi) module 707, a processor 708 including one or more processing cores, and a power supply 709. Those skilled in the art will appreciate that Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0160] The RF circuit 701 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is handed over to one or more processors 708 for processing; in addition, the data related to the uplink is sent to the base station. Usually, the RF circuit 701 includes but is not limited to an antenna, at least one amplifier, a tuner, one or more oscillators, a subscriber identity module (SIM) card, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 701 can also communicate with the network and other devices through wireless communication. Wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0161] The memory 702 can be used to store software programs and modules, and the processor 708 executes various functional applications and data processing by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 702 may also include a memory controller to provide the processor 708 and the input unit 703 with access to the memory 702.
[0162] The input unit 703 can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Specifically, in a specific embodiment, the input unit 703 may include a touch-sensitive surface and other input devices. The touch-sensitive surface, also known as a touch display screen or a touch pad, can collect the user's touch operations on or near it (such as the user's operation on or near the touch-sensitive surface using any suitable object or accessory such as a finger, a stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch-sensitive surface may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 708, and can receive and execute the command sent by the processor 708. In addition, the touch-sensitive surface can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch-sensitive surface, the input unit 703 may also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0163] The display unit 704 can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit 704 may include a display panel. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch-sensitive surface may cover the display panel. When the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor 708 to determine the type of touch event. Subsequently, the processor 708 provides a corresponding visual output on the display panel according to the type of touch event. Although in Figure 7 In the embodiment, the touch-sensitive surface and the display panel are used as two independent components to realize input and output functions, but in some embodiments, the touch-sensitive surface and the display panel can be integrated to realize input and output functions.
[0164] The electronic device may also include at least one sensor 705, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel according to the brightness of the ambient light, and the proximity sensor may turn off the display panel and / or backlight when the electronic device is moved to the ear. As a type of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the electronic device, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0165] The audio circuit 706, the speaker, and the microphone can provide an audio interface between the user and the electronic device. The audio circuit 706 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 706 and converted into audio data, and then the audio data is output to the processor 708 for processing, and then sent to another electronic device through the RF circuit 701, or the audio data is output to the memory 702 for further processing. The audio circuit 706 may also include an earplug jack to provide communication between an external headset and the electronic device.
[0166] WiFi is a short-range wireless transmission technology. Electronic devices can help users send and receive emails, browse web pages, and access streaming media through WiFi module 707. It provides users with wireless broadband Internet access. Figure 7 A WiFi module 707 is shown, but it is understandable that it is not an essential component of the electronic device and can be omitted as needed without changing the essence of the invention.
[0167] The processor 708 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and / or modules stored in the memory 702 and calling data stored in the memory 702, it executes various functions of the electronic device and processes data, thereby monitoring the mobile phone as a whole. Optionally, the processor 708 may include one or more processing cores; preferably, the processor 708 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 708.
[0168] The electronic device also includes a power supply 709 (such as a battery) for supplying power to each component. Preferably, the power supply can be logically connected to the processor 708 through a power management system, so that the power management system can manage charging, discharging, and power consumption management. The power supply 709 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0169] Although not shown, the electronic device may also include a camera, a Bluetooth module, etc., which will not be described in detail here. Specifically in this embodiment, the processor 708 in the electronic device will load the executable files corresponding to the processes of one or more applications into the memory 702 according to the following instructions, and the processor 708 will run the application stored in the memory 702 to achieve various functions, as follows:
[0170] receiving a code query instruction, the code query instruction including at least one code query identifier, the code query identifier corresponding to the code identifier of the target code;
[0171] Based on the code query identifier, query the target code with the code identifier and the code storage information corresponding to the target code in the preset code repository;
[0172] Generate code query results based on code storage information and code identification.
[0173] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0174] To this end, an embodiment of the present invention provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any code query method provided in the embodiment of the present invention. For example, the instructions can execute the following steps:
[0175] The application programs in the memory 702 implement various functions, as follows:
[0176] receiving a code query instruction, the code query instruction including at least one code query identifier, the code query identifier corresponding to the code identifier of the target code;
[0177] Based on the code query identifier, query the target code with the code identifier and the code storage information corresponding to the target code in the preset code repository;
[0178] Generate code query results based on code storage information and code identification.
[0179] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0180] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0181] Since the instructions stored in the storage medium can execute the steps in any code query method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any code query method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0182] According to one aspect of the present application, a computer program product or a computer program is also provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the methods provided in various optional implementations of the above embodiments.
[0183] The above is a detailed introduction to a code query method, device, electronic device and storage medium provided in an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A code query method, characterized in that: include: Receive a code query instruction, the code query instruction includes at least one code query identifier, the code query identifier corresponds to a code identifier included in the target code, the code identifier corresponds to an interface, and the target code including the code identifier includes at least one group; Based on the code query identifier, query the target code with the code identifier and the code storage information corresponding to the target code in a preset code repository; Generate a code query result according to the code storage information and the code identifier, the code query result including other application codes using the interface and code storage information; Based on the code query result, sending code query result information to the terminal that sent the code query instruction; When the interface is modified, a reminder message is sent to each application accessing the interface.
2. The code query method according to claim 1, characterized in that: Before searching the preset code repository for the target code having the code identifier based on the code query identifier, the method further includes: Creating the code repository; In response to a code storage request, extract code features from the code to determine a code identifier of the code; Based on the code identifier, generate code feature information of the code; Based on the code feature information, the code is stored in the code repository.
3. The code query method according to claim 2, characterized in that: The method further comprises: extracting code features from the code in response to the code storage request, and determining the code identifier of the code; Configure a monitoring code for the code warehouse to monitor the code entry information of the code; The storing the code into the code repository based on the code feature information includes: Based on the code feature information and the code storage information, the code is stored in the code warehouse.
4. The code query method according to claim 3, characterized in that: The code storage information includes code project information; Before extracting code features from the code and determining the code identifier of the code, the method further includes: When there is a historical code in the code repository that has the same code project information as the code, comparing the historical code with the code; If there is a code update between the historical code and the code, the code identifier of the historical code is adjusted based on the code update, and the adjusted code identifier of the historical code is determined as the code identifier of the code.
5. The code query method according to claim 4, characterized in that: The code update includes code deletion, code addition and code modification; The step of adjusting the code identifier of the historical code based on the code update includes: If the code update is code deletion, deleting the code identifier in the historical code corresponding to the deleted code; If the code update is a code addition, code feature extraction is performed on the added difference code to generate first feature information, and the code identifier of the historical code is adjusted based on the first feature information; If the code update is a code modification, code feature extraction is performed on the modified code to generate second feature information, and the code identifier of the historical code is adjusted based on the second feature information.
6. The code query method according to claim 2, characterized in that: The extracting code features from the code to determine the code identifier of the code includes: Determining a code language type corresponding to the code; Based on the code language type, obtaining a preset syntax tree analysis tool, wherein the syntax tree analysis tool corresponds to the code language type; Analyze the code based on the syntax tree analysis tool to determine the code features of the code; The code feature is matched with a preset code feature type, and a code identifier of the code is determined based on the matching result.
7. The code query method according to any one of claims 1 to 6, characterized in that: The generating of the code query result according to the code storage information and the code identifier includes: According to the code identifier, determining the position of the code identifier in the target code; A code query result is generated according to the location and the code storage information.
8. A code query device, characterized in that: include: An instruction receiving unit, configured to receive a code query instruction, wherein the code query instruction includes at least one code query identifier, the code query identifier corresponds to a code identifier included in the target code, the code identifier corresponds to an interface, and the target code including the code identifier includes at least one group; An identification query unit, configured to query the target code having the code identification and the code storage information corresponding to the target code in a preset code repository based on the code query identification; A result generating unit, configured to generate a code query result according to the code storage information and the code identifier, wherein the code query result includes other application codes using the interface and the storage information of the code; A result returning unit, configured to send code query result information to a terminal that sends the code query instruction based on the code query result; When the interface is modified, a reminder message is sent to each application accessing the interface.
9. An electronic device, characterized in that: It comprises a memory and a processor; the memory stores an application program, and the processor is used to run the application program in the memory to execute the steps in the code query method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the code query method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Application converting method and device and equipment
CN107239318A
Project construction method and device, computer equipment and storage medium
CN112416327A