Nothing Special   »   [go: up one dir, main page]

CN113535178A - Code package reference method and device - Google Patents

Code package reference method and device Download PDF

Info

Publication number
CN113535178A
CN113535178A CN202010284657.0A CN202010284657A CN113535178A CN 113535178 A CN113535178 A CN 113535178A CN 202010284657 A CN202010284657 A CN 202010284657A CN 113535178 A CN113535178 A CN 113535178A
Authority
CN
China
Prior art keywords
code
code package
version
package
attribute information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010284657.0A
Other languages
Chinese (zh)
Other versions
CN113535178B (en
Inventor
徐治理
霍龙社
曹云飞
崔煜喆
刘腾飞
唐雄燕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China United Network Communications Group Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China United Network Communications Group Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202010284657.0A priority Critical patent/CN113535178B/en
Publication of CN113535178A publication Critical patent/CN113535178A/en
Application granted granted Critical
Publication of CN113535178B publication Critical patent/CN113535178B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

本申请提供一种代码包的引用方法及装置,涉及计算机技术领域,能够解决脚本代码和引用的代码包存在版本冲突的问题。该方法包括:计算机设备解析脚本代码,确定脚本代码所引用的第一代码包的名称和第一方法的属性信息;根据第一代码包的名称,查找到M个版本的第一代码包;根据第一方法的属性信息,从M个版本的第一代码包中,确定目标版本的第一代码包;指示脚本代码引用目标版本的第一代码包。本申请实施例用于引用代码包的过程中。

Figure 202010284657

The present application provides a code package reference method and device, which relate to the field of computer technology and can solve the problem of version conflict between script code and referenced code package. The method includes: the computer device parses the script code, determines the name of the first code package referenced by the script code and the attribute information of the first method; according to the name of the first code package, finds M versions of the first code package; The attribute information of the first method determines the first code package of the target version from the M versions of the first code package; instructs the script code to refer to the first code package of the target version. The embodiments of the present application are used in the process of referencing code packages.

Figure 202010284657

Description

Code package reference method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for referencing a code package.
Background
In the software development process, in order to reduce repeated labor and improve code development efficiency, a developer can package common functions realized by the developer into a code packet and disclose the code packet to other developers for calling, so that the other developers can directly refer to the code packet only by knowing an input interface and an output interface of the code packet, and business development is rapidly realized.
However, each code package is independently developed by different developers according to the needs of the developers, and the developers can add a new code package according to the needs and change script codes in the new code package (for example, adding a method in the code package or deleting a method). Therefore, in the development process, the script code refers to a code packet with an incorrect version (the code packet with the incorrect version does not contain the method called by the script code), so that the script code cannot jump to the method normally, and the problem of abnormal running of the script code is caused.
Disclosure of Invention
The application provides a code package reference method and device, which are used for solving the problem that script codes cannot run normally due to the fact that a code package with a wrong version is referred.
In order to achieve the purpose, the technical scheme is as follows:
in a first aspect, the present application provides a method for referencing a code package, the method comprising:
the computer equipment analyzes the script codes and determines the name of a first code packet referred by the script codes and attribute information of a first method; searching first code packets of M versions according to the names of the first code packets, wherein M is a positive integer; according to the attribute information of the first method, determining a first code packet of a target version from first code packets of M versions, wherein the first code packet of the target version comprises the first method; the script code is instructed to reference a first code package of the target version.
Based on the technical scheme, the computer device can determine the first code packet of the target version from the first code packets of the M versions (the first code packet of the target version comprises the first method), and the problem that the computer device cannot determine which version of the first code packet has the first method and further cannot determine the first code packet of the target version is solved. Moreover, the first code packet of the target version comprises the first method, so that the script codes quote the first code packet of the target version, normal jumping of the script codes to the first method in the first code packet can be realized, and the script codes can run normally.
In one possible design, checking whether a first code packet of an ith version contains a method with attribute information identical to attribute information of the first method, wherein the ith version is any one of M versions, and i is a positive integer less than or equal to M; and if the first code packet of the ith version contains the method with the attribute information being the same as the attribute information of the first method, determining that the first code packet of the ith version is the first code packet of the target version.
In one possible design, the attribute information of the first method includes a name of the first method; if the first code packages of the M versions do not include the method with the attribute information being the same as that of the first method, calculating the name similarity of each method in the N methods and the first method, wherein the name similarity is used for indicating the similarity of the two methods on the name, and the N methods are all the methods included by the first code packages of the M versions; determining a method with the highest name similarity from the N methods; and taking the first code packet containing the method with the highest name similarity as the first code packet of the target version.
In one possible design, the method for referencing the code package further includes: determining the name of a second code packet called by the first method and attribute information of the second method; determining P versions of second code packets according to the names of the second code packets, wherein P is a positive integer; determining a second code packet of a reference version from the second code packets of the P versions according to the attribute information of the second method; the second code package of the referenced version includes the second method; the second code package indicating that the script code references the version.
In a second aspect, the present application provides an apparatus for referencing a code package, the apparatus comprising:
the analysis unit is used for analyzing the script codes and determining the names of the first code packets quoted by the script codes and the attribute information of the first method; the processing unit is used for searching the first code packets of M versions according to the names of the first code packets, wherein M is a positive integer; according to the attribute information of the first method, determining a first code packet of a target version from first code packets of M versions, wherein the first code packet of the target version comprises the first method; and the reference unit is used for indicating the script code to reference the first code package of the target version.
In one possible design, the processing unit is further configured to check whether the first code packet of the ith version includes a method whose attribute information is the same as the attribute information of the first method, where the ith version is any one of M versions, and i is a positive integer less than or equal to M; and if the first code packet of the ith version contains the method with the attribute information being the same as the attribute information of the first method, determining that the first code packet of the ith version is the first code packet of the target version.
In one possible design, the processing unit is further configured to calculate a name similarity between each of the N methods and the first method if none of the M versions of the first code packages includes a method whose attribute information is the same as the attribute information of the first method, where the name similarity is used to indicate a similarity between the two methods on the name, and the N methods are all methods included in the M versions of the first code packages; determining a method with the highest name similarity from the N methods; and taking the first code packet containing the method with the highest name similarity as the first code packet of the target version.
In one possible design, the parsing unit further determines a name of a second code packet called by the first method and attribute information of the second method; the processing unit is also used for determining P versions of second code packets according to the names of the second code packets, wherein P is a positive integer; determining a second code packet of a reference version from the second code packets of the P versions according to the attribute information of the second method; the second code package of the referenced version includes the second method. And the reference unit is also used for indicating the script code to reference the second code package of the reference version.
In a third aspect, the present application provides a computer device comprising: a processor and a communication interface; the communication interface is coupled to a processor for executing a computer program or instructions for implementing the method of referencing a code package as described in the first aspect and any possible implementation form of the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium having stored therein instructions that, when executed on a computer, cause the computer to perform the method of referencing the code package described in any one of the possible implementations of the first aspect and the first aspect described above.
In a fifth aspect, the present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of referencing a code package as described in the first aspect and any one of the possible implementations of the first aspect.
In a sixth aspect, the present application provides a chip comprising a processor and a communication interface, the communication interface being coupled to the processor, the processor being configured to execute a computer program or instructions to implement the method of referencing a code package as described in the first aspect and any one of the possible implementations of the first aspect.
In the above-mentioned solution, for technical problems that can be solved by the code packet referencing device, the computer storage medium, the computer program product, or the chip, and technical effects that can be achieved by the code packet referencing device, the computer storage medium, the computer program product, or the chip, reference may be made to the technical problems and the technical effects that are solved by the first aspect, and details are not described herein again.
Drawings
Fig. 1 is a flowchart illustrating a method for referencing a code package according to an embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating another method for referencing a code package according to an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating another method for referencing a code package according to an embodiment of the present disclosure;
FIG. 4 is a flowchart illustrating another method for referencing a code package according to an embodiment of the present disclosure;
FIG. 5 is a schematic structural diagram of a device for referencing a code package according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of another computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The character "/" herein generally indicates that the former and latter associated objects are in an "or" relationship. For example, A/B may be understood as A or B.
The terms "first" and "second" in the description and claims of the present application are used for distinguishing between different objects and not for describing a particular order of the objects.
Furthermore, the terms "including" and "having," and any variations thereof, as referred to in the description of the present application, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or modules is not limited to the listed steps or modules but may alternatively include other steps or modules not listed or inherent to such process, method, article, or apparatus.
In addition, in the embodiments of the present application, words such as "exemplary" or "for example" are used to mean serving as examples, illustrations or explanations. Any embodiment or design described herein as "exemplary" or "e.g.," is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "e.g.," is intended to present concepts in a concrete fashion.
The technical scheme provided by the embodiment of the application can be executed by computer equipment. The computer device is a device installed with a programming tool that supports programming using a programming language with a code package sharing platform, a programming language in which a reference declaration is present for a code package, and a programming language in which a reference method is present (e.g., Java language, Python language), for example, intellj IDEA, eclipse. The computer device may store script code written by a developer or automatically generate script code generated by scripting software. The computer device may be a tablet computer, a notebook computer, a desktop computer, a portable computer, and the like, which is not limited in this application.
As shown in fig. 1, a method for referencing a code package provided by an embodiment of the present application includes the following steps:
s101, the computer equipment analyzes the script codes and determines the names of the first code packages and the attribute information of the first method, wherein the first code packages are referred by the script codes.
The script code may be a script code written by a developer, or a script code generated by automatically generating script software, which is not limited in this embodiment of the present application.
The script code includes a reference declaration and attribute information of the first method. The reference declaration includes the name of the code package referenced by the reference word (e.g., import) and the script code. For example, the citation claim may be that: and the import PackageA refers to the import word and refers to the name of the code packet referred by the script code as PackageA. The attribute information of the first method includes: name of the first method, parameter type of the first method, number of parameters of the first method, return value type of the first method.
In one possible implementation, the computer device parses the script code to determine the citation claim and attribute information for the first method. Thereafter, the computer device determines a name of a first code package referenced by the script code based on the reference declaration.
S102, the computer device finds the first code packages of the M versions according to the names of the first code packages.
Wherein M is a positive integer.
According to one possible implementation manner, the computer device reads the environment variable and finds the first code packages of the M versions according to the names of the first code packages. The environment variable includes M versions of a first code package.
It should be noted that, because the methods in the code package may change with the update of the technology or the change of the requirement, the computer device may store the code packages of different versions, so as to achieve the purpose that different requirements can be realized by different versions of one code package.
S103, the computer device determines the first code packet of the target version from the first code packets of the M versions according to the attribute information of the first method.
Wherein the first code package of the target version includes a first method.
S104, the computer device instructs the script code to refer to the first code packet of the target version.
It will be appreciated that since the target version of the first code package includes the first method, the computer device instructs the script code to reference the target version of the first code package, enabling the script code to jump normally into the first method in the first code package.
Based on the technical scheme shown in fig. 1, the computer device can determine the first code packet of the target version from the first code packets of the M versions (the first code packet of the target version includes the first method), and the problem that the computer device cannot determine which version of the first code packet has the first method and cannot determine the first code packet of the target version is solved. Moreover, the first code packet of the target version comprises the first method, so that the script codes quote the first code packet of the target version, normal jumping of the script codes to the first method in the first code packet can be realized, and the script codes can run normally.
As shown in fig. 2, step S103 may be embodied as the following steps:
s201, the computer device checks whether the first code packet of the ith version contains the method of which the attribute information is the same as the attribute information of the first method.
The ith version is any one of M versions, and i is a positive integer less than or equal to M.
Note that the attribute information of the method is the same as the attribute information of the first method, which means that the name, the parameter type, the number of parameters, and the return value type of the method are all the same as the attribute information of the first method.
Illustratively, the attribute information of the first method is: function1(3, 5). The name of the first method is Function1, the parameters of the first method are 3 and 5 of integer type (int), and the return value type of the first method is int.
The computer device parses the attribute information of the method in the version code packet from the first code packet of version 1.0. The method of the first code package of version 1.0 is as follows:
Figure BDA0002448012700000061
the name of the method in the first code packet of version 1.0 is Function1, the parameter types of the method are all integer types, the number of the parameters of the method is 2, and the type of the returned value is int. Therefore, the first code package of version 1.0 contains the same method as the attribute information of the first method.
S202, if the first code packet of the ith version contains the method of which the attribute information is the same as the attribute information of the first method, the computer equipment determines that the first code packet of the ith version is the first code packet of the target version.
Based on the technical scheme shown in fig. 2, the computer device can determine the first code packet of the target version in different ways by judging whether the first code packet of the ith version contains the method that the attribute information is the same as the attribute information of the first method, so that the problem that the computer device cannot determine which version of the first code packet contains the method called by the script code and cannot determine the first code packet of the target version is solved. In addition, the first code packet of the target version contains the method called by the script code, so that the script code refers to the first code packet of the target version, the method that the script code normally jumps to the first code packet can be realized, and the script code can normally run.
If none of the first code packets of the M versions contains a method whose attribute information is the same as the attribute information of the first method, as shown in fig. 3, step S103 may be further specifically implemented as:
s301, the computer device calculates the name similarity of each method in the N methods and the first method.
The name similarity is used for indicating the similarity of the two methods on the name, and the N methods are all methods included in the first code packet of the M versions.
According to one possible implementation manner, the computer device analyzes N methods from the first code packets of the M versions, and calculates the name similarity of each method in the N methods and the first method.
It should be noted that whether the name components of the two methods are the same, whether the name components of the two methods are arranged in the same order, and the case of the letter all affect the similarity of the names. The following is illustrated by three examples.
Example one, the name of the first method is Function1, the name of the method 2 is Function2, and the computer device calculates the similarity of the names of the method 2 and the method 1 to be 8/9.
Example two, the name of method 1 is Function1, the name of method 2 is F2 action, and the computer device calculates the similarity between the names of method 2 and method 1 to be 1/9.
Example three, method 1 is named Function1, method 2 is named Function2, and the computer device calculates the similarity between method 2 and method 1 as 7/9.
It can be understood that the name similarity needs to consider multiple factors of whether the name components of the two methods are the same or not, so that the computer device can acquire the method with higher name similarity to the first method.
S302, the computer equipment determines the method with the highest name similarity from the N methods.
In one possible implementation, the computer device compares the N name similarities and determines the method with the highest name similarity.
Illustratively, table 1 shows that the first code package (e.g., PackageA) has 2 versions, and that the 2 versions of the first code package contain 4 methods. One row in table 1 is a piece of data representing the method contained by each version of PackageA. The first method is named Function 1.
TABLE 1
Figure BDA0002448012700000071
The name similarity between the Function method and the Function1 is 8/9, the name similarity between the Function1 and the Function1 is 3/9, the name similarity between the Function1 is 5/9, and the name similarity between the Function aaaa1 and the Function1 is 4/9. 8/9>5/9>4/9> 3/9. That is, the Function method has the highest similarity with the Function1 method.
S303, the computer device takes the first code packet containing the method with the highest name similarity as the first code packet of the target version.
It can be understood that, when the attribute information of the first method is incorrect and the computer device cannot acquire a method with the attribute information being the same as the attribute information of the first method from the first code packets of the M versions, the computer device reduces the search condition and determines the method most similar to the first method according to the name similarity, so that the computer device can determine the first code packet of the target version.
Based on the technical scheme shown in fig. 3, when none of the M versions of the first code packets includes a method whose attribute information is the same as the attribute information of the first method, the computer device reduces the search condition, searches for a method similar to the first method, and determines the method with the highest name similarity (i.e., the method with the highest similarity to the first method), thereby avoiding the problem that the first code packet of the target version cannot be determined if the attribute information of the first method is incorrect.
After the computer device determines the target version of the first code package, the script code in the first code package also references a second code package containing a referenced version of the second method. And the second code packet has a plurality of versions, and if the reference version of the second code packet cannot be determined, the computer equipment still has the risk of referring to the code packet with the wrong version, so that the script code cannot jump normally, and the problem of abnormal running of the script code is caused.
In order to avoid the problem that a script code cannot jump normally due to the reference of a code packet with an incorrect version, as shown in fig. 4, a method for referencing a code packet provided by an embodiment of the present application includes the following steps:
s401, the computer device determines the name of the second code packet called by the first method and attribute information of the second method.
In one possible implementation, the computer device parses the first code packet of the target version, and determines the name of the second code packet called by the first method and the attribute information of the second method.
Wherein the first code package of the target version includes a name of the second code package and attribute information of the second method. The attribute information of the second method includes: the name of the second method, the parameter type of the second method, the number of parameters of the second method, the second, the return value type of the method.
S402, the computer equipment determines P versions of second code packages according to the names of the second code packages.
Wherein P is a positive integer.
In one possible implementation, the computer device reads the environment variable and finds the second code packages of the P versions according to the names of the second code packages. The environment variable includes P versions of the second code package installed by the computer device.
S403, the computer device determines the second code package of the reference version from the second code packages of the P versions according to the attribute information of the second method.
Wherein the second code package of the referenced version includes a second method.
In one possible implementation, the computer device checks whether the kth version of the second code package contains a method whose attribute information is the same as the attribute information of the second method. When the kth version of the second code package contains a method whose attribute information is the same as the attribute information of the second method, the computer device determines the kth version of the second code package as a reference version of the second code package. Wherein the kth version is one of the P versions.
The specific implementation of this method can refer to the descriptions of steps S201-S202, which are not described herein again.
In another possible implementation manner, when none of the second code packages of the P versions contains a method whose attribute information is the same as the attribute information of the second method, the computer device calculates the name similarity between each of the Q methods and the second method. The computer device determines the method with the highest name similarity from the Q methods. The computer device takes the second code package containing the method with the highest name similarity as the second code package of the referenced version. Wherein, the Q methods are all methods included in the second code packet of the P versions.
For specific implementation, reference may be made to the description of steps S301 to S303, which is not described herein again.
S404, the computer device indicates the script code to refer to the second code packet of the reference version.
It will be appreciated that since the second code package of the referenced version includes the second method, the computer device instructs the script code to reference the second code package of the referenced version, which may enable normal jumping of the script code from the first method to the second method in the second code package of the referenced version.
Based on the technical scheme shown in fig. 4, the computer device can determine the second code package of the referenced version (which includes the second method) from the second code packages of the P versions, which solves the problem that the computer device cannot determine which version of the second code package has the second method and cannot determine the second code package of the referenced version. Moreover, the first code packet of the target version comprises the first method, so that the script codes quote the first code packet of the target version, normal jumping of the script codes to the first method in the first code packet can be realized, and the script codes can run normally.
It should be noted that the embodiment shown in fig. 4 is a process for referencing a second code package (a second code package of a referenced version) to a first code package, and is specifically described. However, the scripting code in the second code package may also reference the third method in the third code package, and the computer device cannot determine which version of the third code package exists with the third method. That is, when a code package refers to a code package, there is a problem that the code package of the reference version cannot be determined. Thus, the embodiment shown in FIG. 4 may be referenced when a code package references a code package.
In the embodiment of the present application, the server may be divided into the functional modules or the functional units according to the above method examples, for example, each functional module or functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated module may be implemented in a form of hardware, or may be implemented in a form of a software functional module or a functional unit. The division of the modules or units in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
As shown in fig. 5, an embodiment of the present invention provides a device for referencing a code package, including:
the analysis unit 101 is used for analyzing the script codes and determining the names of the first code packets referred by the script codes and the attribute information of the first method;
the processing unit 102 is configured to find the first code packages of M versions according to names of the first code packages, where M is a positive integer; according to the attribute information of the first method, determining a first code packet of a target version from first code packets of M versions, wherein the first code packet of the target version comprises the first method;
and the reference unit 103 is used for indicating the script code to reference the first code package of the target version.
Optionally, the processing unit 102 is further configured to check whether the first code packet of the ith version contains a method whose attribute information is the same as the attribute information of the first method, where the ith version is any one of M versions, and i is a positive integer less than or equal to M; and if the first code packet of the ith version contains the method with the attribute information being the same as the attribute information of the first method, determining that the first code packet of the ith version is the first code packet of the target version.
Optionally, the processing unit 102 is further configured to calculate a name similarity between each of the N methods and the first method if none of the M versions of the first code packages includes a method whose attribute information is the same as the attribute information of the first method, where the name similarity is used to indicate a similarity between the two methods on the name, and the N methods are all methods included in the M versions of the first code packages; determining a method with the highest name similarity from the N methods; and taking the first code packet containing the method with the highest name similarity as the first code packet of the target version.
Optionally, the parsing unit 101 further determines a name of the second code packet called by the first method and attribute information of the second method;
the processing unit 102 is further configured to determine, according to names of second code packets, P versions of the second code packets, where P is a positive integer; determining a second code packet of a reference version from the second code packets of the P versions according to the attribute information of the second method; the second code package of the referenced version includes the second method;
and the reference unit 103 is also used for indicating the script code to reference the second code package of the reference version.
Fig. 6 shows yet another possible structure of the computer device involved in the above-described embodiment. The computer device includes: a processor 201 and a communication interface 202. The processor 201 is used to control and manage the actions of the device, for example, to perform the various steps in the method flows shown in the above-described method embodiments, and/or to perform other processes for the techniques described herein. The communication interface 202 is used to support communication of the computer device with other network entities. The computer device may further comprise a memory 203 and a bus 204, the memory 203 being used for storing program codes and data of the apparatus.
The processor 201 may implement or execute various exemplary logical blocks, units and circuits described in connection with the present disclosure. The processor may be a central processing unit, general purpose processor, digital signal processor, application specific integrated circuit, field programmable gate array or other programmable logic device, transistor logic device, hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, units, and circuits described in connection with the present disclosure. A processor may also be a combination of computing functions, e.g., comprising one or more microprocessors, a DSP and a microprocessor, or the like.
Memory 203 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, a hard disk, or a solid state disk; the memory may also comprise a combination of memories of the kind described above.
The bus 204 may be an Extended Industry Standard Architecture (EISA) bus or the like. The bus 204 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 6, but this is not intended to represent only one bus or type of bus.
Through the above description of the embodiments, it is clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions. For the specific working processes of the system, the apparatus and the unit described above, reference may be made to the corresponding processes in the foregoing method embodiments, and details are not described here again.
Embodiments of the present application provide a computer program product containing instructions that, when run on a computer, cause the computer to perform the method of referencing the code package in the above-described method embodiments.
The present application further provides a computer-readable storage medium, in which instructions are stored, and when the instructions are executed on a computer, the computer is caused to execute a method for referencing a code package in a method flow shown in the above method embodiment.
The computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM), a register, a hard disk, an optical fiber, a portable Compact Disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, any suitable combination of the above, or any other form of computer readable storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an Application Specific Integrated Circuit (ASIC). In embodiments of the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
Since the computer device, the computer-readable storage medium, and the computer program product in the embodiments of the present invention may be applied to the method described above, for technical effects that can be obtained by the method, reference may also be made to the method embodiments described above, and details of the embodiments of the present invention are not described herein again.
The above is only an embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1.一种代码包的引用方法,其特征在于,所述方法包括:1. a reference method of code package, is characterized in that, described method comprises: 解析脚本代码,确定所述脚本代码所引用的第一代码包的名称和第一方法的属性信息;Parse the script code, and determine the name of the first code package and the attribute information of the first method referenced by the script code; 根据所述第一代码包的名称,查找到M个版本的第一代码包,M为正整数;According to the name of the first code package, find M versions of the first code package, where M is a positive integer; 根据所述第一方法的属性信息,从所述M个版本的第一代码包中,确定目标版本的第一代码包,所述目标版本的第一代码包包括所述第一方法;According to the attribute information of the first method, the first code package of the target version is determined from the M versions of the first code package, and the first code package of the target version includes the first method; 指示所述脚本代码引用所述目标版本的第一代码包。The script code is instructed to reference the target version of the first code package. 2.根据权利要求1所述的代码包的引用方法,其特征在于,所述根据所述第一方法的属性信息,从所述M个版本的第一代码包中,确定目标版本的第一代码包,包括:2. The method for quoting a code package according to claim 1, wherein, according to the attribute information of the first method, from the first code packages of the M versions, the first code package of the target version is determined. Code package, including: 检查第i个版本的第一代码包是否包含属性信息与所述第一方法的属性信息相同的方法,所述第i个版本为所述M个版本中的任意一个版本,i为小于等于M的正整数;Check whether the i-th version of the first code package contains the same attribute information as that of the first method, the i-th version is any one of the M versions, and i is less than or equal to M positive integer of ; 若所述第i个版本的第一代码包包含属性信息与所述第一方法的属性信息相同的方法,则确定所述第i个版本的第一代码包为所述目标版本的第一代码包。If the first code package of the i-th version contains a method whose attribute information is the same as that of the first method, then determine that the first code package of the i-th version is the first code of the target version Bag. 3.根据权利要求2所述的代码包的引用方法,其特征在于,所述第一方法的属性信息包括所述第一方法的名称;3. The method for quoting a code package according to claim 2, wherein the attribute information of the first method comprises the name of the first method; 所述根据所述第一方法的属性信息,从所述M个版本的第一代码包中,确定目标版本的第一代码包,包括:The determining of the first code package of the target version from the M versions of the first code package according to the attribute information of the first method includes: 若所述M个版本的第一代码包均不包括属性信息与所述第一方法的属性信息相同的方法,则计算N个方法中每一个方法与所述第一方法的名称相似度,所述名称相似度用于指示两个方法在名称上的相似程度,所述N个方法为所述M个版本的第一代码包所包括的全部方法;If none of the M versions of the first code package includes a method whose attribute information is the same as the attribute information of the first method, then calculate the name similarity between each of the N methods and the first method, so The name similarity is used to indicate the similarity of the names of the two methods, and the N methods are all methods included in the M versions of the first code package; 从所述N个方法中,确定名称相似度最高的方法;From the N methods, determine the method with the highest name similarity; 以包含所述名称相似度最高的方法的第一代码包作为所述目标版本的第一代码包。The first code package containing the method with the highest similarity in name is used as the first code package of the target version. 4.根据权利要求1至3任一项所述的代码包的引用方法,其特征在于,所述方法还包括:4. The method for citing a code package according to any one of claims 1 to 3, wherein the method further comprises: 确定所述第一方法所调用的第二代码包的名称和第二方法的属性信息;determining the name of the second code package called by the first method and the attribute information of the second method; 根据所述第二代码包的名称,确定P个版本的第二代码包,P为正整数;According to the name of the second code package, determine P versions of the second code package, where P is a positive integer; 根据所述第二方法的属性信息,从所述P个版本的第二代码包中,确定引用版本的第二代码包;所述引用版本的第二代码包包括所述第二方法;According to the attribute information of the second method, from the second code packages of the P versions, determine the second code package of the reference version; the second code package of the reference version includes the second method; 指示所述脚本代码引用所述引用版本的第二代码包。The script code is instructed to reference the referenced version of the second code package. 5.一种代码包的引用装置,其特征在于,所述装置包括:5. A reference device for a code package, wherein the device comprises: 解析单元,用于解析脚本代码,确定所述脚本代码所引用的第一代码包的名称和第一方法的属性信息;a parsing unit, configured to parse the script code, and determine the name of the first code package referenced by the script code and the attribute information of the first method; 处理单元,用于根据所述第一代码包的名称,查找到M个版本的第一代码包,M为正整数;根据所述第一方法的属性信息,从所述M个版本的第一代码包中,确定目标版本的第一代码包,所述目标版本的第一代码包包括所述第一方法;a processing unit, configured to find M versions of the first code package according to the name of the first code package, where M is a positive integer; In the code package, the first code package of the target version is determined, and the first code package of the target version includes the first method; 引用单元,用于指示所述脚本代码引用所述目标版本的第一代码包。The reference unit is used to instruct the script code to refer to the first code package of the target version. 6.根据权利要求5所述的代码包的引用装置,其特征在于,6. The reference device of the code package according to claim 5, is characterized in that, 所述处理单元,还用于检查第i个版本的第一代码包是否包含属性信息与所述第一方法的属性信息相同的方法,所述第i个版本为所述M个版本中的任意一个版本,i为小于等于M的正整数;若所述第i个版本的第一代码包包含属性信息与所述第一方法的属性信息相同的方法,则确定所述第i个版本的第一代码包为所述目标版本的第一代码包。The processing unit is further configured to check whether the i-th version of the first code package contains a method whose attribute information is the same as that of the first method, and the i-th version is any of the M versions. A version, i is a positive integer less than or equal to M; if the first code package of the i-th version contains a method whose attribute information is the same as that of the first method, then determine the i-th version of the first code package. A code package is the first code package of the target version. 7.根据权利要求6所述的代码包的引用装置,其特征在于,7. The reference device of the code package according to claim 6, wherein, 所述处理单元,还用于若所述M个版本的第一代码包均不包括属性信息与所述第一方法的属性信息相同的方法,则计算N个方法中每一个方法与所述第一方法的名称相似度,所述名称相似度用于指示两个方法在名称上的相似程度,所述N个方法为所述M个版本的第一代码包所包括的全部方法;从所述N个方法中,确定名称相似度最高的方法;以包含所述名称相似度最高的方法的第一代码包作为所述目标版本的第一代码包。The processing unit is further configured to, if none of the M versions of the first code package includes a method whose attribute information is the same as that of the first method, calculate the difference between each of the N methods and the first code package. The name similarity of a method, the name similarity is used to indicate the similarity in names of two methods, and the N methods are all methods included in the M versions of the first code package; from the Among the N methods, the method with the highest name similarity is determined; the first code package including the method with the highest name similarity is used as the first code package of the target version. 8.根据权利要求5-7任一项所述的代码包的引用装置,其特征在于,8. The reference device of the code package according to any one of claims 5-7, characterized in that, 所述解析单元,还用确定所述第一方法所调用的第二代码包的名称和第二方法的属性信息;The parsing unit is also used to determine the name of the second code package called by the first method and the attribute information of the second method; 所述处理单元,还用于根据所述第二代码包的名称,确定P个版本的第二代码包;根据所述第二方法的属性信息,从所述P个版本的第二代码包中,确定引用版本的第二代码包;所述引用版本的第二代码包包括所述第二方法;The processing unit is further configured to determine P versions of the second code package according to the name of the second code package; according to the attribute information of the second method, from the P versions of the second code package , determine the second code package of the reference version; the second code package of the reference version includes the second method; 所述引用单元,还用于指示所述脚本代码引用所述引用版本的第二代码包。The referencing unit is further configured to instruct the script code to refer to the second code package of the referenced version. 9.一种计算机设备,其特征在于,包括:处理器、存储器和通信接口;其中,所述通信接口和所述处理器耦合,当该计算机设备运行时,处理器执行该存储器存储的该计算机执行指令,以实现上述权利要求1-4任一项中的代码包的引用方法。9. A computer device, comprising: a processor, a memory, and a communication interface; wherein the communication interface is coupled to the processor, and when the computer device operates, the processor executes the computer stored in the memory The instruction is executed to implement the method of referencing the code package in any one of the above claims 1-4. 10.一种计算机可读存储介质,计算机可读存储介质中存储有指令,其特征在于,当计算机执行该指令时,该计算机执行上述权利要求1-4任一项中的代码包的引用方法。10. A computer-readable storage medium having instructions stored in the computer-readable storage medium, characterized in that, when the computer executes the instruction, the computer executes the method for citing the code package in any one of the preceding claims 1-4 .
CN202010284657.0A 2020-04-13 2020-04-13 Code package reference method and device Active CN113535178B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010284657.0A CN113535178B (en) 2020-04-13 2020-04-13 Code package reference method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010284657.0A CN113535178B (en) 2020-04-13 2020-04-13 Code package reference method and device

Publications (2)

Publication Number Publication Date
CN113535178A true CN113535178A (en) 2021-10-22
CN113535178B CN113535178B (en) 2024-12-10

Family

ID=78119855

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010284657.0A Active CN113535178B (en) 2020-04-13 2020-04-13 Code package reference method and device

Country Status (1)

Country Link
CN (1) CN113535178B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050081184A1 (en) * 2003-09-30 2005-04-14 International Business Machines Corporation Multi-attribute dynamic link library packaging
US20130007028A1 (en) * 2011-06-29 2013-01-03 International Business Machines Corporation Discovering related files and providing differentiating information
CN105446723A (en) * 2014-09-02 2016-03-30 国际商业机器公司 Method and device for identifying semantic difference between source code versions
US20160378445A1 (en) * 2015-06-26 2016-12-29 Mitsubishi Electric Corporation Similarity determination apparatus, similarity determination method and similarity determination program
WO2017151546A1 (en) * 2016-03-01 2017-09-08 650 Industries, Inc. Method and apparatus for loading multiple differing versions of a native library into a native environment
CN109542779A (en) * 2018-11-12 2019-03-29 泰康保险集团股份有限公司 Test method, device and storage medium
US20190114166A1 (en) * 2017-10-16 2019-04-18 Western Digital Technologies, Inc. Function tracking for source code files

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050081184A1 (en) * 2003-09-30 2005-04-14 International Business Machines Corporation Multi-attribute dynamic link library packaging
US20130007028A1 (en) * 2011-06-29 2013-01-03 International Business Machines Corporation Discovering related files and providing differentiating information
CN105446723A (en) * 2014-09-02 2016-03-30 国际商业机器公司 Method and device for identifying semantic difference between source code versions
US20160378445A1 (en) * 2015-06-26 2016-12-29 Mitsubishi Electric Corporation Similarity determination apparatus, similarity determination method and similarity determination program
WO2017151546A1 (en) * 2016-03-01 2017-09-08 650 Industries, Inc. Method and apparatus for loading multiple differing versions of a native library into a native environment
US20190114166A1 (en) * 2017-10-16 2019-04-18 Western Digital Technologies, Inc. Function tracking for source code files
CN109542779A (en) * 2018-11-12 2019-03-29 泰康保险集团股份有限公司 Test method, device and storage medium

Also Published As

Publication number Publication date
CN113535178B (en) 2024-12-10

Similar Documents

Publication Publication Date Title
CN107992307B (en) Method and device for compiling functions
CN111443921A (en) Subcontracting deployment method, system and computer equipment for web front-end project
US11262986B2 (en) Automatic software generation for computer systems
CN110502357A (en) A kind of stack retrogressive method, device, medium and equipment
WO2020237508A1 (en) Assertion validation code binding method and apparatus
WO2023207973A1 (en) Compiler test method and apparatus, case generation method and apparatus, and instruction storage structure
CN107797996B (en) Entry translation method and device
CN111240987B (en) Method and device for detecting migration program, electronic equipment and computer readable storage medium
CN115599359A (en) Code generation method, device, equipment and medium
WO2019227899A1 (en) Program calling decoupling
CN106502707B (en) Code generation method and device
CN111352631B (en) Interface compatibility detection method and device
CN107810474B (en) Automatic import and dependency in large-scale source code repository
CN113535178B (en) Code package reference method and device
CN105867886A (en) Method and device for writing table
CN112947941A (en) Method and device for adding exception handling code
CN103235745B (en) A kind of address conflict detecting method and device
CN110244954A (en) A kind of Compilation Method and equipment of application program
WO2023197851A9 (en) Abnormal component identification method and apparatus, device, storage medium, and program product
CN116578282A (en) Code generation method, device, electronic equipment and medium
CN113986744A (en) Method and device for testing warehouse and table components and storage medium
US9063758B2 (en) Population of dynamic objects representing static namespace hierarchies
CN112445390B (en) Submenu selection method and device and terminal equipment
CN111726373B (en) Communication link construction method, device and equipment
CN118886404A (en) Pagination form verification method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant