简体   繁体   中英

How eclipse senses the things like break loop end, keywords etc.?

i tried searching on the net for this query but couldn't find proper answer. here is my question.

i noticed that eclipse editor points the loop when we select(highlight) break; can anyone help me knowing how technically does it know that loop end? Eg

快照 also things like if we highlight some variable, it highlights all the mentions of the same and similarly when we write code it changes colour of keywords etc.

Please See, i want to know how it does these things behind the scene technically.

The Eclipse JDT (Java Development Tools) is the Eclipse project that provides many plugins for supporting the development of any Java application. The JDT Core component provides the Java Document Model, that itself is an API for reading/manipulating structured Java source documents.

The Java Document Model is - among others - based around an AST (abstract syntax tree), which is build up from the source code. This AST contains nodes for representing elements like fields, variables, statements (break is a statement), and it also contains many more nodes for representing the references to other nodes. If you declare a variable and use that variable in other code places, then these usages are known as references. A reference to a field and a reference to a variable with the same name are indeed other references.

So, basically, Eclipse runs through the AST for finding all relevant references in the needed context.

basically eclipse will search for a corresponding keyword in front like for , while or switch and then it will count the brackets since then to know where the bracket will be closed

To highlight a variable, specially in java since it is case sensitive, is just to search for the same name.

This is just a basic approach and i think behind the scenes there will be a much more complex approach for that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM