CN112882716A - Code text processing method and device, computer equipment and storage medium - Google Patents
Code text processing method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN112882716A CN112882716A CN202110184710.4A CN202110184710A CN112882716A CN 112882716 A CN112882716 A CN 112882716A CN 202110184710 A CN202110184710 A CN 202110184710A CN 112882716 A CN112882716 A CN 112882716A
- Authority
- CN
- China
- Prior art keywords
- text
- line
- target
- unit
- target single
- 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
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/427—Parsing
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The application relates to a code text processing method, a code text processing device, computer equipment and a storage medium. The method comprises the following steps: acquiring a target code text, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text, and acquiring line number information corresponding to the target single-line text; segmenting the target single-line text according to a grammar parsing rule of a programming language to obtain at least one text unit of the target single-line text; acquiring feature information of the text unit, matching a corresponding rendering rule according to the feature information, and rendering the text unit according to the rendering rule; and displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text. Based on the code text processed and displayed by the method, a user can efficiently and accurately analyze the position of the grammatical error in the code.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a code text processing method and apparatus, a computer device, and a storage medium.
Background
With the development of computer technology, code editors have emerged, which are text editors for writing computer programs, which are usually stand-alone applications, either existing as part of an integrated development environment, or a web editor running in a browser.
However, in the conventional RPA (Robotic Process Automation) design Process, a code editor having only a simple text editing function is used for editing the flow code, the display form of the code text is relatively single, and the code editor does not have a prompt function such as highlighting grammar, and thus, a user has a poor look and feel when reviewing the code and cannot quickly find out a grammar problem existing in the code according to the display effect of the code.
Disclosure of Invention
In view of the above, it is necessary to provide a code text processing method, apparatus, computer device and storage medium for efficiently and accurately checking syntax errors of code texts displayed by a user based on the code text processing method.
A code text processing method, the method comprising:
acquiring a target code text, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text, and acquiring line number information corresponding to the target single-line text;
segmenting the target single-line text according to a grammar parsing rule of a programming language to obtain at least one text unit of the target single-line text;
acquiring feature information of the text unit, matching a corresponding rendering rule according to the feature information, and rendering the text unit according to the rendering rule;
and displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text.
In one embodiment, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text, includes:
and carrying out full scanning on the target code text, acquiring a line change separator in the target code text, and splitting the target code text into at least one target single-line text taking lines as units according to the line change separator.
In one embodiment, segmenting the target single-line text according to the grammar parsing rules of the programming language includes:
and acquiring characters of a preset type in the target single-line text according to a grammar parsing rule of the programming language, and segmenting the target single-line text according to the characters of the preset type.
In one embodiment, the feature information refers to feature information of text contained in a text unit, and the rendering rule includes at least one of a rendering rule of a text font color, a rendering rule of a text font size, a rendering rule of a text font style, and a rendering rule of a text background style.
In one embodiment, displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text includes:
generating a line number identifier according to line number information corresponding to the target single-line text;
and displaying the line number identification on a display interface, and displaying the rendered text unit at the corresponding position indicated by the line number identification.
In one embodiment, the method further comprises:
when detecting that the position of the cursor generates a text change operation, judging whether the line number of the code text subjected to the text change operation is changed;
and if so, taking the changed line with the text change and the text in the line behind the changed line as the target code text, re-splitting the target code text by taking the line as a splitting unit to obtain at least one target single-line text, and acquiring the line number information corresponding to the target single-line text.
In one embodiment, the method further comprises:
if not, the single-line text with the text change and the single-line text behind the single-line text with the text change are respectively used as target single-line texts, and the step of segmenting the target single-line text according to the grammar parsing rule of the programming language is carried out.
A code text processing apparatus, said apparatus comprising:
the single-line text acquisition module is used for acquiring a target code text, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text and acquiring line number information corresponding to the target single-line text;
the text unit acquisition module is used for segmenting the target single-line text according to the grammar parsing rule of the programming language to obtain at least one text unit of the target single-line text;
the rendering rule matching module is used for acquiring the characteristic information of the text unit, matching the corresponding rendering rule according to the characteristic information and rendering the text unit according to the rendering rule;
and the text unit display module is used for displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the code text processing method when executing the computer program:
a computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the code text processing method described above.
According to the code text processing method, the code text processing device, the computer equipment and the storage medium, the target code text is split according to the lines, the split single-line text is further split into text units according to the grammar parsing rule, corresponding rendering processing is carried out according to the feature information of each split text unit, and then the rendered text units are displayed according to the corresponding line number. When a user checks errors according to the code text displayed based on the method, the user can firstly determine which line a grammar error occurs in according to the line number information, and then can efficiently and accurately analyze the position of the grammar error in the code according to different rendering effects presented by text units representing different grammars.
Drawings
FIG. 1 is a diagram of an application environment of a code text processing method in one embodiment;
FIG. 2 is a flowchart illustrating a code text processing method according to an embodiment;
FIG. 3 is a logic diagram of a code text processing method in an application example;
FIG. 4A is a diagram illustrating an effect of an application example before the code text processing method of the present application is used;
FIG. 4B is a diagram illustrating an effect of the code text processing method according to the present application after being used in an application example;
FIG. 5 is a block diagram showing the structure of a code text processing apparatus according to an embodiment
FIG. 6 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It is to be understood that the term "and/or", as used herein, describes an associative relationship of associated objects, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The code text processing method provided by the application can be applied to the application environment shown in FIG. 1. When the terminal 102 receives an instruction for displaying a code text, a target code text is obtained, the target code text is split by taking a line as a splitting unit to obtain at least one target single-line text, line number information corresponding to the target single-line text is obtained, the target single-line text is segmented according to a grammar parsing rule of a programming language to obtain at least one text unit of the target single-line text, characteristic information of the text unit is obtained, a corresponding rendering rule is matched according to the characteristic information, the text unit is rendered according to the rendering rule, and the rendered text unit is displayed on a display interface according to the line number information corresponding to the target single-line text. The terminal 102 may be, but is not limited to, various personal computers, laptops, smartphones, terminal servers, tablets, and portable wearable devices.
In one embodiment, as shown in fig. 2, a code text processing method is provided, which is described by taking the application of the method to the terminal in fig. 1 as an example, and includes the following steps:
step S202: and acquiring a target code text, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text, and acquiring line number information corresponding to the target single-line text.
The code text may refer to a process code text that can be opened by a robot process automation design device in an RPA design process, and the target code text refers to a code text designated to be applied with the code text processing method according to the scheme. The single line of text can be used as an independent line object, and the single line of text is generally separated by a line separator such as a space.
Specifically, the terminal may obtain, according to a selection instruction of a user, a flow code text designated as a display object as a target code text, split the target code text into at least one single-line text with lines as units by performing operations such as reading and analyzing on the target code text, and use the split single-line text as a target single-line text for subsequent processing. In the splitting process, the total number of single-line texts which can be split from the target code text can be measured and calculated, and the line number information corresponding to the target single-line text can be determined according to the position of the target single-line text in the target code text, namely the target single-line text is the split line of texts. Further, when the split single-line text is multiple lines, a text list containing the multiple lines of single-line text and information of corresponding lines can be generated.
Step S204: and segmenting the target single-line text according to a grammar parsing rule of the programming language to obtain at least one text unit of the target single-line text.
The programming language is not limited, and may be Python, C language++The programming languages, namely the code text processing method, the code text processing device and the like can support the extension of various programming languages.
Specifically, since different programming languages have different grammatical rules, for example, different programming languages have different definitions for each type of characters such as keywords, operators, separators, and the like, the corresponding grammar parsing rule can be obtained according to the specified programming language, and the target single-line text can be segmented according to the corresponding grammar parsing rule, so as to obtain at least one text unit belonging to the target single-line text. Further, when a plurality of text units are obtained by dividing a single line of text, a unit list belonging to the single line of text may be generated, and each text unit in the unit list is associated with the line number information of the single line of text.
Step S206: and acquiring the feature information of the text unit, matching a corresponding rendering rule according to the feature information, and rendering the text unit according to the rendering rule.
The feature information refers to feature information of a text contained in a text unit, and the text contained in the text unit may belong to different types such as keywords, operators, character strings or annotations according to different grammar parsing rules, so that the text unit has different feature information. The rendering rules may include rendering rules of text font color, rendering rules of text font size, rendering rules of text font style, rendering rules of text background, text box, text list and other styles, and the like.
Specifically, the feature information of the text unit may be determined according to the type to which the text unit belongs, the matching of the rendering rule is performed according to the obtained feature information, and rendering processing such as coloring, scaling, text rendering, and the like is performed on each text unit according to the matched rendering rule. And different feature information is correspondingly matched with different rendering rules. For example, the keywords, the separators are colored blue, the character strings are colored gray, the annotations are colored green, and the like, which are only used for illustration and are not limited to the rendering rule.
Step S208: and displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text.
Specifically, the line number of the rendered text unit when displayed can be determined according to the line number information corresponding to the target single-line text, that is, the rendered text unit is displayed in the line corresponding to the target single-line text to which the rendered text unit belongs.
According to the code text processing method, the target code text is split according to the lines, the split single-line text is further split into text units according to the grammar parsing rule, corresponding rendering processing is carried out according to the feature information of each split text unit, and the rendered text units are displayed according to the corresponding line number. When a user checks errors according to the code text displayed based on the method, the user can firstly determine which line a grammar error occurs in according to the line number information, and then can efficiently and accurately analyze the position of the grammar error in the code according to different rendering effects presented by text units representing different grammars.
In one embodiment, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text, includes: and carrying out full scanning on the target code text, acquiring a line change separator in the target code text, and splitting the target code text into at least one target single-line text taking lines as units according to the line change separator.
In this embodiment, the line change separator in the target code text may be recognized through full scanning, different symbols may be used as the line change separator in different programming language environments, for example, a space, a semicolon, or the like may be used as the line change separator, so that which kind of symbol the line change separator in the current environment is determined according to different programming language environments, and then recognition may be performed. The entire target code text can be quickly split into one or more lines of single-line text in line units by identifying line-changing separators, and each single line of text is taken as an independent line object (target single-line text).
In one embodiment, segmenting the target single-line text according to the grammar parsing rules of the programming language includes: and acquiring characters of a preset type in the target single-line text according to a grammar parsing rule of the programming language, and segmenting the target single-line text according to the characters of the preset type.
In this embodiment, the preset type of characters refers to characters that are set according to grammar rules of a programming language and can reflect different types of grammars in the programming language, for example, the preset type of characters may include keywords, operators, character strings, and/or separators (spaces, commas, or parentheses), and the like, specifically, the preset type of characters in the target single-line text may be parsed according to the grammar parsing rules, and the target single-line text may be segmented into one or more text units that conform to the grammar parsing rules according to the parsing results, so that the segmented text units may well reflect the grammar rules of the codes.
In one embodiment, displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text includes: generating a line number identifier according to line number information corresponding to the target single-line text; and displaying the line number identification on a display interface, and displaying the rendered text unit at the corresponding position indicated by the line number identification.
In this embodiment, the rendered text unit is displayed on the display interface, a line number identifier capable of identifying the position of the single-line text can be generated according to the line number information corresponding to each single-line text, the line number identifier is displayed on the display interface, and the rendered text unit is displayed at the position indicated by the line number identifier. Through the display mode, the user can more quickly and accurately determine the position of the line object (target single-line text) with the error according to the line number identification, and determine the position of the unit object (text unit) with the grammar error according to different rendering effects.
In one embodiment, the method further comprises: when detecting that the position of the cursor generates a text change operation, judging whether the line number of the code text subjected to the text change operation is changed; and if so, taking the changed line with the text change and the text in the line behind the changed line as the target code text, re-splitting the target code text by taking the line as a splitting unit to obtain at least one target single-line text, and acquiring the line number information corresponding to the target single-line text.
In this embodiment, the technical solution related to the present application also supports editing and modifying a code text. When a user performs changing operations such as inputting, pasting, deleting and the like on a text at the position of a cursor through an external device and the like, whether the line number of the modified code text is changed or not can be judged, if yes, the text in the changed line and all lines behind the changed line can be analyzed, split, divided, rendered and displayed again according to the method from the changed line, and therefore when the code text is in an editable state, the line number information can be dynamically updated according to the change of the text, and the edited code text can be accurately rendered and displayed.
In one embodiment, the above method further comprises: if not, the single-line text with the text change and the single-line text behind the single-line text with the text change are respectively used as target single-line texts, and the step of segmenting the target single-line text according to the grammar parsing rule of the programming language is carried out.
In this embodiment, if the line number of the modified code text is not changed, it is not necessary to perform the splitting of the single-line text, the line number calculation, or the updating of the line number information, but even a minor modification (for example, adding a preceding bracket) may cause a change in syntax, thereby affecting the execution of the subsequent code.
The following describes the code text processing method according to the present invention in further detail with reference to an application example. As shown in fig. 3, fig. 3 is a logic diagram of a code text processing method in an application example. The concrete description is as follows:
A. entering an RPA code editor (designer) to open any flow code file;
B. clicking to execute a main menu, and clicking a preview script button in a submenu of the main menu;
C. the picture as shown in fig. 4B appears and the entire process ends.
In the processes of B and C, the code text is processed and displayed by the code text processing method according to the present application, and the specific processes are as follows:
1. reading a flow code file;
2. a line analysis module (a single-line text acquisition module) splits the read full text of the code text to obtain a plurality of single-line texts and a line list;
3. when the line number of the full text changes due to a user or any reason, the line analysis module increases or decreases the line information of the changed part so as to enable the line list to always correspond to the current full text;
4. judging whether the current display area changes, wherein the display area is a row list area displayed to a user and the vertical or horizontal scroll bar is generally moved by the user to change;
5. if the display area is not changed, whether the line where the current cursor is located has text change or not still needs to be judged, if yes, the input line and all input lines displayed below the input line are measured and calculated again by a unit analysis module (a text unit acquisition module);
6. the unit analysis module analyzes the single-line texts of each line to obtain a unit list of each line again;
7. the rendering rule matching module performs feature analysis on each unit in the unit list in the row to be displayed to obtain the characteristic information of each unit, and performs rendering according to the features;
8. and the text unit display module displays each rendered unit in a corresponding line.
9. By this time, all units are processed and the content is seen by the user. Referring to fig. 4A to 4B, fig. 4A shows an effect diagram before the code text processing method of the present application is used, and fig. 4B shows an effect diagram after the code text processing method of the present application is used.
Comparing the two figures, it is obvious that after the code text is processed by the method of the application, the impression effect of the user during review is obviously improved. When an error occurs and the error position is reported when the process is operated, the user can quickly locate the code part with the exception according to the line number identification. If the scheme related to the application is not utilized for processing, the user can only search sentence by sentence line by line in a naked eye mode, and the effect brought by the application improves the efficiency of the user for processing the problems by times. The former processing speed needs at least more than 20 seconds according to the code content, even more, the code content is measured according to minutes when the code content is excessive, and the positioning speed of the grammar error is generally not more than 5 seconds after the scheme related to the application is used for processing.
It should be understood that although the various steps in the flow charts of fig. 2-3 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-3 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 5, there is provided a code text processing apparatus including: a single-line text acquisition module 10, a text unit acquisition module 20, a rendering rule matching module 30, and a text unit presentation module 40, wherein:
a single-line text acquisition module 10, configured to acquire a target code text, split the target code text by using a line as a splitting unit to obtain at least one target single-line text, and acquire line number information corresponding to the target single-line text;
the text unit obtaining module 20 is configured to segment the target single-line text according to a syntax parsing rule of the programming language to obtain at least one text unit of the target single-line text;
the rendering rule matching module 30 is configured to obtain feature information of the text unit, match a corresponding rendering rule according to the feature information, and perform rendering processing on the text unit according to the rendering rule;
and the text unit display module 40 is configured to display the rendered text unit on a display interface according to the line number information corresponding to the target single-line text.
In one embodiment, the single-line text obtaining module 10 performs full scan on the target code text, obtains a line change separator in the target code text, and splits the target code text into at least one target single-line text with lines as units according to the line change separator.
In one embodiment, the text unit obtaining module 20 obtains a preset type of characters in the target single-line text according to a syntax parsing rule of the programming language, and segments the target single-line text according to the preset type of characters.
In one embodiment, the text unit displaying module 40 generates a line number identifier according to the line number information corresponding to the target single-line text; and displaying the line number identification on a display interface, and displaying the rendered text unit at the corresponding position indicated by the line number identification.
In one embodiment, the text unit displaying module 40 is further configured to determine whether the line number of the code text after the text change operation is changed when the text change operation is detected at the position of the cursor; if yes, the single-line text obtaining module 10 is further configured to take the text in the changed line where the text is changed and the line after the changed line as the target code text, re-enter the step of splitting the target code text by taking the line as a splitting unit to obtain at least one target single-line text, and obtain line number information corresponding to the target single-line text.
In an embodiment, the text unit obtaining module 20 is further configured to, if not, take the single-line text with the text change and the single-line text after the single-line text with the text change as target single-line texts, and perform a step of segmenting the target single-line text according to a syntax parsing rule of the programming language.
For specific limitations of the code text processing device, reference may be made to the above limitations of the code text processing method, which are not described herein again. The modules in the code text processing device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a code text processing method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 6 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program: acquiring a target code text, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text, and acquiring line number information corresponding to the target single-line text; segmenting the target single-line text according to a grammar parsing rule of a programming language to obtain at least one text unit of the target single-line text; acquiring feature information of the text unit, matching a corresponding rendering rule according to the feature information, and rendering the text unit according to the rendering rule; and displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text.
In one embodiment, when the processor executes the computer program to split the target code text by using a line as a splitting unit to obtain at least one target single-line text, the following steps are specifically implemented: and carrying out full scanning on the target code text, acquiring a line change separator in the target code text, and splitting the target code text into at least one target single-line text taking lines as units according to the line change separator.
In one embodiment, when the processor executes the computer program to segment the target single-line text according to the grammar parsing rule of the programming language, the following steps are specifically realized: and acquiring characters of a preset type in the target single-line text according to a grammar parsing rule of the programming language, and segmenting the target single-line text according to the characters of the preset type.
In one embodiment, when the processor executes the computer program to display the rendered text unit on the display interface according to the line number information corresponding to the target single-line text, the following steps are specifically implemented: generating a line number identifier according to line number information corresponding to the target single-line text; and displaying the line number identification on a display interface, and displaying the rendered text unit at the corresponding position indicated by the line number identification.
In one embodiment, execution of the computer program by the processor further implements the steps of: when detecting that the position of the cursor generates a text change operation, judging whether the line number of the code text subjected to the text change operation is changed; and if so, taking the changed line with the text change and the text in the line behind the changed line as the target code text, re-splitting the target code text by taking the line as a splitting unit to obtain at least one target single-line text, and acquiring the line number information corresponding to the target single-line text.
In one embodiment, execution of the computer program by the processor further implements the steps of: if not, the single-line text with the text change and the single-line text behind the single-line text with the text change are respectively used as target single-line texts, and the step of segmenting the target single-line text according to the grammar parsing rule of the programming language is carried out.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of: acquiring a target code text, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text, and acquiring line number information corresponding to the target single-line text; segmenting the target single-line text according to a grammar parsing rule of a programming language to obtain at least one text unit of the target single-line text; acquiring feature information of the text unit, matching a corresponding rendering rule according to the feature information, and rendering the text unit according to the rendering rule; and displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text.
In one embodiment, when the computer program is executed by the processor to split the target code text by using the line as a splitting unit to obtain at least one target single-line text, the following steps are specifically implemented: and carrying out full scanning on the target code text, acquiring a line change separator in the target code text, and splitting the target code text into at least one target single-line text taking lines as units according to the line change separator.
In one embodiment, when the computer program is executed by the processor to segment the target single-line text according to the grammar parsing rule of the programming language, the following steps are specifically realized: and acquiring characters of a preset type in the target single-line text according to a grammar parsing rule of the programming language, and segmenting the target single-line text according to the characters of the preset type.
In one embodiment, when the computer program is executed by the processor to display the rendered text unit on the display interface according to the line number information corresponding to the target single-line text, the following steps are specifically implemented: generating a line number identifier according to line number information corresponding to the target single-line text; and displaying the line number identification on a display interface, and displaying the rendered text unit at the corresponding position indicated by the line number identification.
In one embodiment, the computer program when executed by the processor further performs the steps of: when detecting that the position of the cursor generates a text change operation, judging whether the line number of the code text subjected to the text change operation is changed; and if so, taking the changed line with the text change and the text in the line behind the changed line as the target code text, re-splitting the target code text by taking the line as a splitting unit to obtain at least one target single-line text, and acquiring the line number information corresponding to the target single-line text.
In one embodiment, the computer program when executed by the processor further performs the steps of: if not, the single-line text with the text change and the single-line text behind the single-line text with the text change are respectively used as target single-line texts, and the step of segmenting the target single-line text according to the grammar parsing rule of the programming language is carried out.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. A code text processing method, the method comprising:
acquiring a target code text, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text, and acquiring line number information corresponding to the target single-line text;
segmenting the target single-line text according to a grammar parsing rule of a programming language to obtain at least one text unit of the target single-line text;
acquiring feature information of the text unit, matching a corresponding rendering rule according to the feature information, and rendering the text unit according to the rendering rule;
and displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text.
2. The method of claim 1, wherein the splitting the target code text with lines as splitting units to obtain at least one target single line of text comprises:
and carrying out full scanning on the target code text, acquiring a line change separator in the target code text, and splitting the target code text into at least one target single-line text with lines as units according to the line change separator.
3. The method of claim 1, wherein the segmenting the target single-line text according to the parsing rule of the programming language comprises:
and acquiring characters of a preset type in the target single-line text according to a grammar parsing rule of a programming language, and segmenting the target single-line text according to the characters of the preset type.
4. The method according to claim 1, wherein the feature information is feature information of text included in the text unit, and the rendering rule includes at least one of a rendering rule of a text font color, a rendering rule of a text font size, a rendering rule of a text font style, and a rendering rule of a text background style.
5. The method according to claim 1, wherein the displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text comprises:
generating a line number identifier according to the line number information corresponding to the target single-line text;
displaying the line number identification on a display interface, and displaying the rendered text unit at the corresponding position indicated by the line number identification.
6. The method according to any one of claims 1 to 5, further comprising:
when detecting that the position of the cursor generates a text change operation, judging whether the line number of the code text after the text change operation is changed;
and if so, taking the changed line with the text change and the text in the line behind the changed line as target code texts, re-entering the step of splitting the target code texts by taking the line as a splitting unit to obtain at least one target single-line text, and acquiring line number information corresponding to the target single-line text.
7. The method of claim 6, further comprising:
if not, the single-line text with the text change and the single-line text behind the single-line text with the text change are respectively used as the target single-line text, and the step of segmenting the target single-line text according to the grammar parsing rule of the programming language is carried out.
8. A code text processing apparatus, characterized in that the apparatus comprises:
the single-line text acquisition module is used for acquiring a target code text, splitting the target code text by taking a line as a splitting unit to obtain at least one target single-line text and acquiring line number information corresponding to the target single-line text;
the text unit acquisition module is used for segmenting the target single-line text according to a grammar parsing rule of a programming language to obtain at least one text unit of the target single-line text;
the rendering rule matching module is used for acquiring the feature information of the text unit, matching a corresponding rendering rule according to the feature information, and rendering the text unit according to the rendering rule;
and the text unit display module is used for displaying the rendered text unit on a display interface according to the line number information corresponding to the target single-line text.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 7 are implemented when the computer program is executed by the processor.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110184710.4A CN112882716A (en) | 2021-02-10 | 2021-02-10 | Code text processing method and device, computer equipment and storage medium |
CA3148441A CA3148441A1 (en) | 2021-02-10 | 2022-02-10 | Code text processing method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110184710.4A CN112882716A (en) | 2021-02-10 | 2021-02-10 | Code text processing method and device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112882716A true CN112882716A (en) | 2021-06-01 |
Family
ID=76057572
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110184710.4A Pending CN112882716A (en) | 2021-02-10 | 2021-02-10 | Code text processing method and device, computer equipment and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN112882716A (en) |
CA (1) | CA3148441A1 (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114239562A (en) * | 2021-12-27 | 2022-03-25 | 沈阳哲航信息科技有限公司 | Method, device and equipment for identifying program code blocks in document |
CN114970448A (en) * | 2022-05-31 | 2022-08-30 | 北京沃东天骏信息技术有限公司 | Information display method and device, and storage medium |
CN119720938A (en) * | 2024-12-20 | 2025-03-28 | 京东方科技集团股份有限公司 | Text processing method and device, electronic device and computer-readable storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107797794A (en) * | 2017-10-17 | 2018-03-13 | 北京华航唯实机器人科技股份有限公司 | Edit methods, device, storage medium, processor and the terminal of program code |
CN110674033A (en) * | 2019-09-09 | 2020-01-10 | 平安普惠企业管理有限公司 | Method, device and equipment for processing code and storage medium |
-
2021
- 2021-02-10 CN CN202110184710.4A patent/CN112882716A/en active Pending
-
2022
- 2022-02-10 CA CA3148441A patent/CA3148441A1/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107797794A (en) * | 2017-10-17 | 2018-03-13 | 北京华航唯实机器人科技股份有限公司 | Edit methods, device, storage medium, processor and the terminal of program code |
CN110674033A (en) * | 2019-09-09 | 2020-01-10 | 平安普惠企业管理有限公司 | Method, device and equipment for processing code and storage medium |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114239562A (en) * | 2021-12-27 | 2022-03-25 | 沈阳哲航信息科技有限公司 | Method, device and equipment for identifying program code blocks in document |
CN114239562B (en) * | 2021-12-27 | 2024-10-11 | 沈阳哲航信息科技有限公司 | Method, device and equipment for identifying program code blocks in document |
CN114970448A (en) * | 2022-05-31 | 2022-08-30 | 北京沃东天骏信息技术有限公司 | Information display method and device, and storage medium |
CN119720938A (en) * | 2024-12-20 | 2025-03-28 | 京东方科技集团股份有限公司 | Text processing method and device, electronic device and computer-readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CA3148441A1 (en) | 2022-08-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10929449B2 (en) | Generating a structured document guiding view | |
US20200401431A1 (en) | Adaptive web-based robotic process automation | |
US7046848B1 (en) | Method and system for recognizing machine generated character glyphs and icons in graphic images | |
CN112882716A (en) | Code text processing method and device, computer equipment and storage medium | |
CN110955608B (en) | Test data processing method, device, computer equipment and storage medium | |
CN111176996A (en) | Test case generation method, device, computer equipment and storage medium | |
US20110270858A1 (en) | File type recognition analysis method and system | |
JP6354457B2 (en) | Application development support apparatus, data processing method thereof, and program | |
CN109189686A (en) | Automation regression testing method, apparatus, storage medium and computer equipment | |
CN115081440B (en) | Method, device and device for identifying variant words in text and extracting original sensitive words | |
CN112835579A (en) | Method, apparatus, electronic device and storage medium for determining interface code | |
CN113657361A (en) | Page abnormity detection method and device and electronic equipment | |
CN113641933A (en) | Abnormal webpage identification method, abnormal site identification method and device | |
CN112612469A (en) | Interface element processing method and device and electronic equipment | |
CN112596803A (en) | Control string truncation checking method and device, computer equipment and storage medium | |
CN113419721A (en) | Web-based expression editing method, device, equipment and storage medium | |
CN113805861B (en) | Code generation method based on machine learning, code editing system and storage medium | |
CN110908570B (en) | Image processing method, device, terminal and storage medium | |
CN113885857A (en) | Method and device for acquiring visual component and storage medium | |
JP4466241B2 (en) | Document processing method and document processing apparatus | |
CN113918165A (en) | Method and system for compiling text description type flow description into application automatic operation script | |
CN113392624A (en) | Sensitive vocabulary labeling method and device, electronic equipment and computer readable storage medium | |
KR102782734B1 (en) | System, method, and program for performance evaluation of chart derendering model using artificial intelligence | |
CN119150302B (en) | A method and system for intelligent mining of software security vulnerabilities based on large language model | |
US12424009B1 (en) | Processing techniques for fast and accurate identification of application screens using optical character recognition |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210601 |