Getting Code Style Auto Indent Location

I'm new to plugin developement and I'm trying to write a plugin which has similar behavior to the Auto-Indent Lines feature with the following differences:

1. If text exists on the current line, instead of moving the carret to the following line, it moves the caret to the indent location (i.e. at the start of the indented line)
2. If there is no text on the current line, it moves the carret to where the indented line would be if there was text, rather than not moving the carret at all.

I've looked at a couple of examples and I have a few questions:
1. Is there a way, in the Open API, to determine what the indent setting is?
2. Some lines will be a continuation of a statement on the previous line. Is there any way to determine if this is the case? Is there any way to determine if there is an alignment rule which must be applied? For example, if it's a method parameter to a method call on the previous line, how do I determine if the parameter should be aligned with open parenthesis of the method call?
3. What is the best practice for changing text in the editor?

Thanks.

Scott

1 comment
Comment actions Permalink

1. If text exists on the current line, instead of moving the carret to

the following line, it moves the caret to the indent location (i.e. at the
start of the indented line)

This can be achieved by the Home key, can't it?

2. If there is no text on the current line, it moves the carret to where

the indented line would be if there was text, rather than not moving the
carret at all.

End key should do this.

1. Is there a way, in the Open API, to determine what the indent setting

is?

See CodeStyleSettings.

2. Some lines will be a continuation of a statement on the previous line.

Is there any way to determine if this is the case? Is there any way to
determine if there is an alignment rule which must be applied? For example,
if it's a method parameter to a method call on the previous line, how do I
determine if the parameter should be aligned with open parenthesis of the
method call?

Hmm... CodeStyleManager.adjustLineIndent(PsiFile file, int offset) may help
you.

3. What is the best practice for changing text in the editor?


You may change its Document. There are methods for changing text.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"



"Scott" <sdgoldst@mailandnews.com> wrote in message
news:29757889.1070443068030.JavaMail.javamailuser@localhost...

I'm new to plugin developement and I'm trying to write a plugin which has

similar behavior to the Auto-Indent Lines feature with the following
differences:
>

1. If text exists on the current line, instead of moving the carret to

the following line, it moves the caret to the indent location (i.e. at the
start of the indented line)

2. If there is no text on the current line, it moves the carret to where

the indented line would be if there was text, rather than not moving the
carret at all.
>

I've looked at a couple of examples and I have a few questions:
1. Is there a way, in the Open API, to determine what the indent setting

is?

2. Some lines will be a continuation of a statement on the previous line.

Is there any way to determine if this is the case? Is there any way to
determine if there is an alignment rule which must be applied? For example,
if it's a method parameter to a method call on the previous line, how do I
determine if the parameter should be aligned with open parenthesis of the
method call?

3. What is the best practice for changing text in the editor?

>

Thanks.

>

Scott



0

Please sign in to leave a comment.