CN117170684A - File compiling method, device, equipment and storage medium - Google Patents
File compiling method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN117170684A CN117170684A CN202311248416.0A CN202311248416A CN117170684A CN 117170684 A CN117170684 A CN 117170684A CN 202311248416 A CN202311248416 A CN 202311248416A CN 117170684 A CN117170684 A CN 117170684A
- Authority
- CN
- China
- Prior art keywords
- annotation
- file
- target
- processor
- information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 55
- 238000012545 processing Methods 0.000 claims abstract description 7
- 238000004590 computer program Methods 0.000 claims description 14
- 230000006870 function Effects 0.000 claims description 5
- 239000011148 porous material Substances 0.000 claims description 2
- 238000004891 communication Methods 0.000 description 5
- 239000000243 solution Substances 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 238000012986 modification Methods 0.000 description 4
- 230000004048 modification Effects 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 238000002347 injection Methods 0.000 description 3
- 239000007924 injection Substances 0.000 description 3
- 239000002699 waste material Substances 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Stored Programmes (AREA)
Abstract
The application discloses a file compiling method, a device, equipment and a storage medium, which relate to the field of computer processing and comprise the following steps: acquiring a target source file and generating an abstract syntax tree to be processed, which corresponds to the target source file; acquiring a pre-configured target insert annotation processor corresponding to the target source file; and executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file. In the process of compiling the file, the corresponding information automatic writing operation is executed by the preset plug-in annotation processor, so that the operation performance of the obtained byte code file can be effectively improved, and the workload of related developers is reduced.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for compiling a file.
Background
In the conventional scheme, in order to output the related information, when a developer modifies a file, the corresponding information needs to be hard-coded, that is, the related information is directly written into a Java (object oriented programming language) file. A disadvantage of this solution is that each time a new code is released, the corresponding file needs to be modified. Bug (program error) occurs once the developer misses or forgets to modify. On the other hand, because the information is manually modified, the modification error is easy to occur, the workload of a developer is greatly increased, and the modification accuracy cannot be ensured.
Disclosure of Invention
Accordingly, the present application is directed to a method, apparatus, device, and storage medium for compiling a file, which can effectively improve the running performance of the obtained bytecode file, ensure the accuracy of compiling, and reduce the workload of the relevant developer. The specific scheme is as follows:
in a first aspect, the present application provides a file compiling method, including:
acquiring a target source file and generating an abstract syntax tree to be processed, which corresponds to the target source file;
acquiring a pre-configured target insert annotation processor corresponding to the target source file;
and executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file.
Optionally, the performing, by the target-inserted annotation processor, a corresponding information automatic writing operation on the abstract syntax tree to be processed includes:
based on the target plug-in annotation processor, executing corresponding annotation scanning operation by utilizing the annotation set information of the target plug-in annotation processor to obtain a plurality of variables to be filled corresponding to the target source file;
variable definitions corresponding to the variables to be filled are obtained from the abstract syntax tree to be processed;
and respectively executing corresponding real value filling operation on each variable definition by using the target plug-in annotation processor so as to complete corresponding information automatic writing operation.
Optionally, the file compiling method further includes:
marking variables to be filled in the target source file through a plurality of custom annotation classes which are created in advance, and obtaining corresponding annotation set information based on each custom annotation class.
Optionally, the performing, with the target-inserted annotation processor, a corresponding real-value filling operation on each of the variable definitions, includes:
and respectively executing corresponding real value acquisition operation based on the custom annotation information corresponding to each variable to be filled, and respectively filling corresponding variable definitions based on the acquired real values so as to obtain a plurality of corresponding filled variable definitions.
Optionally, the performing a corresponding real value obtaining operation based on the custom annotation information corresponding to each variable to be filled includes:
if the custom annotation information corresponding to the current variable to be filled belongs to a first type of preset annotation, acquiring and analyzing a corresponding pore file by using a preset XML analyzer so as to finish a corresponding first true value acquisition operation;
if the custom annotation information belongs to a second type of preset annotation, acquiring corresponding Git branch information by using JGit to finish corresponding second true value acquisition operation;
if the custom annotation information belongs to a third type of preset annotation, acquiring current time information based on a preset constructor function so as to complete corresponding third true value acquisition operation.
Optionally, the performing, with the target-inserted annotation processor, a corresponding real-value filling operation on each of the variable definitions, includes:
and performing corresponding processing on the predefined related interface class to complete the real value filling operation corresponding to each variable definition.
In a second aspect, the present application provides a file compiling apparatus, comprising:
the file acquisition module is used for acquiring a target source file and generating an abstract syntax tree to be processed, which corresponds to the target source file;
a processor acquisition module for acquiring a preconfigured target insert annotation processor corresponding to the target source file;
and the information writing module is used for executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file.
Optionally, the information writing module includes:
the annotation scanning unit is used for executing corresponding annotation scanning operation by utilizing the annotation set information of the object plug-in annotation processor based on the object plug-in annotation processor to obtain a plurality of variables to be filled corresponding to the object source file;
a variable definition obtaining unit, configured to obtain variable definitions corresponding to the variables to be filled from the abstract syntax tree to be processed;
and the real value filling sub-module is used for respectively executing corresponding real value filling operation on each variable definition by utilizing the target plug-in annotation processor so as to complete corresponding information automatic writing operation.
In a third aspect, the present application provides an electronic device, comprising:
a memory for storing a computer program;
and a processor for executing the computer program to implement the steps of the file compiling method.
In a fourth aspect, the present application provides a computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the file compilation method described above.
In the method, the target source file is obtained, and the abstract syntax tree to be processed corresponding to the target source file is generated; acquiring a pre-configured target insert annotation processor corresponding to the target source file; and executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file. In the process of compiling the file, the corresponding information automatic writing operation is executed by the preset plug-in annotation processor, so that the running performance of the obtained byte code file can be effectively improved, the compiling accuracy is ensured, the workload of relevant developers is reduced, unnecessary time resource waste can be avoided, and the development efficiency is further improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for compiling files;
FIG. 2 is a flowchart of a method for compiling a file according to the present application;
FIG. 3 is a flowchart of a specific file compiling method according to the present application;
FIG. 4 is a schematic diagram of a file compiling apparatus according to the present application;
fig. 5 is a block diagram of an electronic device according to the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the conventional scheme, in order to output the related information, when a developer compiles a file, the corresponding information needs to be hard-coded, that is, the related information is directly written into a Java file. A disadvantage of this solution is that each time a new code is released, the corresponding file needs to be modified. Bug occurs once a developer misses or forgets to modify. On the other hand, because the information is manually modified, the condition of modification errors is easy to occur, the workload of developers is greatly increased, and the compiling accuracy cannot be ensured. Therefore, the application provides a file compiling scheme which can effectively improve the running performance of the obtained byte code file, ensure the compiling accuracy and reduce the workload of related developers.
Referring to fig. 1, the embodiment of the application discloses a file compiling method, which comprises the following steps:
and S11, acquiring a target source file and generating a to-be-processed abstract syntax tree corresponding to the target source file.
In this embodiment, as shown in fig. 2, after the target source file is acquired, the target source file needs to be parsed to generate a corresponding abstract syntax tree to be processed. Wherein, it can be understood that the target source file is a Java file. The AST in fig. 2, abstract syntax code, also called abstract syntax tree, is a tree-like representation of the abstract syntax structure of the source code.
And step S12, acquiring a pre-configured target plug-in annotation processor corresponding to the target source file.
In this embodiment, as shown in fig. 2, after the abstract syntax tree to be processed corresponding to the target source file is obtained, a pre-configured target insert-type annotation processor corresponding to the target source file needs to be obtained.
It should be understood that in this embodiment, in the process of obtaining the target plug-in annotation processor through configuration in advance, it is necessary to first create several custom annotation classes to mark variables to be filled in the target source file, and obtain the corresponding annotation set information based on each custom annotation class. Then, a corresponding plug-in annotation processor class name definition operation, i.e., com. An abstract processor class needs to be inherited in the process of defining the class. The target plug-in annotation processor needs to use @ Supported dAnnomination types to note annotation class information required to be supported by the target plug-in annotation processor. The specific class name definition code statement may be as follows.
It will further be appreciated that a corresponding file may then be created under the folder of the project root directory (e.g., META-INF/services /) corresponding to the target source file, with a file name of java. Accounting. Processing. Processor, and a processor class name (i.e., the company. Abc. Valuefileprocessor) corresponding to the target plug-in annotation processor may be written to the created file. In this way the target insert annotation processor may be automatically obtained.
And step S13, executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file.
In this embodiment, after the target insert annotation processor is acquired, a corresponding information automatic writing operation needs to be performed based on an init (initialization) method and a process (processing) method in the target insert annotation processor. The init method mainly obtains some environment information of compiling time; the process method is a method which can be called by a compiler when compiling, and comprises two parameters, wherein the states represent notes supported by the processor, namely the note set messages; roundEnv denotes the context of the build. For the process method, a specific code implementation statement may be as follows.
public boolean process(Set<?extends TypeElement>annotationSet,RoundEnvironment roundEnvironment);
Wherein the anonationset is the annotation set information.
That is, the performing, by the target-inserted annotation processor, a corresponding information automatic writing operation on the abstract syntax tree to be processed may specifically include: executing corresponding annotation scanning operation by utilizing the annotation set information of the target plug-in annotation processor, namely the animation set, so as to obtain a plurality of variables to be filled corresponding to the target source file by traversing the animation set, namely the elements marked by each animation (namely self-defining annotation information) in the animation set; obtaining variable definitions (namely JCV.ariableDecl) corresponding to the variables to be filled from the abstract syntax tree to be processed based on the corresponding RoundEnvironment interface; and respectively executing corresponding real value filling operation on each variable definition by using the target plug-in annotation processor so as to complete corresponding information automatic writing operation. And calling different methods according to different custom annotation information to complete corresponding real value acquisition operation, so as to assign values to corresponding variable definitions through jcv.init=treemaker.Liter ()), wherein getAbcd () is a code implementation function for specifically acquiring service data. That is, the performing, with the target-inserted annotation processor, a corresponding real-valued fill operation on each of the variable definitions, respectively, includes: and respectively executing corresponding real value acquisition operation based on the custom annotation information corresponding to each variable to be filled, and respectively filling corresponding variable definitions based on the acquired real values so as to obtain a plurality of corresponding filled variable definitions.
Specifically, in this embodiment, the performing, based on the custom annotation information corresponding to each variable to be filled, a corresponding real value obtaining operation may specifically include: if the custom annotation information corresponding to the current variable to be filled belongs to a first type of preset annotation, acquiring and analyzing a corresponding pom (project object model, item object model) file by using a preset XML (eXtensible Markup Language, extensible markup language format) analyzer so as to complete a corresponding first true value acquisition operation; if the custom annotation information belongs to a second class of preset annotations, acquiring corresponding branch information of the Git (distributed version control system) by using JGit (a class library of lightweight pure Java for realizing access of a version control system of the Git and providing a version control algorithm of a core) so as to complete corresponding second true value acquisition operation; if the custom annotation information belongs to a third type of preset annotation, acquiring current time information based on a preset constructor function so as to complete corresponding third true value acquisition operation. It should be understood that, in this embodiment, the first preset annotation is specifically an annotation @ PomVersion for marking a variable that needs to be filled with Pom Version, and in this case, an Xpp3 (XML Pull Parser 3, a very fast XML Parser, and Xpp of the third Version) needs to be used to read the pon.
MavenXpp3Reader reader=new MavenXpp3Reader();
Model model=reader.read(new FileReader("pom.xml"));
String version=model.getVersion()
Meanwhile, the second preset annotation may be @ gitband for marking a variable that needs to fill the Git branch or @ gitUrl for marking a variable that needs to fill the Git Url (path of the repository). The code implementation statement for acquiring the true value for the @ gitband may be specifically shown as follows.
Repository repository=new FileRepositoryBuilder()
.setGitDir(Paths.get(dir,".git").toFile()).build();
git=new Git(repository);
Thus, the current Git branch can be obtained through git.getband (). In addition, the true value acquisition operation for the @ GitUrl is completed specifically by a repositive.
In addition, the third preset annotation may be specifically @ BuildTime for marking the current build time variable to be filled, and it is to be understood that a code implementation statement for obtaining a true value for the @ BuildTime may be specifically shown as follows.
Creating a Date object representing the current time
Date date=new Date();
Creating a SimpleDateFormat object, specifying a date format
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-ddHH:mm:ss");
Formatting Date objects into strings using SimpleDateFormat
String dateString=dateFormat.format(date);
Thus, corresponding real value acquisition operations can be completed for the various custom annotation information respectively. That is, with the target insert annotation processor, injection of the corresponding information, including but not limited to, pon information, git information, and build information, is automatically completed at the compilation stage. It can be appreciated that the operation performance is improved because no additional information injection/modification or the like is required when the operation is performed based on the obtained bytecode file corresponding to the target source file.
Further, in this embodiment, the performing, by using the target-inserted annotation processor, a corresponding real-value filling operation on each of the variable definitions may specifically include: and performing corresponding processing on the predefined related interface class to complete the real value filling operation corresponding to each variable definition. The relevant interface class may specifically be a relevant HTTP (Hypertext Transfer Protocol ) interface class. It is to be appreciated that in one embodiment, specific statements for the relevant interface class may be as follows.
Among these, infoController is a specific such related interface class.
Therefore, in the embodiment of the application, the target source file is acquired, and the abstract syntax tree to be processed corresponding to the target source file is generated; acquiring a pre-configured target insert annotation processor corresponding to the target source file; and executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file. In the process of compiling the file, the corresponding information automatic writing operation is executed by the preset plug-in annotation processor, so that the running performance of the obtained byte code file can be effectively improved, the compiling accuracy is ensured, the workload of relevant developers is reduced, unnecessary time resource waste can be avoided, and the development efficiency is further improved.
Referring to fig. 3, the embodiment of the application discloses a file compiling method, which comprises the following steps:
and S21, acquiring a target source file and generating a to-be-processed abstract syntax tree corresponding to the target source file.
And S22, acquiring a pre-configured target plug-in annotation processor corresponding to the target source file.
Step S23, based on the target plug-in annotation processor, corresponding annotation scanning operation is executed by utilizing the annotation set information of the target plug-in annotation processor, and a plurality of variables to be filled corresponding to the target source file are obtained.
And step S24, variable definitions corresponding to the variables to be filled are obtained from the abstract syntax tree to be processed.
And S25, respectively executing corresponding real value filling operation on each variable definition by utilizing the target plug-in annotation processor so as to complete corresponding information automatic writing operation, so that compiling operation corresponding to the target source file is completed according to the obtained processed abstract syntax tree, and a corresponding byte code file is obtained.
For the specific process from step S21 to step S25, reference may be made to the corresponding content disclosed in the foregoing embodiment, and no further description is given here.
Therefore, in the embodiment of the application, through utilizing the target plug-in annotation processor corresponding to the target source file and utilizing the annotation set information of the target plug-in annotation processor to complete the corresponding information automatic injection operation in the compiling stage, the information which cannot be acquired when the byte code file is operated can be read, including but not limited to the pon information, the Git information and the construction information, and other information can be expanded by adding other types of custom annotation information according to actual requirements.
Referring to fig. 4, the embodiment of the present application further correspondingly discloses a file compiling device, including:
a file obtaining module 11, configured to obtain a target source file, and generate a to-be-processed abstract syntax tree corresponding to the target source file;
a processor acquisition module 12 for acquiring a pre-configured target insert annotation processor corresponding to the target source file;
and the information writing module 13 is used for executing corresponding information automatic writing operation on the basis of the target plug-in annotation processor to-be-processed abstract syntax tree so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file.
The more specific working process of each module may refer to the corresponding content disclosed in the foregoing embodiment, and will not be described herein.
Thus, according to the embodiment of the application, the target source file is obtained, and the abstract syntax tree to be processed corresponding to the target source file is generated; acquiring a pre-configured target insert annotation processor corresponding to the target source file; and executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file. In the process of compiling the file, the corresponding information automatic writing operation is executed by the preset plug-in annotation processor, so that the running performance of the obtained byte code file can be effectively improved, the compiling accuracy is ensured, the workload of relevant developers is reduced, unnecessary time resource waste can be avoided, and the development efficiency is further improved.
In some specific embodiments, the file compiling apparatus may specifically further include:
the annotation set acquisition module is used for marking variables to be filled in the target source file through a plurality of custom annotation classes which are created in advance, and obtaining corresponding annotation set information based on each custom annotation class.
In some specific embodiments, the real value filling submodule may specifically include:
and the real value filling unit is used for respectively executing corresponding real value acquisition operation based on the custom annotation information corresponding to each variable to be filled, and respectively filling corresponding variable definitions based on the acquired real values so as to obtain a plurality of corresponding filled variable definitions.
In some embodiments, the real value filling unit may be specifically configured to obtain and parse a corresponding pon file by using a preset XML parser if the custom annotation information corresponding to the current variable to be filled belongs to a first type of preset annotation, so as to complete a corresponding first real value obtaining operation; if the custom annotation information belongs to a second type of preset annotation, acquiring corresponding Git branch information by using JGit to finish corresponding second true value acquisition operation; if the custom annotation information belongs to a third type of preset annotation, acquiring current time information based on a preset constructor function so as to complete corresponding third true value acquisition operation.
In some embodiments, the real value filling unit is specifically configured to perform a real value filling operation corresponding to each of the variable definitions by performing corresponding processing on a predefined related interface class.
Further, the embodiment of the present application further discloses an electronic device, and fig. 5 is a block diagram of an electronic device 20 according to an exemplary embodiment, where the content of the figure is not to be considered as any limitation on the scope of use of the present application.
Fig. 5 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein the memory 22 is configured to store a computer program that is loaded and executed by the processor 21 to implement the relevant steps in the file compiling method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide an operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol to be followed is any communication protocol applicable to the technical solution of the present application, which is not specifically limited herein; the input/output interface 25 is used for acquiring external input data or outputting external output data, and the specific interface type thereof may be selected according to the specific application requirement, which is not limited herein.
The memory 22 may be a carrier for storing resources, such as a read-only memory, a random access memory, a magnetic disk, or an optical disk, and the resources stored thereon may include an operating system 221, a computer program 222, and the like, and the storage may be temporary storage or permanent storage.
The operating system 221 is used for managing and controlling various hardware devices on the electronic device 20 and computer programs 222, which may be Windows Server, netware, unix, linux, etc. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the file compilation method performed by the electronic device 20 as disclosed in any of the previous embodiments.
Further, the application also discloses a computer readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the file compiling method disclosed above. For specific steps of the method, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and no further description is given here.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing has outlined rather broadly the more detailed description of the application in order that the detailed description of the application that follows may be better understood, and in order that the present principles and embodiments may be better understood; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.
Claims (10)
1. A method of compiling a file, comprising:
acquiring a target source file and generating an abstract syntax tree to be processed, which corresponds to the target source file;
acquiring a pre-configured target insert annotation processor corresponding to the target source file;
and executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file.
2. The method of claim 1, wherein the performing, based on the target-inserted annotation processor, a corresponding information automatic write operation on the abstract syntax tree to be processed, comprises:
based on the target plug-in annotation processor, executing corresponding annotation scanning operation by utilizing the annotation set information of the target plug-in annotation processor to obtain a plurality of variables to be filled corresponding to the target source file;
variable definitions corresponding to the variables to be filled are obtained from the abstract syntax tree to be processed;
and respectively executing corresponding real value filling operation on each variable definition by using the target plug-in annotation processor so as to complete corresponding information automatic writing operation.
3. The file compiling method according to claim 2, further comprising:
marking variables to be filled in the target source file through a plurality of custom annotation classes which are created in advance, and obtaining corresponding annotation set information based on each custom annotation class.
4. A method according to claim 3, wherein said performing, with said target-inserted annotation processor, a respective real-valued fill operation on each of said variable definitions, respectively, comprises:
and respectively executing corresponding real value acquisition operation based on the custom annotation information corresponding to each variable to be filled, and respectively filling corresponding variable definitions based on the acquired real values so as to obtain a plurality of corresponding filled variable definitions.
5. The method according to claim 4, wherein the performing the respective real value acquisition operations based on the custom annotation information corresponding to each of the variables to be filled, respectively, includes:
if the custom annotation information corresponding to the current variable to be filled belongs to a first type of preset annotation, acquiring and analyzing a corresponding pore file by using a preset XML analyzer so as to finish a corresponding first true value acquisition operation;
if the custom annotation information belongs to a second type of preset annotation, acquiring corresponding Git branch information by using JGit to finish corresponding second true value acquisition operation;
if the custom annotation information belongs to a third type of preset annotation, acquiring current time information based on a preset constructor function so as to complete corresponding third true value acquisition operation.
6. The method of claim 4, wherein said performing, with said target-inserted annotation processor, a corresponding real-valued fill operation on each of said variable definitions, respectively, comprises:
and performing corresponding processing on the predefined related interface class to complete the real value filling operation corresponding to each variable definition.
7. A document compiling apparatus, comprising:
the file acquisition module is used for acquiring a target source file and generating an abstract syntax tree to be processed, which corresponds to the target source file;
a processor acquisition module for acquiring a preconfigured target insert annotation processor corresponding to the target source file;
and the information writing module is used for executing corresponding information automatic writing operation on the abstract syntax tree to be processed based on the target plug-in annotation processor so as to finish compiling operation corresponding to the target source file according to the obtained processed abstract syntax tree and obtain a corresponding byte code file.
8. The file compiling apparatus according to claim 7, wherein the information writing module comprises:
the annotation scanning unit is used for executing corresponding annotation scanning operation by utilizing the annotation set information of the object plug-in annotation processor based on the object plug-in annotation processor to obtain a plurality of variables to be filled corresponding to the object source file;
a variable definition obtaining unit, configured to obtain variable definitions corresponding to the variables to be filled from the abstract syntax tree to be processed;
and the real value filling sub-module is used for respectively executing corresponding real value filling operation on each variable definition by utilizing the target plug-in annotation processor so as to complete corresponding information automatic writing operation.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the file compiling method according to any one of claims 1 to 6.
10. A computer readable storage medium for storing a computer program which when executed by a processor implements the file compilation method of any of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311248416.0A CN117170684A (en) | 2023-09-25 | 2023-09-25 | File compiling method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311248416.0A CN117170684A (en) | 2023-09-25 | 2023-09-25 | File compiling method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117170684A true CN117170684A (en) | 2023-12-05 |
Family
ID=88935457
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311248416.0A Pending CN117170684A (en) | 2023-09-25 | 2023-09-25 | File compiling method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117170684A (en) |
-
2023
- 2023-09-25 CN CN202311248416.0A patent/CN117170684A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8893077B1 (en) | Service to generate API libraries from a description | |
US6907572B2 (en) | Command line interface abstraction engine | |
KR101795844B1 (en) | Runtime system | |
WO2019233293A1 (en) | Method and apparatus for developing application program | |
US20040158820A1 (en) | System for generating an application framework and components | |
CN113076096B (en) | Desktop application program development method, device, equipment and storage medium | |
CN112799677B (en) | Method, device, equipment and storage medium for hook of compiling period | |
US6934940B2 (en) | Source code transformation-temporary object reduction | |
US20090328016A1 (en) | Generalized expression trees | |
US8756258B2 (en) | Generating references to reusable code in a schema | |
CN112000320A (en) | Automatic code generation method, device, equipment and storage medium | |
CN112667287A (en) | Method, device and equipment for creating rule file and computer readable storage medium | |
CN105354073A (en) | Android system based standalone application networking method and system | |
US9244706B2 (en) | Command line shell command generation based on schema | |
US11630645B2 (en) | System and method for managing and using data model | |
CN115951890A (en) | Method, system and device for code conversion between different front-end frames | |
CN117170684A (en) | File compiling method, device, equipment and storage medium | |
Soude et al. | A model driven approach for unifying user interfaces development | |
CN113885844A (en) | Business service arranging method and related device | |
CN113360156A (en) | IOS compiling method and related equipment | |
CN112181398A (en) | Configuration file processing device, method and storage medium | |
Trivedi | Building a Web App with Blazor and ASP. Net Core: Create a Single Page App with Blazor Server and Entity Framework Core | |
CN117971228A (en) | Automatic generation method and system for C# code and electronic device | |
Chebanyuk et al. | An Approach for Design of Architectural Solutions Based on Software Model-To-Model Transformation | |
Juhnke et al. | LCDL: an extensible framework for wrapping legacy code |
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 |