CN101853174A - Method and device for synchronizing defining and calling of string resource - Google Patents

Method and device for synchronizing defining and calling of string resource Download PDF

Info

Publication number
CN101853174A
CN101853174A CN200910081166A CN200910081166A CN101853174A CN 101853174 A CN101853174 A CN 101853174A CN 200910081166 A CN200910081166 A CN 200910081166A CN 200910081166 A CN200910081166 A CN 200910081166A CN 101853174 A CN101853174 A CN 101853174A
Authority
CN
China
Prior art keywords
string
character string
program
module
file
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
CN200910081166A
Other languages
Chinese (zh)
Other versions
CN101853174B (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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN200910081166.XA priority Critical patent/CN101853174B/en
Publication of CN101853174A publication Critical patent/CN101853174A/en
Application granted granted Critical
Publication of CN101853174B publication Critical patent/CN101853174B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a device for synchronizing defining and calling of a string resource and aims to solve the technical problems of redundancy and frequent asynchronism of defining and calling due to manual maintenance of the string resource by a developer in a software developing environment. Character strings in a program code are automatically called by adding a scanning detection module, bidirectional detection is performed on the definition of the character strings in a string resource file and a prompt is actively given to a program developer if redundancy or undefinition of the character strings is found, so that the workload of the developer is relieved, the developing speed is increased, the error detection accuracy and efficiency are improved, the code is optimized and redundant character strings are prevented from occupying an extra storage space.

Description

A kind of string resource definition and the method for synchronous and the device that call
Technical field
The present invention relates to the software source code development technique, relate in particular to a kind of string resource definition and the method for synchronous and the device that call.
Background technology
In field of software development, string resource mainly is meant the set that is defined in the character string in the resource file that needs to show output on user interface, and for international language environment, string resource generally all can have several language versions.The internationalization of character string uses the internationalization form of centralized management, and same string resource is identified by the character string identification (key assignments) that unique system generates, and each string resource has different performances below different language.The developer is divided into two processes generally to the management of string resource: the one, and the unique character string identification of character string content allocation is promptly given in the definition of character string; The 2nd, calling of character string promptly called the corresponding characters string by character string identification from resource file in program code.Because the definition of character string and call by the developer and manually safeguard, call with being defined in to a certain extent and separate, will produce synchronous problem like this, in program code, do not use this character string if promptly in the string resource file, defined certain character string, will produce redundancy; If call character string by certain character string identification, and the not definition in the string resource file of corresponding characters string then will make mistakes in the program compiler code, and causing can't the failure of whole procedure code compile.
Summary of the invention
In view of this, fundamental purpose of the present invention is to provide a kind of method and the device that can realize string resource definition and invoke synchronous, be used for solving at software development environment, the developer safeguards that artificially string resource causes redundancy easily and nonsynchronous technical matters often occurs defining and calling.
Thereby basic thought of the present invention is automatically program code to be scanned and in time find and remind the developer that or which character string are undefined by adding a scanning detection module, though and which character string of self-verifying defined but used in program code, thereby in time finds the character string of redundant definition and point out the developer to delete.
For achieving the above object, technical scheme of the present invention is achieved in that
A kind of string resource definition and the method for synchronous that calls comprise:
Use macro definition to realize the string resource access interface, scan the character string identification that in program's code file, calls but in the string resource file, do not define by the scanning detection module, and detect the string resource that in the string resource file, defines but in program's code file, do not call, and produce corresponding warning information.
Further, described use macro definition realizes that the string resource access interface is meant: definition is used for calling the grand of string resource at program's code file in the string resource file, and described grand use specific named rule is named.
Further, call in program's code file by scanning detection module scanning but the method for the character string identification that do not define in the string resource file is:
That detects in real time that the developer imports in program's code file calls the grand of string resource and extracts character string identification from described grand, if find that described character string identification is undefined in the string resource file, then produces corresponding warning information; Or,
All call the grand of string resource and scan in to program's code file to call the scanning detection module when the save routine code file or by menucommand, and detect its character string identification of quoting and whether in the string resource file, define, if find the undefined corresponding warning information that then produces.
Further, described detection defines in the string resource file but the step of the string resource that do not call in program's code file is:
By all call the grand of string resource in the scanning detection module entire scan program's code file, and the character string identification in will be described grand extracts and forms character string identification and gather;
Whether the character string identification of each string resource in the scanning detection module cycle criterion string resource file is contained in the described character string identification set, if there is not the character string that produces corresponding this redundancy definition of warning information prompting deletion.
Another object of the present invention is to provide a kind of device that can realize string resource definition and invoke synchronous, for achieving the above object, technical scheme of the present invention is achieved in that
A kind of string resource definition and the synchronous device that calls comprise program code editor module, string resource module, also comprise:
The scanning detection module, be used for that character string between program's code file and the string resource file calls and define synchronously, and when finding to quote undefined character string or the redundant character string that defines, produce corresponding warning information.
Further, described scanning detection module comprises:
The redundancy detection module is used for detecting in the definition of string resource file but the character string of not calling in program's code file, and produces corresponding warning information;
The reference scan module is used for autoscan and calls but the character string identification that do not define in the string resource file at program's code file, and produces corresponding warning information;
Alarm module is used to receive the warning information of redundancy detection module and the generation of reference scan module and is prompted to the user with setting means.
Further, described reference scan module comprises:
Grand matching module, be used in real time grand mate or scanning occurs when the described program code editor module save routine code file calls the grand of string resource in program's code file, obtain its character string identification of quoting and send to the reference validation module importing at the program code editor module;
The reference validation module is used for retrieving at the string resource file according to the character string identification that receives, and judges whether described character string identification defines in the string resource file, then produces warning information and sends to described alarm module as if undefined.
Further, described redundancy detection module comprises:
The character string identification acquisition module is used for calling the grand of string resource in scanning at program's code file, and the character string identification that obtains wherein forms the character string identification set;
The definition authentication module, be used for obtaining the character string identification of the defined string resource of string resource file, and judge that whether each character string identification is contained in the described character string identification set, if do not comprise, then produces warning information and sends to described alarm module.
Further, described program code editor module is by the described scanning detection module of interface interchange, and described scanning detection module is outputting alarm information or pass through described interface and export described warning information in described program code editor module directly.
The present invention calls the character string in the program code automatically by interpolation scanning detection module and two-way detection is carried out in the character string definition in the string resource file, if find to exist character string redundancy or undefined situation then active attention program developer, thereby alleviated developer's work load, the speed of exploitation and the accuracy rate and the efficient of error detection have been improved, optimize code, avoided the outer storage space of redundance character string occupying volume.
Description of drawings
Fig. 1 realizes the process flow diagram of the method for synchronous that string resource defines and calls for the present invention;
Fig. 2 realizes the structural drawing of the synchronous device that string resource defines and calls for the present invention.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, by the following examples and with reference to accompanying drawing, the present invention is described in more detail.
Fig. 1 is the process flow diagram that the present invention realizes the method for synchronous that string resource defines and calls, and is specially:
Step 1: the user adds string resource in the string resource module, generates the string resource file;
In Integrated Development Environment, usually be provided for defining and managing the string resource module of string resource file, by the new string resource of string resource module definable, can carry out operations such as maintenance management to string resource, among the present invention, the scanning detection module is operated the string resource file by the interface that the string resource module provides.
Each string resource has different contents at different language, and each string resource all has unique character string identification corresponding with it, can call corresponding characters string resource by character string identification in program's code file.
In order in program code, directly to call corresponding characters string resource according to character string identification, need string resource is compiled into the string resource file, in the string resource file, calling of string resource encapsulated interface, and using macro definition in header file is specific grand with the standard of calling of string resource, scanning in program's code file for convenience, the present invention uses the specific named rule to name grand in the string resource file, and the macro definition example is as follows:
#define_(msgid)zGuiI?18n_Gettext(msgid),
Wherein zGuiI18n_Gettext is the function that is used for obtaining from the string resource file string resource, _ (msgid) grand for what in program's code file, use, msgid is a character string identification, uses this macro definition just can call string resource in the character string resource file.
Step 2: the time by program code editor module coding code file, the scanning detection module scans program's code file, when finding to call character string grand, from its invoke code, obtain the character string identification of being quoted, judge whether described character string identification defines in the string resource file, if undefinedly then produce corresponding warning information;
Among the present invention, in the program code editor module, carry out the editor of program's code file, operations such as compiling, the Visual Studio C++ Integrated Development Environment of existing programmed environment such as Microsoft, program code editor module that the source program code file is edited and the string resource module that is used for the string resource management maintenance have wherein been comprised, the open interface that the present invention provides by Integrated Development Environment adds a scanning detection module, be used for that character string between program code editor module and the string resource module calls and define synchronously, and when finding the redundant definition of character string or quoting undefined character string, produce corresponding warning information.When moving, Integrated Development Environment loads described scanning detection module automatically.
As shown in Figure 2, described scanning detection module comprises redundancy detection module, reference scan module and alarm module.The reference scan module is used for autoscan to be called but the character string identification that do not define in the string resource file at program's code file, and produces corresponding warning information.Alarm module is used to receive the warning information of redundancy detection module and the generation of reference scan module and is prompted to the user with setting means.
The mode that the scanning detection module scans undefined character string identification can have two kinds, and a kind of is the real time monitoring pattern, and a kind of is the centralized detecting pattern.
The course of work of real time monitoring pattern is: when the program development personnel write source program code, catch the incoming event of keyboard in real time by the scanning detection module, and to the input character string mate in real time, if find to call the grand of string resource, then its character string identification of quoting is judged, if find that described character string identification is undefined in the string resource file, then produce corresponding warning information.
The course of work of centralized detecting pattern is: when the save routine code file (scanning detection module capture the preservation incident) or call the scanning detection module by menucommand, to all call the grand entire scan of carrying out of string resource in the program's code file, and detect its character string identification of quoting one by one and whether in the string resource file, define, if find that undefined character string identification then produces corresponding warning information.
With the macro definition in the step 1 is example, use _ (" 0001 ") macro call form calls character string and is designated 0001 string resource in program code, the macrodefinition format of scanning detection module basis _ (" Key ") is mated, if find to satisfy calling of this form, then take out the Key value, if this character string identification did not define in the string resource file, then produce warning information, the developer finds just can add corresponding string resource by the string resource module behind this warning information.
The developer may directly import a lot of program codes in the middle of engineering, do not write one by one, call and may have a lot of character strings inside the program code, the scanning detection module can travel through all code files of whole engineering the inside successively, to meet _ character string identification that the specific character string of (" key ") is used all extracts, compare with the character string identification that defines in all string resource files, thereby find out all undefined string resources, in time add undefined string resource with the prompting developer.
Step 3: detect the string resource that in the string resource file, defines but in program's code file, do not call by the scanning detection module automatically;
As shown in Figure 2, scanning comprises the redundancy detection module in the detection module, and the redundancy detection module is used for detecting in the definition of string resource file but the character string of not calling in program's code file, and produces corresponding warning information;
In the program code editor module, trigger automatically by the preservation incident during save routine code file and call the scanning detection module, or the developer initiatively calls the scanning detection module by menucommand, by the redundancy detection module of scanning in the detection module program code is carried out entire scan, from all call string resource grand, extract character string identification and form the character string identification set;
The redundancy detection module is by string resource module each string resource corresponding characters string sign that circulates, and judge whether described character string identification is contained in the character string identification set that generates in the above-mentioned steps, then produce corresponding warning information prompting developer in the character string identification set and in time delete the string resource of this redundancy definition if be contained in.
Among the present invention, the prompting mode of described warning information can adopt initiatively, and pop-up window also can highlight undefined character string identification or or highlight the redundant string resource that defines with special background colour in the string resource module with special background colour in the program code coding module in the mode of tabulation demonstration.
The present invention provides the framework of a cover string resource management optimization to the program development personnel, the developer uses this framework, can finish string resource definition, call, synchronously and redundancy detection etc., alleviate developer's work load to a great extent, improved the efficient of exploitation and error detection.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention.

Claims (9)

1. a string resource defines and the method for synchronous that calls, and it is characterized in that, comprising:
Use macro definition to realize the string resource access interface, scan the character string identification that in program's code file, calls but in the string resource file, do not define by the scanning detection module, and detect the string resource that in the string resource file, defines but in program's code file, do not call, and produce corresponding warning information.
2. method according to claim 1, it is characterized in that, described use macro definition realizes that the string resource access interface is meant: definition is used for calling the grand of string resource at program's code file in the string resource file, and described grand use specific named rule is named.
3. method according to claim 1 is characterized in that, the method that scans the character string identification that calls but do not define by the scanning detection module in program's code file in the string resource file is:
That detects in real time that the developer imports in program's code file calls the grand of string resource and extracts character string identification from described grand, if find that described character string identification is undefined in the string resource file, then produces corresponding warning information; Or,
All call the grand of string resource and scan in to program's code file to call the scanning detection module when the save routine code file or by menucommand, and detect its character string identification of quoting and whether in the string resource file, define, if find the undefined corresponding warning information that then produces.
4. method according to claim 1 is characterized in that, described detection defines in the string resource file but the step of the string resource that do not call in program's code file is:
By all call the grand of string resource in the scanning detection module entire scan program's code file, and the character string identification in will be described grand extracts and forms character string identification and gather;
Whether the character string identification of each string resource in the scanning detection module cycle criterion string resource file is contained in the described character string identification set, if there is not the character string that produces corresponding this redundancy definition of warning information prompting deletion.
5. a string resource defines and the synchronous device that calls, and comprises program code editor module, string resource module, it is characterized in that, also comprises:
The scanning detection module, be used for that character string between program's code file and the string resource file calls and define synchronously, and when finding to quote undefined character string or the redundant character string that defines, produce corresponding warning information.
6. device according to claim 5 is characterized in that, described scanning detection module comprises:
The redundancy detection module is used for detecting in the definition of string resource file but the character string of not calling in program's code file, and produces corresponding warning information;
The reference scan module is used for autoscan and calls but the character string identification that do not define in the string resource file at program's code file, and produces corresponding warning information;
Alarm module is used to receive the warning information of redundancy detection module and the generation of reference scan module and is prompted to the user with setting means.
7. device according to claim 6 is characterized in that, described reference scan module comprises:
Grand matching module, be used in real time grand mate or scanning occurs when the described program code editor module save routine code file calls the grand of string resource in program's code file, obtain its character string identification of quoting and send to the reference validation module importing at the program code editor module;
The reference validation module is used for retrieving at the string resource file according to the character string identification that receives, and judges whether described character string identification defines in the string resource file, then produces warning information and sends to described alarm module as if undefined.
8. device according to claim 6 is characterized in that, described redundancy detection module comprises:
The character string identification acquisition module is used for calling the grand of string resource in scanning at program's code file, and the character string identification that obtains wherein forms the character string identification set;
The definition authentication module, be used for obtaining the character string identification of the defined string resource of string resource file, and judge that whether each character string identification is contained in the described character string identification set, if do not comprise, then produces warning information and sends to described alarm module.
9. device according to claim 5, it is characterized in that, described program code editor module is by the described scanning detection module of interface interchange, and described scanning detection module is outputting alarm information or pass through described interface and export described warning information in described program code editor module directly.
CN200910081166.XA 2009-04-03 2009-04-03 Method and device for synchronizing defining and calling of string resource Active CN101853174B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910081166.XA CN101853174B (en) 2009-04-03 2009-04-03 Method and device for synchronizing defining and calling of string resource

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910081166.XA CN101853174B (en) 2009-04-03 2009-04-03 Method and device for synchronizing defining and calling of string resource

Publications (2)

Publication Number Publication Date
CN101853174A true CN101853174A (en) 2010-10-06
CN101853174B CN101853174B (en) 2014-03-12

Family

ID=42804682

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910081166.XA Active CN101853174B (en) 2009-04-03 2009-04-03 Method and device for synchronizing defining and calling of string resource

Country Status (1)

Country Link
CN (1) CN101853174B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103645985A (en) * 2013-11-28 2014-03-19 广州视源电子科技股份有限公司 Source code macro-matching detection method
CN105511934A (en) * 2015-12-08 2016-04-20 贵阳朗玛信息技术股份有限公司 Resource processing method and device in application program development
CN106326693A (en) * 2016-08-18 2017-01-11 广州优视网络科技有限公司 Obfuscation method and obfuscation device for application program code
CN106487851A (en) * 2015-08-31 2017-03-08 北京国双科技有限公司 Web wrapper information transferring method, apparatus and system
CN106648822A (en) * 2016-12-30 2017-05-10 深圳市九洲电器有限公司 User interface character string screening method and system
CN110059214A (en) * 2019-04-01 2019-07-26 北京奇艺世纪科技有限公司 A kind of image resource processing method and processing device
CN117931265A (en) * 2024-03-25 2024-04-26 英诺达(成都)电子科技有限公司 Command management method, device, electronic apparatus, storage medium, and program product

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1257455C (en) * 2002-07-25 2006-05-24 梁肇新 Inter-process calling gate technique
CN101308486A (en) * 2008-03-21 2008-11-19 北京印刷学院 Test question automatic generation system and method

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103645985A (en) * 2013-11-28 2014-03-19 广州视源电子科技股份有限公司 Source code macro-matching detection method
CN106487851A (en) * 2015-08-31 2017-03-08 北京国双科技有限公司 Web wrapper information transferring method, apparatus and system
CN106487851B (en) * 2015-08-31 2019-06-18 北京国双科技有限公司 Web wrapper information transferring method, apparatus and system
CN105511934A (en) * 2015-12-08 2016-04-20 贵阳朗玛信息技术股份有限公司 Resource processing method and device in application program development
CN105511934B (en) * 2015-12-08 2018-11-13 贵阳朗玛信息技术股份有限公司 Method for processing resource in application development and device
CN106326693A (en) * 2016-08-18 2017-01-11 广州优视网络科技有限公司 Obfuscation method and obfuscation device for application program code
CN106648822A (en) * 2016-12-30 2017-05-10 深圳市九洲电器有限公司 User interface character string screening method and system
WO2018121041A1 (en) * 2016-12-30 2018-07-05 深圳市九洲电器有限公司 Interface character string screening method and system
CN106648822B (en) * 2016-12-30 2019-09-06 深圳市九洲电器有限公司 Interface character string selection method and system
CN110059214A (en) * 2019-04-01 2019-07-26 北京奇艺世纪科技有限公司 A kind of image resource processing method and processing device
CN117931265A (en) * 2024-03-25 2024-04-26 英诺达(成都)电子科技有限公司 Command management method, device, electronic apparatus, storage medium, and program product

Also Published As

Publication number Publication date
CN101853174B (en) 2014-03-12

Similar Documents

Publication Publication Date Title
CN101853174B (en) Method and device for synchronizing defining and calling of string resource
CN108885545B (en) Tools and methods for real-time dataflow programming languages
US8037000B2 (en) Systems and methods for automated interpretation of analytic procedures
CN102945203B (en) A kind of code security method of testing for mobile Internet application
CN106341257B (en) Device for self-defining log analysis rule and automatically analyzing log
CN102521120A (en) Software automation test system and method
US20160224338A1 (en) Analyzing Components Related To A Software Application In A Software Development Environment
CN103065221A (en) Multidisciplinary collaborative optimization flow modeling and scheduling method and system based on business process execution language (BPEL)
CN102708452A (en) Water quality analyzing/calculating service system supporting dynamic compiling
CN103092866A (en) Data monitoring method and monitoring device
CN103529773B (en) Automatic conversion method for behavior control scripting language
CN103200203B (en) Based on the semantic class protocol format estimating method performing track
CN103399735A (en) Method for developing intermediate layer of remote function call interface
CN103885754A (en) Automatic data model generating system and automatic data model generating method
CN111652529B (en) Water engineering combined scheduling method
CN105975381B (en) Malfunction monitoring expert system integrating and developing platform
CN101916221A (en) Method and system for performing unit testing on equipment
CN110759191B (en) Elevator control method based on 5G smart park
CN102262527B (en) The method and system of generating network service
CN102541564A (en) UI (User Interface) multiplexing method and device
CN101866297B (en) Method and device for generating management platform
CN103164325A (en) Control coding method and control coding device
CN108647018A (en) Can live preview code generating system
Wu et al. Rules oriented business process modeling
CN108762752A (en) A kind of the Android application program function class drawing generating method and device of combination dynamic and static code analysis technology

Legal Events

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