CN107506304A - Code detection method, device, electronic equipment and storage medium - Google Patents
Code detection method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN107506304A CN107506304A CN201710737174.XA CN201710737174A CN107506304A CN 107506304 A CN107506304 A CN 107506304A CN 201710737174 A CN201710737174 A CN 201710737174A CN 107506304 A CN107506304 A CN 107506304A
- Authority
- CN
- China
- Prior art keywords
- node
- code
- internationalization
- detected
- correlation technique
- 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.)
- Pending
Links
- 238000001514 detection method Methods 0.000 title claims abstract description 46
- 238000000034 method Methods 0.000 claims abstract description 179
- 238000004458 analytical method Methods 0.000 claims abstract description 41
- 230000015654 memory Effects 0.000 claims description 19
- 230000000877 morphologic effect Effects 0.000 claims description 7
- 230000004048 modification Effects 0.000 claims description 6
- 238000012986 modification Methods 0.000 claims description 6
- 230000008859 change Effects 0.000 claims description 4
- 238000004590 computer program Methods 0.000 claims description 3
- 238000012545 processing Methods 0.000 description 12
- 210000004027 cell Anatomy 0.000 description 7
- 238000010586 diagram Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 7
- 238000004891 communication Methods 0.000 description 5
- 238000011161 development Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000006978 adaptation Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 238000007689 inspection Methods 0.000 description 2
- 230000005291 magnetic effect Effects 0.000 description 2
- 239000000463 material Substances 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 239000000470 constituent Substances 0.000 description 1
- 238000007796 conventional method Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 235000013399 edible fruits Nutrition 0.000 description 1
- 230000005611 electricity Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000008439 repair process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 210000000352 storage cell Anatomy 0.000 description 1
- 238000005728 strengthening Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/362—Debugging of software
- G06F11/366—Debugging of software using diagnostics
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The disclosure is directed to a kind of code detection method, device, electronic equipment and storage medium, applied to Developing International Software, is related to technical field of software development.This method includes:Code to be detected is parsed to generate the abstract syntax tree of code to be detected;Each node of ergodic abstract syntax tree, and semantic analysis is carried out to each node to judge that each node whether there is the method for not meeting internationalization and calling;And the node to the method for not meeting internationalization calling be present is prompted.The disclosure can improve code detection efficiency, help developer to find potential Internationalizationof in code as soon as possible, save the cost spent after software issue on solving Internationalizationof, improve software development efficiency.
Description
Technical field
This disclosure relates to technical field of software development, is filled in particular to a kind of code detection method, code detection
Put, electronic equipment and computer-readable recording medium.
Background technology
With the popularization of cyber-net worldwide, the internationalization of software is increasingly becoming in software development must not
The link that can lack.International Software refers to during software design and development so that software function and Code Design can
Adapt to multiple countries and multilingual.
Due to the polymorphism of the parameter of programming language, developer is in IDE (IDE, Integrated
Development Environment) it is inner when writing code, often neglect it is some for language/region (locale) and
The internationalization method of calling of the sensitive function of character set (charset) or method, often using default method of calling, this is just
Easily software is caused to occur substantial amounts of Internationalizationof after reaching the standard grade.In a kind of technical scheme, by the way of regular expression
Enter line code internationalization detection to the code to be detected finished writing, but this mode is that directly the code finished writing is scanned,
Not only cause detection efficiency low, and rate of false alarm is higher.
Accordingly, it is desirable to provide a kind of code detection method that can solve the problem that one or more of above mentioned problem problem, generation
Code detection means, electronic equipment and computer-readable recording medium.
It should be noted that information is only used for strengthening the reason to the background of the disclosure disclosed in above-mentioned background section
Solution, therefore can include not forming the information to prior art known to persons of ordinary skill in the art.
The content of the invention
The purpose of the disclosure is to provide a kind of code detection method, code detecting apparatus, electronic equipment and computer
Readable storage medium storing program for executing, so at least overcome to a certain extent caused by the limitation of correlation technique and defect one or
Multiple problems.
According to an aspect of this disclosure, there is provided a kind of code detection method, applied to Developing International Software, bag
Include:
Code to be detected is parsed to generate the abstract syntax tree of the code to be detected;
Each node of the abstract syntax tree is traveled through, and semantic analysis is carried out to each node to judge that each node whether there is
The method that internationalization calls is not met;And
The node that the method that internationalization calls is not met to existing is prompted.
In a kind of exemplary embodiment of the disclosure, semantic analysis is carried out to each node to judge that each node whether there is
Not meeting the method that internationalization calls includes:
Semantic analysis is carried out to each node to judge whether the method for each node belongs to internationalization correlation technique;
If the method for node belongs to the internationalization correlation technique, judge whether the parameter of the method for the node accords with
Close the parameter type of the internationalization correlation technique;
If the parameter of the method for the node do not meet it is described internationalization correlation technique parameter type, judge described in
The method that internationalization calls that do not meet be present in node.
In a kind of exemplary embodiment of the disclosure, the internationalization correlation technique includes language correlation technique, region
One or more in correlation technique and character set correlation technique.
In a kind of exemplary embodiment of the disclosure, carry out semantic analysis to each node is to judge the method for each node
The no internationalization correlation technique that belongs to includes:
Whether the method based on each node of preset matching rule judgment of each method in the code to be detected belongs to international
Change correlation technique.
In a kind of exemplary embodiment of the disclosure, the code detection method also includes:
The preset matching rule of each method in the code to be detected is set by extensible markup language.
In a kind of exemplary embodiment of the disclosure, the node that the method that internationalization calls is not met to existing carries
Show including:
In IDE there is the node for not meeting the method that internationalization calls in distinctiveness display.
In a kind of exemplary embodiment of the disclosure, code to be detected is parsed to generate the abstract of the code to be detected
Syntax tree includes:
Morphological analysis is carried out to code to be detected with syntactic analysis to generate the abstract syntax tree of the code to be detected.
In a kind of exemplary embodiment of the disclosure, there is the section for not meeting the method that internationalization calls in distinctiveness display
Point includes:
The node for not meeting the method that internationalization calls and corresponding modification prompting be present in distinctiveness display.
According to an aspect of this disclosure, there is provided a kind of code detecting apparatus, including:
Syntax tree generation unit, for parsing code to be detected to generate the abstract syntax tree of the code to be detected;
Travel through analytic unit, for traveling through each node of the abstract syntax tree, and each node is carried out semantic analysis with
Judge that each node whether there is the method that internationalization calls that do not meet;And
Tip element, the node for not meeting the method that internationalization calls to existing are prompted.
According to an aspect of this disclosure, there is provided a kind of electronic equipment, including
Processor;And
Memory, computer-readable instruction is stored with the memory, the computer-readable instruction is by the processing
The code detection method according to above-mentioned any one is realized when device performs.
According to an aspect of this disclosure, there is provided a kind of computer-readable recording medium, be stored thereon with computer journey
Sequence, the code detection method according to above-mentioned any one is realized when the computer program is executed by processor.
Code detection method, code detecting apparatus, electronic equipment in a kind of exemplary embodiment of the disclosure with
And computer-readable recording medium, code to be detected can be parsed to generate the abstract syntax tree of code to be detected;Ergodic abstract
Each node of syntax tree, judge that each node whether there is the method for not meeting internationalization and calling by semantic analysis;To existing not
The node for meeting the method that internationalization calls is prompted.On the one hand, code to be detected is parsed to generate taking out for code to be detected
As syntax tree, code to be detected can be converted into being easy to the tree data structure of computer disposal, so as to improve code
Detection efficiency;On the other hand, each node of ergodic abstract syntax tree, judge that each node whether there is by semantic analysis and do not meet
Internationalized the method called, and the method for each node can be detected exactly, so as to reduce rate of false alarm and fail to report
Rate;Another further aspect, the node that the method that internationalization calls is not met to existing are prompted, and can help developer as soon as possible
It was found that potential Internationalizationof in code, saves the cost spent after software issue in solution Internationalizationof, improves
Software development efficiency.
It should be appreciated that the general description and following detailed description of the above are only exemplary and explanatory, not
The disclosure can be limited.
Brief description of the drawings
Its example embodiment is described in detail by referring to accompanying drawing, the above and other feature and advantage of the disclosure will become
It is more obvious.
Fig. 1 diagrammatically illustrates the flow chart of the code detection method according to the exemplary embodiment of the disclosure one;
Fig. 2 diagrammatically illustrates the schematic diagram of the ergodic abstract syntax tree according to the exemplary embodiment of the disclosure one;
Fig. 3 diagrammatically illustrates the IDE of the code detection method for the exemplary embodiment for not using the disclosure
In code to be detected;
Fig. 4 shows that unlatching is using the code detection method of the exemplary embodiment of the disclosure one in IDE
The schematic diagram of plug-in unit;
Fig. 5 diagrammatically illustrates there is the signal of miscue according to the code to be detected of the exemplary embodiment of the disclosure one
Figure;
Fig. 6 diagrammatically illustrates the block diagram of the code detecting apparatus according to the exemplary embodiment of the disclosure one;
Fig. 7 diagrammatically illustrates the block diagram of the electronic equipment according to the exemplary embodiment of the disclosure one;
Fig. 8 diagrammatically illustrates the schematic diagram of the computer-readable recording medium according to the exemplary embodiment of the disclosure one.
Embodiment
Example embodiment is described more fully with referring now to accompanying drawing.However, example embodiment can be real in a variety of forms
Apply, and be not understood as limited to embodiment set forth herein;On the contrary, these embodiments are provided so that the disclosure will be comprehensively and complete
It is whole, and the design of example embodiment is comprehensively communicated to those skilled in the art.Identical reference represents in figure
Same or similar part, thus repetition thereof will be omitted.
In addition, described feature, structure or characteristic can be incorporated in one or more implementations in any suitable manner
In example.In the following description, there is provided many details fully understand so as to provide to embodiment of the disclosure.However,
It will be appreciated by persons skilled in the art that the technical scheme of the disclosure can be put into practice without one in the specific detail or more
It is more, or other methods, constituent element, material, device, step etc. can be used.In other cases, it is not shown in detail or describes
Known features, method, apparatus, realization, material are operated to avoid each side of the fuzzy disclosure.
Block diagram shown in accompanying drawing is only functional entity, not necessarily must be corresponding with physically separate entity.
I.e., it is possible to realize these functional entitys using software form, or these are realized in the module of one or more softwares hardening
A part for functional entity or functional entity, or realized in heterogeneous networks and/or processor device and/or microcontroller device
These functional entitys.
In this example embodiment, a kind of code detection method provide firstly.With reference to shown in figure 1, the code detection side
Method may comprise steps of:
Step S110. parses code to be detected to generate the abstract syntax tree of the code to be detected;
Step S120. travels through each node of the abstract syntax tree, and carries out semantic analysis to each node to judge each section
Point is with the presence or absence of the method for not meeting internationalization calling;And
The node that step S130. does not meet the method that internationalization calls to existing is prompted.
According to the code detection method in this example embodiment, on the one hand, parse code to be detected to generate generation to be detected
The abstract syntax tree of code, code to be detected can be converted into being easy to the tree data structure of computer disposal, so as to carry
High code detection efficiency;On the other hand, each node of ergodic abstract syntax tree, judge that each node whether there is by semantic analysis
The method that internationalization calls is not met, the method for each node can be detected exactly, so as to reduce rate of false alarm
And rate of failing to report;Another further aspect, the node that the method that internationalization calls is not met to existing are prompted, and can help developer
As soon as possible find code in potential Internationalizationof, save software issue after solve Internationalizationof spent into
This, improves software development efficiency.
Below, the code detection method in this example embodiment will be described in detail with reference to accompanying drawing.
In step s 110, code to be detected is parsed to generate the abstract syntax tree of the code to be detected.
In this exemplary embodiment, the abstract syntax tree (Abstract Syntax Tree, AST) of code to be detected is to treat
The tree-shaped form of expression of the abstract syntax structure of code is detected, code to be detected can be carried out by abstract syntax tree compiler
Parsing, code to be detected is converted into being easy to the tree of computer disposal.It is to be detected with writing for Java programming languages
Exemplified by code, code to be detected can be parsed by JJTree to generate the abstract syntax tree of code to be detected.
Further, in this exemplary embodiment, code to be detected is parsed to generate the abstract language of the code to be detected
Method tree can include:Morphological analysis is carried out to code to be detected with syntactic analysis to generate the abstract syntax of the code to be detected
Tree.Morphological analysis is that the character stream for forming generation detection code is scanned, and then identifies that word is (also referred to as single according to word-building rule
Word symbol or symbol).The task of syntactic analysis is that word sequence is combined into all kinds of grammatical phrases on the basis of morphological analysis,
Such as " program ", " sentence ", " expression formula " etc..In this exemplary embodiment, can will be to be checked by morphological analysis and syntactic analysis
Survey the data structure such as abstract syntax tree that code conversion is the tree class that access is easier in subsequent processes.
It should be noted that in this exemplary embodiment, code to be detected by taking the code that Java programming languages are write as an example,
But the code to be detected in the example embodiment of the disclosure can also be the code that the programming languages such as Python or C++ are write,
This is equally in the protection domain of the disclosure.
Next, travel through each node of the abstract syntax tree in step S120., and each node is carried out semantic analysis with
Judge that each node whether there is the method that internationalization calls that do not meet.
Shown in reference picture 2, in this exemplary embodiment, by taking Java programming languages as an example, code " String b1 to be detected
=newString (a);String b2=new String (a1, Charset.defaultCharset ());" can be solved
Analyse into abstract syntax tree as shown in Figure 2.Therefore, can the abstract syntax tree based on code to be detected to each section in Fig. 2
Point is traveled through, to judge that each node whether there is the method for not meeting internationalization and calling.
In this exemplary embodiment, semantic analysis is carried out to each node can include examining the type of the parameter of each node
Look into, the inspection of title of method to node etc., but the semantic analysis not limited to this in the example embodiment of the disclosure, example
Such as, semantic analysis can also include type checking of type of expression inspection, function or method etc., and this is equally in the disclosure
In protection domain.
Further, in this exemplary embodiment, semantic analysis is carried out to each node to judge each node with the presence or absence of not
Meeting the method that internationalization calls can include:Semantic analysis is carried out to each node to judge whether the method for each node belongs to state
Border correlation technique;If the method for node belongs to the internationalization correlation technique, the parameter of the method for the node is judged
Whether the parameter type of the internationalization correlation technique is met;If the parameter of the method for the node does not meet the internationalization
The parameter type of correlation technique, then judge that the node has the method that internationalization calls that do not meet.
In this exemplary embodiment, the correlation technique that internationalizes can be to function sensitive Locale and Charset or side
Method, internationalization correlation technique can include language correlation technique, region correlation technique and character set correlation technique, but this public affairs
Internationalization correlation technique not limited to this in the example embodiment opened, for example, internationalization correlation technique can also include with the date,
Currency or the relevant method of linear module etc., this is equally in the protection domain of the disclosure.It is to be checked by taking Java programming languages as an example
Surveying the internationalization correlation technique in each node of the abstract syntax tree of code can be including the method in table 1 below:
Internationalization correlation technique in table 1.Java programming languages
Illustrated by taking following three method as an example:
●DateFormat.getDateInstance(DateFormat.SHORT,<locale>).format(new
Date());
●String.getBytes(<Charset>);
●new String(<bytes[]>,<Charset>);
In above three method, the parameter related to locale and Charset is included in each method, therefore, this three
Individual method belongs to the correlation technique that internationalizes.When traveling through the abstract syntax tree of code to be detected, if the method for a certain node
For one of above three method, then need to judge whether the parameter of the method for the node meets the parameter type of the above method, such as
The parameter of the method for the fruit node does not meet the parameter type of the above method, then judges that the node is present and do not meet internationalization calling
Method.
Further, in this exemplary embodiment, semantic analysis is carried out to each node whether to judge the method for each node
Belonging to internationalization correlation technique can include:Each node of preset matching rule judgment based on each method in the code to be detected
Method whether belong to internationalization correlation technique.In this exemplary embodiment, extensible markup language can be passed through
(Extensible Markup Language, XML) sets the preset matching rule of each method in code to be detected.Citing and
Speech, for the String methods in the java.lang.* bags of a level, can set a matching in XML configuration file
The matched rule of String methods, the matched rule of String methods are as follows:<Rule Name=" String " Type="
Constructor " Pattern=" Key:None#Value:None " Locator=" Key:ASTNode#Value:
ClassInstanceCreation " Library=" String "></Rule>
In this exemplary embodiment, after in XML configuration file there is provided the configuration rule of String methods, traveling through
During each node in abstract syntax tree, the String in each node can be judged based on the matched rule of default String methods
Whether method belongs to internationalization correlation technique.As shown in Figure 2, the configuration of String methods is provided with XML configuration file
After rule, after String methods are traversed, whether the String methods that can judge to traverse based on the preset rules belong to
In internationalization correlation technique.
Next, in step s 130, the node that the method that internationalization calls is not met to existing is prompted.
Fig. 3 show do not use the disclosure example embodiment code detection method IDE (IDE,
Integrated Development Environment) in code to be detected.In figure 3, the 28th line code
Code table is not passed to according to Developing International specification in getBytes () method, but due to meeting the grammar request of compiler,
So IDE does not carry out any prompting to developer.Fig. 4, which shows to open in IDE, applies the example embodiment of the disclosure one
Code detection method plug-in unit schematic diagram.In Fig. 4, vGlobal is the code detection side using the present exemplary embodiment
The plug-in unit of method, it have selected and " after Turn On ", just start plug-in unit vGlobal.The plug-in unit is able to carry out this example embodiment
In code detection method.
Fig. 5 shows the code to be detected after the code detection method performed in this example embodiment.Can from Fig. 5
To find out, due to not being passed to code table according to Developing International specification in getBytes () method of the 28th line code, on the left side
The 28th row be marked as mistake, and be underlined below getByte () method of 28 rows, to be carried to developer
Show that this method does not meet the specification of Developing International.In addition, in Figure 5, additionally provide repair corresponding with getByte () method
Change prompting, such as figure 5 illustrates " I18n syntax error, charset need to be provided (I18n languages
Method mistake, it is desirable to provide character set) ".
It should be noted that although describing each step of method in the disclosure with particular order in the accompanying drawings, still,
This, which does not require that or implied, to perform these steps according to the particular order, or has to carry out the step shown in whole
Desired result could be realized.It is additional or alternative, it is convenient to omit some steps, multiple steps to be merged into a step and held
OK, and/or by a step execution of multiple steps etc. are decomposed into.
In addition, in this exemplary embodiment, additionally provide a kind of code detecting apparatus.Shown in reference picture 6, the code detection
Device 600 can include:Syntax tree generation unit 610, traversal analytic unit 620 and Tip element 630.Wherein:
Syntax tree generation unit 610 is used to parse code to be detected to generate the abstract syntax tree of the code to be detected;
Traversal analytic unit 620 is used for each node for traveling through the abstract syntax tree, and carries out semantic analysis to each node
To judge that each node whether there is the method for not meeting internationalization and calling;And
The node that Tip element 630 is used to not meet the method that internationalization calls to existing is prompted.
Further, in this exemplary embodiment, semantic analysis is carried out to each node to judge each node with the presence or absence of not
Meeting the method that internationalization calls can include:
Semantic analysis is carried out to each node to judge whether the method for each node belongs to internationalization correlation technique;
If the method for node belongs to the internationalization correlation technique, judge whether the parameter of the method for the node accords with
Close the parameter type of the internationalization correlation technique;
If the parameter of the method for the node do not meet it is described internationalization correlation technique parameter type, judge described in
The method that internationalization calls that do not meet be present in node.
Further, in this exemplary embodiment, the internationalization correlation technique can include language correlation technique, region
One or more in correlation technique and character set correlation technique.
Further, in this exemplary embodiment, semantic analysis is carried out to each node whether to judge the method for each node
Belonging to internationalization correlation technique includes:
Whether the method based on each node of preset matching rule judgment of each method in the code to be detected belongs to international
Change correlation technique.
In addition, in this exemplary embodiment, the code detection method can also include:
The preset matching rule of each method in the code to be detected is set by extensible markup language.
Further, in this exemplary embodiment, the node for the method that internationalization calls not being met to existing is prompted
It can include:
In IDE there is the node for not meeting the method that internationalization calls in distinctiveness display.
Further, in this exemplary embodiment, code to be detected is parsed to generate the abstract language of the code to be detected
Method tree can include:
Morphological analysis is carried out to code to be detected with syntactic analysis to generate the abstract syntax tree of the code to be detected.
Further, in this exemplary embodiment, the node for not meeting the method that internationalization calls be present in distinctiveness display
It can include:
The node for not meeting the method that internationalization calls and corresponding modification prompting be present in distinctiveness display.
Each functional module and above-mentioned code detection side due to the code detecting apparatus 600 of the example embodiment of the disclosure
The step of example embodiment of method, is corresponding, therefore will not be repeated here.
In an exemplary embodiment of the disclosure, a kind of electronic equipment that can realize the above method is additionally provided.
Person of ordinary skill in the field it is understood that various aspects of the invention can be implemented as system, method or
Program product.Therefore, various aspects of the invention can be implemented as following form, i.e.,:Complete hardware embodiment, completely
Software implementation (including firmware, microcode etc.), or hardware and software in terms of combine embodiment, may be collectively referred to as here
" circuit ", " module " or " system ".
The electronic equipment 700 of this embodiment according to the present invention is described referring to Fig. 7.The electronics that Fig. 7 is shown is set
Standby 700 be only an example, should not bring any restrictions to the function and use range of the embodiment of the present invention.
As shown in fig. 7, electronic equipment 700 is showed in the form of universal computing device.The component of electronic equipment 700 can wrap
Include but be not limited to:Above-mentioned at least one processing unit 710, above-mentioned at least one memory cell 720, connection different system component
The bus 730 of (including memory cell 720 and processing unit 710), display unit 740.
Wherein, the memory cell is had program stored therein code, and described program code can be held by the processing unit 710
OK so that the processing unit 710 performs each according to the present invention described in above-mentioned " code detection method " part of this specification
The step of kind exemplary embodiment.For example, the step S110. parsings that the processing unit 710 can perform as shown in fig. 1 are treated
Code is detected to generate the abstract syntax tree of the code to be detected;Step S120. travels through each node of the abstract syntax tree,
And semantic analysis is carried out to each node to judge that each node whether there is the method for not meeting internationalization and calling;And step
S130. the node for the method that internationalization calls not being met to existing is prompted.
Memory cell 720 can include the computer-readable recording medium of volatile memory cell form, such as Random Access Storage Unit
(RAM) 7201 and/or cache memory unit 7202, it can further include read-only memory unit (ROM) 7203.
Memory cell 720 can also include program/utility with one group of (at least one) program module 7205
7204, such program module 7205 includes but is not limited to:Operating system, one or more application program, other program moulds
Block and routine data, the realization of network environment may be included in each or certain combination in these examples.
Bus 730 can be to represent the one or more in a few class bus structures, including memory cell bus or storage
Cell controller, peripheral bus, graphics acceleration port, processing unit use any bus structures in a variety of bus structures
Local bus.
Electronic equipment 700 can also be with one or more external equipments 770 (such as keyboard, sensing equipment, bluetooth equipment
Deng) communication, the equipment communication interacted with the electronic equipment 700 can be also enabled a user to one or more, and/or with causing
Any equipment that the electronic equipment 700 can be communicated with one or more of the other computing device (such as router, modulation /demodulation
Device etc.) communication.This communication can be carried out by input/output (I/O) interface 750.Also, electronic equipment 700 can be with
By network adapter 760 and one or more network (such as LAN (LAN), wide area network (WAN) and/or public network,
Such as internet) communication.As illustrated, network adapter 760 is communicated by bus 730 with other modules of electronic equipment 700.
It should be understood that although not shown in the drawings, can combine electronic equipment 700 does not use other hardware and/or software module, including but not
It is limited to:Microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive and
Data backup storage system etc..
The description of embodiment more than, those skilled in the art is it can be readily appreciated that example embodiment described herein
It can be realized, can also be realized by way of software combines necessary hardware by software.Therefore, implemented according to the disclosure
The technical scheme of example can be embodied in the form of software product, and the software product can be stored in a non-volatile memories
In medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) or on network, including some instructions are make it that a computing device (can
To be personal computer, server, terminal installation or network equipment etc.) perform method according to the embodiment of the present disclosure.
In an exemplary embodiment of the disclosure, a kind of computer-readable recording medium is additionally provided, is stored thereon with energy
Enough realize the program product of this specification above method.In some possible embodiments, various aspects of the invention can be with
It is embodied as a kind of form of program product, it includes program code, described when described program product is run on the terminal device
Program code be used for make the terminal device perform described in above-mentioned " illustrative methods " part of this specification according to the present invention
The step of various exemplary embodiments.
With reference to shown in figure 8, the program product 800 according to an embodiment of the invention for being used to realize the above method is described,
It can use portable compact disc read only memory (CD-ROM) and including program code, and can in terminal device, such as
Run on PC.However, the program product not limited to this of the present invention, in this document, readable storage medium storing program for executing can be appointed
What is included or the tangible medium of storage program, the program can be commanded execution system, device either device use or and its
It is used in combination.
Described program product can use any combination of one or more computer-readable recording mediums.Computer-readable recording medium can be readable letter
Number medium or readable storage medium storing program for executing.Readable storage medium storing program for executing for example can be but be not limited to electricity, magnetic, optical, electromagnetic, infrared ray or
System, device or the device of semiconductor, or any combination above.The more specifically example of readable storage medium storing program for executing is (non exhaustive
List) include:It is electrical connection, portable disc, hard disk, random access memory (RAM) with one or more wires, read-only
Memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read only memory
(CD-ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.
Computer-readable signal media can be including the data-signal in a base band or as carrier wave part propagation, its
In carry readable program code.The data-signal of this propagation can take various forms, including but not limited to electromagnetic signal,
Optical signal or above-mentioned any appropriate combination.Readable signal medium can also be any readable Jie beyond readable storage medium storing program for executing
Matter, the computer-readable recording medium can send, propagate either transmit for used by instruction execution system, device or device or and its
The program of combined use.
The program code included on computer-readable recording medium can be transmitted with any appropriate medium, including but not limited to wirelessly, be had
Line, optical cable, RF etc., or above-mentioned any appropriate combination.
Can being combined to write the program operated for performing the present invention with one or more programming languages
Code, described program design language include object oriented program language-Java, C++ etc., include routine
Procedural programming language-such as " C " language or similar programming language.Program code can be fully in user
Perform on computing device, partly perform on a user device, the software kit independent as one performs, is partly calculated in user
Its upper side point is performed or performed completely in remote computing device or server on a remote computing.It is remote being related to
In the situation of journey computing device, remote computing device can pass through the network of any kind, including LAN (LAN) or wide area network
(WAN) user calculating equipment, is connected to, or, it may be connected to external computing device (such as utilize ISP
To pass through Internet connection).
In addition, above-mentioned accompanying drawing is only the schematic theory of the processing included by method according to an exemplary embodiment of the present invention
It is bright, rather than limitation purpose.It can be readily appreciated that the time that above-mentioned processing shown in the drawings was not intended that or limited these processing is suitable
Sequence.In addition, being also easy to understand, these processing for example can be performed either synchronously or asynchronously in multiple modules.
It should be noted that although some modules or list of the equipment for action executing are referred in above-detailed
Member, but this division is not enforceable.In fact, in accordance with an embodiment of the present disclosure, two or more above-described moulds
Either the feature of unit and function can embody block in a module or unit.A conversely, above-described module
Either the feature of unit and function can be further divided into being embodied by multiple modules or unit.
Those skilled in the art will readily occur to the disclosure its after considering specification and putting into practice invention disclosed herein
His embodiment.The application is intended to any modification, purposes or the adaptations of the disclosure, these modifications, purposes or
Adaptations follow the general principle of the disclosure and including the undocumented common knowledge in the art of the disclosure or
Conventional techniques.Description and embodiments are considered only as exemplary, and the true scope of the disclosure and spirit are by claim
Point out.
It should be appreciated that the precision architecture that the disclosure is not limited to be described above and is shown in the drawings, and
And various modifications and changes can be being carried out without departing from the scope.The scope of the present disclosure is only limited by appended claim.
Claims (11)
- A kind of 1. code detection method, applied to Developing International Software, it is characterised in that including:Code to be detected is parsed to generate the abstract syntax tree of the code to be detected;Each node of the abstract syntax tree is traveled through, and semantic analysis is carried out to each node and is not inconsistent with judging that each node whether there is Close the method that internationalization calls;AndThe node that the method that internationalization calls is not met to existing is prompted.
- 2. code detection method according to claim 1, it is characterised in that it is each to judge that semantic analysis is carried out to each node Node includes with the presence or absence of the method for not meeting internationalization calling:Semantic analysis is carried out to each node to judge whether the method for each node belongs to internationalization correlation technique;If the method for node belongs to the internationalization correlation technique, judge whether the parameter of the method for the node meets institute State the parameter type of internationalization correlation technique;If the parameter of the method for the node does not meet the parameter type of the internationalization correlation technique, the node is judged In the presence of the method for not meeting internationalization calling.
- 3. code detection method according to claim 2, it is characterised in that the internationalization correlation technique includes language phase One or more in pass method, region correlation technique and character set correlation technique.
- 4. code detection method according to claim 2, it is characterised in that it is each to judge that semantic analysis is carried out to each node Whether the method for node, which belongs to internationalization correlation technique, includes:Whether the method based on each node of preset matching rule judgment of each method in the code to be detected belongs to internationalization phase Pass method.
- 5. code detection method according to claim 4, it is characterised in that the code detection method also includes:The preset matching rule of each method in the code to be detected is set by extensible markup language.
- 6. code detection method according to any one of claim 1 to 5, it is characterised in that do not meet the world to existing The node for the method that change is called, which carries out prompting, to be included:In IDE there is the node for not meeting the method that internationalization calls in distinctiveness display.
- 7. code detection method according to claim 6, it is characterised in that it is described to be checked to generate to parse code to be detected Surveying the abstract syntax tree of code includes:Morphological analysis is carried out to code to be detected with syntactic analysis to generate the abstract syntax tree of the code to be detected.
- 8. code detection method according to claim 6, it is characterised in that distinctiveness display, which exists, does not meet internationalization tune The node of method includes:The node for not meeting the method that internationalization calls and corresponding modification prompting be present in distinctiveness display.
- A kind of 9. code detecting apparatus, it is characterised in that including:Syntax tree generation unit, for parsing code to be detected to generate the abstract syntax tree of the code to be detected;Analytic unit is traveled through, for traveling through each node of the abstract syntax tree, and semantic analysis is carried out to each node to judge Each node whether there is the method that internationalization calls that do not meet;AndTip element, the node for not meeting the method that internationalization calls to existing are prompted.
- 10. a kind of electronic equipment, it is characterised in that includingProcessor;AndMemory, computer-readable instruction is stored with the memory, the computer-readable instruction is held by the processor Code detection method according to any one of claim 1 to 8 is realized during row.
- 11. a kind of computer-readable recording medium, is stored thereon with computer program, the computer program is executed by processor Shi Shixian code detection methods according to any one of claim 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710737174.XA CN107506304A (en) | 2017-08-24 | 2017-08-24 | Code detection method, device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710737174.XA CN107506304A (en) | 2017-08-24 | 2017-08-24 | Code detection method, device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107506304A true CN107506304A (en) | 2017-12-22 |
Family
ID=60692780
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710737174.XA Pending CN107506304A (en) | 2017-08-24 | 2017-08-24 | Code detection method, device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107506304A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109446078A (en) * | 2018-10-18 | 2019-03-08 | 网易(杭州)网络有限公司 | Code test method and device, storage medium, electronic equipment |
CN110286912A (en) * | 2019-07-03 | 2019-09-27 | 广东三维家信息科技有限公司 | Code detection method, device and electronic equipment |
CN110795197A (en) * | 2019-11-08 | 2020-02-14 | 深圳前海环融联易信息科技服务有限公司 | Method and device for internationalizing enumerated classes, computer equipment and storage medium |
CN110874316A (en) * | 2018-08-31 | 2020-03-10 | 北京京东尚科信息技术有限公司 | Method, device and system for scanning codes |
CN118733007A (en) * | 2024-09-03 | 2024-10-01 | 成都精灵云科技有限公司 | Python-based code automatic generation and automatic checking method |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1908895A (en) * | 2005-08-02 | 2007-02-07 | 国际商业机器公司 | System and method for application program globalization problem verification and computer products |
CN101017458A (en) * | 2007-03-02 | 2007-08-15 | 北京邮电大学 | Software safety code analyzer based on static analysis of source code and testing method therefor |
CN102819490A (en) * | 2012-07-20 | 2012-12-12 | 北京邮电大学 | Method and system for software testing based on given defect description information |
CN106294156A (en) * | 2016-08-11 | 2017-01-04 | 北京邮电大学 | A kind of static code fault detection analysis method and device |
-
2017
- 2017-08-24 CN CN201710737174.XA patent/CN107506304A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1908895A (en) * | 2005-08-02 | 2007-02-07 | 国际商业机器公司 | System and method for application program globalization problem verification and computer products |
CN101017458A (en) * | 2007-03-02 | 2007-08-15 | 北京邮电大学 | Software safety code analyzer based on static analysis of source code and testing method therefor |
CN102819490A (en) * | 2012-07-20 | 2012-12-12 | 北京邮电大学 | Method and system for software testing based on given defect description information |
CN106294156A (en) * | 2016-08-11 | 2017-01-04 | 北京邮电大学 | A kind of static code fault detection analysis method and device |
Non-Patent Citations (2)
Title |
---|
ZHU TIAN QING: "AN EXTENSIBLE STATIC ANALYSIS METHOD USING DEFECTS", 《THE 8TH INTERNATIONAL SYMPOSIUM ON DISTRIBUTED COMPUTING AND APPLICATIONS TO BUSINESS, ENGINEERING AND SCIENCE》 * |
杨朝红等: "基于软件缺陷模型的测试系统", 《北京邮电大学学报》 * |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110874316A (en) * | 2018-08-31 | 2020-03-10 | 北京京东尚科信息技术有限公司 | Method, device and system for scanning codes |
CN110874316B (en) * | 2018-08-31 | 2024-04-12 | 北京京东尚科信息技术有限公司 | Method, device and system for scanning codes |
CN109446078A (en) * | 2018-10-18 | 2019-03-08 | 网易(杭州)网络有限公司 | Code test method and device, storage medium, electronic equipment |
CN109446078B (en) * | 2018-10-18 | 2022-02-18 | 网易(杭州)网络有限公司 | Code testing method and device, storage medium and electronic equipment |
CN110286912A (en) * | 2019-07-03 | 2019-09-27 | 广东三维家信息科技有限公司 | Code detection method, device and electronic equipment |
CN110286912B (en) * | 2019-07-03 | 2023-08-18 | 广东三维家信息科技有限公司 | Code detection method and device and electronic equipment |
CN110795197A (en) * | 2019-11-08 | 2020-02-14 | 深圳前海环融联易信息科技服务有限公司 | Method and device for internationalizing enumerated classes, computer equipment and storage medium |
CN118733007A (en) * | 2024-09-03 | 2024-10-01 | 成都精灵云科技有限公司 | Python-based code automatic generation and automatic checking method |
CN118733007B (en) * | 2024-09-03 | 2024-11-05 | 成都精灵云科技有限公司 | Python-based code automatic generation and automatic inspection method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107506304A (en) | Code detection method, device, electronic equipment and storage medium | |
US9547641B2 (en) | Domain specific salient point translation | |
US8561014B2 (en) | Extracting a system modelling meta-model language model for a system from a natural language specification of the system | |
CN109426723A (en) | Use the detection method, system, equipment and storage medium of memory after release | |
CN105912381B (en) | A compile-time code security detection method based on rule base | |
US8954940B2 (en) | Integrating preprocessor behavior into parsing | |
Sereshkeh et al. | VASTA: a vision and language-assisted smartphone task automation system | |
CN114328208B (en) | Code detection method and device, electronic device, and storage medium | |
US20120131556A1 (en) | Xpath-based selection assistance of gui elements during manual test script authoring for xml-based applications | |
Arora et al. | Requirement boilerplates: Transition from manually-enforced to automatically-verifiable natural language patterns | |
CN110059006A (en) | Code audit method and device | |
Ren et al. | Making smart contract development more secure and easier | |
CN106547516A (en) | Spacecraft telecommand instructs upload control method and device | |
Sabriye et al. | A framework for detecting ambiguity in software requirement specification | |
WO2015159501A1 (en) | Verification property integration device, verification property integration method, and recording medium having verification property integration program stored therein | |
CN110191021A (en) | A kind of protocol testing method, device, electronic equipment and storage medium | |
CN118378631B (en) | Text review method, device, equipment and storage medium | |
CN114116471A (en) | Automatic code scanning method, system, electronic equipment and storage medium | |
CN112306493A (en) | Hot repair patch generation method and device, storage medium and computer equipment | |
CN109446078A (en) | Code test method and device, storage medium, electronic equipment | |
CN111124541B (en) | Configuration file generation method, device, equipment and medium | |
Gong et al. | SCGformer: Smart contract vulnerability detection based on control flow graph and transformer | |
Kothari | Processing natural language requirement to extract basic elements of a class | |
CN115455922B (en) | Form verification method, form verification device, electronic equipment and storage medium | |
CN109284483A (en) | Text processing method and device, storage medium and electronic equipment |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20171222 |
|
RJ01 | Rejection of invention patent application after publication |