Specific embodiment
In order that those skilled in the art more fully understand the technical scheme in the application, below in conjunction with this
Accompanying drawing in application embodiment, is clearly and completely described to the technical scheme in the embodiment of the present application,
Obviously, described embodiment is only some embodiments of the present application, rather than whole embodiments.Base
Embodiment in the application, those of ordinary skill in the art are obtained under the premise of creative work is not made
The every other embodiment for obtaining, should all belong to the scope of the application protection.
Fig. 1 is the flow chart of the code process method in the embodiment of the application one.In the present embodiment, the generation
Code processing method comprises the following steps:
S110:Obtain block code corresponding with the module that current business is included.
Current business is the business of the current desired realization of software developer, and the current business can be comprising multiple
The module planned in advance, and there may be dependence between modules.Wherein, needing to realize certain
Before individual business, the module that can be included by the specified current business of software developer.For example, it is right
In current business X, the module that it is included can be { a, b, c, d, e }, then can be according to these modules point
Corresponding block code is not got.
It is described before obtaining block code corresponding with the module that current business is included in the embodiment of the present application
Method also includes:
According to the dependence between module, add corresponding with dependence in the block code of each module
Dependency Specification;The block code of each module is mapped and stored with the module id of the module.
As it was previously stated, there may be dependence between modules, these dependences can be by each
Corresponding Dependency Specification is added in the block code of module to realize.Such as:
/*global extend*/
// rely on extend
function ajax(settings){
…
}
In the block code of above-mentioned example, then can be by Dependency Specification "/* global extend*/"
To realize that the module " ajax " depends on module " extend ".
Add corresponding dependence in the block code of the module that there is dependence respectively according to the method described above
Information, and assign each module of the division with different module id ID (such as above-mentioned " ajax ",
" extend "), then the block code of each module is corresponded with the module id of the module.Most at last this
Block code after a little addition Dependency Specifications is mapped with the module id ID of modules respectively, and is deposited
In storing up source code database.
As described above, in the present embodiment, step S110 is specifically included:
Receive the module id corresponding with the module that current business is included of user input.
According to the corresponding block code of the module id is inquired with current business is included module.
The user can be software developer, and system receives need of the software developer according to current business
Seek the module id corresponding with each module that current business is included of input.Then, system is according to receiving
The modules mark above-mentioned source code database of inquiry, the module corresponding with modules for being prestored
Code.Such as:The module id of input includes:" ajax ", " extend ", then system queries and module id
The block code of " ajax ", " extend " maps mutually.
S120:Extract the Dependency Specification included in the block code.
Specifically, the embodiment of the present application can be by the corresponding regular expression for extracting Dependency Specification of editor
(Regular Expression, RE) carrys out scan module code to obtain the Dependency Specification.
For example, it is above-mentioned by scanning if the module that current business X is included is { a, b, c, d, e }
The corresponding block code of module, the Dependency Specification included in the block code that can obtain module a is:“/*
Global a*/", the Dependency Specification included in the block code of module b is:"/* global c*/", module d
Block code in the Dependency Specification that includes be:"/* global b*/", includes in the block code of module e
Dependency Specification is:“/*global c*/”;Then, the corresponding dependence of above-mentioned Dependency Specification is as follows:
A depends on b, b to depend on c, d to depend on b, e to depend on c.
S130:The order of each module in current business is determined according to the Dependency Specification list, and according to institute
State order to merge the block code, obtain code file corresponding with the current business.
In the embodiment of the application one, after above-mentioned steps S120 and before step S130, methods described
Also include:
S140:Dependency Specification list corresponding with current business is determined according to the Dependency Specification for extracting.Wherein,
The Dependency Specification list is the dependence obtained according to extraction, by each module of current business according to certain
Order is ranked up.
Continue to continue to use above-mentioned example, if the module that current business X is included is { a, b, c, d, e }, and lead to
Crossing the Dependency Specification extracted in each block code can obtain following dependences:A depends on b, b to depend on
C, d depend on b, e to depend on c.Then, the sequence of modules that can be obtained in Dependency Specification list is:[a,
B, c], [d, b], [e, c], then, merged by by above-mentioned sequence of modules, obtain Dependency Specification
Sequence of modules in list is:[a, b, c, d, b, e, c].
Fig. 2 is each module determined according to the Dependency Specification in current business in the embodiment of the application one
The flow chart of the method for the step of order.Based on above-mentioned steps, step S130 is specifically included:
S1301:Judge to whether there is unnecessary module id in the Dependency Specification list.
Above-mentioned example is continued to use, the sequence of modules in the Dependency Specification list for obtaining is:[a, b, c, d, b, e,
C], it is seen then that there is unnecessary module id in the Dependency Specification list:B, c, that is to say, that a mould
Block identification can only occur once in Dependency Specification list.
S1302:If so, the unnecessary module id is deleted.
In the above example, by unnecessary module id:B, c make delete processing, the dependence after being deleted
Sequence of modules in information list is:[a, d, b, e, c].
S1303:By the module id in the Dependency Specification list for deleting the unnecessary module id
Order carries out inverted order arrangement, and the order of the module id after inverted order is arranged is defined as each mould in current business
The order of block.
In the above example, in the code file for being generated due to final merging, the block code needs being relied on
Position forward in code file is placed in, therefore, the present embodiment can be to the Dependency Specification list after above-mentioned deletion
In sequence of modules:[a, d, b, e, c] makees inverted order arrangement, and module id after inverted order is arranged is suitable
Sequence:[c, e, b, d, a] is defined as the order of each module in current business.
The block code that the secondary ordered pair inquiry of each module that may finally be in above-mentioned current business is obtained is entered
Row merges, and obtains code file corresponding with current business.
For example, if the block code of module a is:
/*global b*/
// rely on b
function a(settings){
…
}
If the block code of module b is:
/*global c*/
// rely on c
function b(settings){
…
}
If the block code of module c is:
function c(settings){
…
}
If the block code of module d is:
/*global b*/
// rely on b
function d(settings){
…
}
If the block code of module e is:
/*global c*/
// rely on c
function e(settings){
…
}
Then according to the order of the above-mentioned each module being defined as in current business, above-mentioned each block code is closed
And after, obtaining final code file is:
function c(settings){
…
}
/*global c*/
// rely on c
function e(settings){
…
}
/*global c*/
// rely on c
function b(settings){
…
}
/*global b*/
// rely on b
function d(settings){
…
}
/*global b*/
// rely on b
function a(settings){
…
}
It is worth addressing, the order of each module in above-mentioned current business is not unique, and part is not deposited
Order between the module of relation of interdependence can be overturned, such as:In [c, e, b, d, a], a and
The order of e can be exchanged mutually.Additionally, in actual applications, it is understood that there may be certain module and other modules
And in the absence of any dependence (also not including Dependency Specification in the block code of the module), then final
During merging code file, can there is no the block code of dependence to be inserted in this and finally merge
To code file in optional position.
In another embodiment of the application, on the premise of no above-mentioned steps S140, in above-mentioned steps S130
The order that each module in current business is determined according to the Dependency Specification the step of, as shown in figure 3, tool
Body includes:
S1304:According to the Dependency Specification, first module id and Depending module of depended module are determined
The second module id.
Continue to continue to use above-mentioned example, if the module that current business X is included is { a, b, c, d, e }, and lead to
Crossing the Dependency Specification extracted in each block code can obtain following dependences:A depends on b, b to depend on
C, d depend on b, e to depend on c.Wherein, depended module includes:B, c, Depending module include:a、
b、d、e。
S1305:Judge to whether there is first module id or second module in default race-card
Mark.
In the present embodiment, system pre-sets a race-card, with the presence dependence that will be determined successively
Module id is inserted into the race-card.
S1306:If there is first module id and do not exist second module id, will be described
Second module id is placed in after first module id.
S1307:If there is second module id and do not exist first module id, will be described
Before first module id is placed in second module id.
By above-mentioned steps S1306 and step S1307, the insertion sequence of the module id in above-mentioned race-card
It is as follows:
Originally, race-card is sky, and the depended module in " a depends on b " is b, and Depending module is a,
Then it is inserted into race-card in the posterior order of preceding, Depending module according to depended module, obtains race-card:
[b、a];
Subsequently, for " b depends on c ", depended module is c, and Depending module is b, by judging,
It can be found that there is b (meeting the situation of step S1307) in above-mentioned race-card, then module c is planted
Before module b, race-card is obtained:
[c、b、a];
For " d depends on b ", depended module is b, and Depending module is d, by judging, Ke Yifa
There is b (meeting the situation of step S1306) in existing above-mentioned race-card, then module d has been inserted in module
After b, race-card is obtained:
[c、b、d、a];
For " e depends on c ", depended module is c, and Depending module is e, by judging, it can be found that
There is c (meeting the situation of step S1306) in above-mentioned race-card, then module e has been inserted in module c
Afterwards, race-card is obtained:
[c、e、b、d、a]。
So far, the order that the module id in final race-card can be determined as procedure described above is current industry
The order of corresponding each module of being engaged in.Then, institute is merged according to the order of the module id included in the race-card
Block code is stated, code file corresponding with the current business is obtained.
In the embodiment of the present application, more simplified in order that obtaining and finally merging the code file for obtaining, also included:
It is determined that the annotation information that includes and being deleted in the block code after merging.The annotation information includes
But it is not limited to:Annotation etc. for describing dependence, for example:" // rely on extend ".
Corresponding with above method flow, embodiments herein additionally provides a kind of device of code process.
The device can be realized by software, it is also possible to be realized by way of hardware or software and hardware combining.With soft
It is by the central processing unit (Central of server as the device on logical meaning as a example by part is realized
Process Unit, CPU) corresponding computer program instructions are read run in internal memory what is formed.
The module diagram of the device of the code process that Fig. 4 is provided for the embodiment of the application one.Wherein, the dress
The function of putting each unit is similar with the function of each step in the above method, therefore the device is referred to above-mentioned side
The particular content of method embodiment.The device includes:
Acquiring unit 401, for obtaining block code corresponding with the module that current business is included;
Extraction unit 402, for extracting the Dependency Specification included in the block code;
Determining unit 403, the order for determining each module in current business according to the Dependency Specification,
And the order according to the module merges the block code, code text corresponding with the current business is obtained
Part.
Such as the shown device of Fig. 4, in the embodiment of the present application, the device also includes:
Memory cell, for according to the dependence between module, in the block code of each module addition with
The corresponding Dependency Specification of dependence;The block code of each module is mapped with the module id of the module
And store;
Then, the acquiring unit 401 specifically for:
Receive the module id corresponding with the module that current business is included of user input;
According to the corresponding block code of the module id is inquired with current business is included module.
Such as the shown device of Fig. 4, in the embodiment of the present application, the device also includes:
List generation unit, for determining Dependency Specification corresponding with current business according to the Dependency Specification for extracting
List;
Then, the determining unit 403 is specifically included:
First judging unit, for judging to whether there is unnecessary module id in the Dependency Specification list;
Unit is deleted, if there is unnecessary module id in the Dependency Specification list, will be described unnecessary
Module id is deleted;
Order determining unit, for by the Dependency Specification list for deleting the unnecessary module id
The order of module id carries out inverted order arrangement, and the order of the module id after inverted order is arranged is defined as current industry
The order of each module in business.
Such as the shown device of Fig. 4, in the embodiment of the present application, the determining unit 403 is specifically included:
Determining unit is relied on, for according to the Dependency Specification, determining the first module id of depended module
With the second module id of Depending module;
Second judging unit, for judging to whether there is first module id or institute in default race-card
State the second module id;
Sequencing unit, does not exist second module for there is first module id in race-card
During mark, second module id is placed in after first module id;There is institute in race-card
When stating the second module id and not existing first module id, first module id is placed in described
Before second module id;Order according to the module id included in the race-card merges the module generation
Code, obtains code file corresponding with the current business.
Such as the shown device of Fig. 4, in the embodiment of the present application, the device also includes:
Annotation deletes unit, and the annotation information included in the block code after merging for determination is simultaneously deleted
Remove.
The technical scheme provided from above the embodiment of the present application, the embodiment of the present application by get with
After the corresponding block code of module that current business is included, the dependence letter included in the block code is extracted
Breath, and the order of each module in current business is determined according to the Dependency Specification, finally according to the order
The block code is merged, code file corresponding with the current business is obtained.In above procedure,
The Dependence Problem for introducing specific code dependence framework to solve each module is avoided passing through, so that final close
And the code file for obtaining more is simplified.
System, device, module or unit that above-described embodiment is illustrated, specifically can be by computer chip or reality
Body is realized, or is realized by the product with certain function.
For convenience of description, it is divided into various units with function during description apparatus above to describe respectively.Certainly,
The function of each unit can be realized in same or multiple softwares and/or hardware when the application is implemented.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or meter
Calculation machine program product.Therefore, the present invention can be using complete hardware embodiment, complete software embodiment or knot
Close the form of the embodiment in terms of software and hardware.And, the present invention can be used and wherein wrapped at one or more
Containing computer usable program code computer-usable storage medium (including but not limited to magnetic disk storage,
CD-ROM, optical memory etc.) on implement computer program product form.
The present invention is produced with reference to method according to embodiments of the present invention, equipment (system) and computer program
The flow chart and/or block diagram of product is described.It should be understood that can by computer program instructions realize flow chart and
/ or block diagram in each flow and/or the flow in square frame and flow chart and/or block diagram and/
Or the combination of square frame.These computer program instructions to all-purpose computer, special-purpose computer, insertion can be provided
The processor of formula processor or other programmable data processing devices is producing a machine so that by calculating
The instruction of the computing device of machine or other programmable data processing devices is produced for realizing in flow chart one
The device of the function of being specified in individual flow or multiple one square frame of flow and/or block diagram or multiple square frames.
These computer program instructions may be alternatively stored in can guide computer or the treatment of other programmable datas to set
In the standby computer-readable memory for working in a specific way so that storage is in the computer-readable memory
Instruction produce include the manufacture of command device, the command device realization in one flow of flow chart or multiple
The function of being specified in one square frame of flow and/or block diagram or multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices, made
Obtain and series of operation steps is performed on computer or other programmable devices to produce computer implemented place
Reason, so as to the instruction performed on computer or other programmable devices is provided for realizing in flow chart one
The step of function of being specified in flow or multiple one square frame of flow and/or block diagram or multiple square frames.
In a typical configuration, computing device includes one or more processors (CPU), input/defeated
Outgoing interface, network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory
And/or the form, such as read-only storage (ROM) or flash memory (flash RAM) such as Nonvolatile memory (RAM).
Internal memory is the example of computer-readable medium.
Computer-readable medium includes that permanent and non-permanent, removable and non-removable media can be by appointing
What method or technique realizes information Store.Information can be computer-readable instruction, data structure, program
Module or other data.The example of the storage medium of computer includes, but are not limited to phase transition internal memory
(PRAM), static RAM (SRAM), dynamic random access memory (DRAM), its
The random access memory (RAM) of his type, read-only storage (ROM), electrically erasable are read-only
Memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage
(CD-ROM), digital versatile disc (DVD) or other optical storages, magnetic cassette tape, tape magnetic
Disk storage or other magnetic storage apparatus or any other non-transmission medium, can be used for storage can be calculated
The information that equipment is accessed.Defined according to herein, computer-readable medium does not include temporary computer-readable matchmaker
Body (transitory media), such as data-signal and carrier wave of modulation.
Also, it should be noted that term " including ", "comprising" or its any other variant be intended to non-row
His property is included, so that process, method, commodity or equipment including a series of key elements not only include
Those key elements, but also other key elements including being not expressly set out, or also include for this process,
Method, commodity or the intrinsic key element of equipment.In the absence of more restrictions, by sentence " including
One ... " key element that limits, it is not excluded that in the process including the key element, method, commodity or set
Also there is other identical element in standby.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer journey
Sequence product.Therefore, the application can using complete hardware embodiment, complete software embodiment or combine software and
The form of the embodiment of hardware aspect.And, the application can be used and wherein include calculating at one or more
Machine usable program code computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM,
Optical memory etc.) on implement computer program product form.
The application can be described in the general context of computer executable instructions, example
Such as program module.Usually, program module includes performing particular task or realizes particular abstract data type
Routine, program, object, component, data structure etc..This can also in a distributed computing environment be put into practice
Application, in these DCEs, by the remote processing devices connected by communication network come
Execution task.In a distributed computing environment, program module may be located at including local including storage device
In remote computer storage medium.
Each embodiment in this specification is described by the way of progressive, identical phase between each embodiment
As part mutually referring to, what each embodiment was stressed be it is different from other embodiment it
Place.For especially for system embodiment, because it is substantially similar to embodiment of the method, so description
Fairly simple, the relevent part can refer to the partial explaination of embodiments of method.
Embodiments herein is the foregoing is only, the application is not limited to.For this area skill
For art personnel, the application can have various modifications and variations.All institutes within spirit herein and principle
Any modification, equivalent substitution and improvements of work etc., within the scope of should be included in claims hereof.