Posts

Showing posts from September, 2011

Eclipse PDE: Everything about Editor Part 4

Auto-Edit Strategy This post of Everything About Editor series explains about editors auto complete feature. Auto edit feature of any editor helps developer while writing code, for example in java editor of eclipse provides auto complete features for string quotes , open braces etc. When you type open curly braces ‘{‘ , eclipse java editor auto inserts closing curly braces considering line and indentation. Here I am going to implement auto-edit strategy for open single , double quotes and opening curly braces ‘{‘. To use auto edits, you must implement the org.eclipse.jface.text.IAutoEditStrategy interface, which contains just one method: void customizeDocumentCommand(IDocument document,DocumentCommand command); This is called each time you make a change to the document with the DocumentCommand object containing the information about that change. So, adding indents or making any change to the text being changed is as simple as modifying the DocumentCommand object. 1. Implement IA

Eclipse PDE: Everything about Editor Part 3

Image
Syntax Highlighting Part 3 of Eclipse PDE: Everything about Editor series deals with Syntax coloring. In previous post I have explained about all Eclipse Editor relegated concepts and document partition. I have tried to explains Syntax highlighting in editor in this post. Syntax highlighting helps to provides different color and styles to different part of code. Eclipse provides a presentation reconciler, which divides the document into a set of tokens that define the background and foreground color, along with the font style for a section of text. The document partitions define the content types within a document, while the presentation reconciler divided those individual content types into tokens for sets of characters that share the same color and font style. The presentation of the document must be maintained while the user continues to modify it. This is done through the use of a damager and a repairer . A Damager takes the description of how the document was modified and

Eclipse PDE: Everything about Editor Part 2

Document Partition In this series of “ Eclipse PDE: Everything about Editor ”, this post explains how to configure your document to represent different partition. Document partitions helps to manipulate different part of document in different way. For example there is not need to showing content assist in single line comment or multi line comment. Here I am explaining defining partition for single and multi line comments 1. Define a custom partition scanner Eclipse framework provides Rule based partition scanner, which allows us to define single or multi line rule for partitioning document content. We need to define Custome partition scanner extending org.eclipse.jface.text.rules.RuleBasedPartitionScanner . Override the constructor and define rules for partition . Below code snippets defines rule for single and multi line comments public class MyPartitionScanner extends RuleBasedPartitionScanner { //Define COnstants for supported partition types public static