2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.codeInsight
;
18 import com
.intellij
.codeInsight
.completion
.simple
.BracesTailType
;
19 import com
.intellij
.codeInsight
.completion
.simple
.ParenthesesTailType
;
20 import com
.intellij
.codeInsight
.completion
.simple
.RParenthTailType
;
21 import com
.intellij
.openapi
.editor
.Editor
;
22 import com
.intellij
.psi
.codeStyle
.CodeStyleSettings
;
24 public class TailTypes
{
25 public static final TailType CALL_RPARENTH
= new RParenthTailType(){
26 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
27 return styleSettings
.SPACE_WITHIN_METHOD_CALL_PARENTHESES
&& editor
.getDocument().getCharsSequence().charAt(tailOffset
- 1) != '(';
30 public static final TailType IF_RPARENTH
= new RParenthTailType(){
31 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
32 return styleSettings
.SPACE_WITHIN_IF_PARENTHESES
;
35 public static final TailType WHILE_RPARENTH
= new RParenthTailType(){
36 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
37 return styleSettings
.SPACE_WITHIN_WHILE_PARENTHESES
;
40 public static final TailType CALL_RPARENTH_SEMICOLON
= new RParenthTailType(){
41 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
42 return styleSettings
.SPACE_WITHIN_METHOD_CALL_PARENTHESES
;
45 public int processTail(final Editor editor
, int tailOffset
) {
46 return insertChar(editor
, super.processTail(editor
, tailOffset
), ';');
50 public static final TailType SYNCHRONIZED_LPARENTH
= new ParenthesesTailType() {
51 protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
52 return styleSettings
.SPACE_BEFORE_SYNCHRONIZED_PARENTHESES
;
55 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
56 return styleSettings
.SPACE_WITHIN_SYNCHRONIZED_PARENTHESES
;
59 public static final TailType CATCH_LPARENTH
= new ParenthesesTailType() {
60 protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
61 return styleSettings
.SPACE_BEFORE_CATCH_PARENTHESES
;
64 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
65 return styleSettings
.SPACE_WITHIN_CATCH_PARENTHESES
;
68 public static final TailType SWITCH_LPARENTH
= new ParenthesesTailType() {
69 protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
70 return styleSettings
.SPACE_BEFORE_SWITCH_PARENTHESES
;
73 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
74 return styleSettings
.SPACE_WITHIN_SWITCH_PARENTHESES
;
77 public static final TailType WHILE_LPARENTH
= new ParenthesesTailType() {
78 protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
79 return styleSettings
.SPACE_BEFORE_WHILE_PARENTHESES
;
82 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
83 return styleSettings
.SPACE_WITHIN_WHILE_PARENTHESES
;
86 public static final TailType FOR_LPARENTH
= new ParenthesesTailType() {
87 protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
88 return styleSettings
.SPACE_BEFORE_FOR_PARENTHESES
;
91 protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
92 return styleSettings
.SPACE_WITHIN_FOR_PARENTHESES
;
95 public static final TailType FINALLY_LBRACE
= new BracesTailType() {
96 protected boolean isSpaceBeforeLBrace(final CodeStyleSettings styleSettings
, final Editor editor
, final int tailOffset
) {
97 return styleSettings
.SPACE_BEFORE_FINALLY_LBRACE
;
101 private TailTypes() {}