/*
 * Copyright 2000-2013 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.codeInsight.editorActions;

import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;

/**
 * Handler, extending IDE behaviour on typing in editor.
 *
 * @author yole
 */
public abstract class TypedHandlerDelegate {
  public static final ExtensionPointName<TypedHandlerDelegate> EP_NAME = ExtensionPointName.create("com.intellij.typedHandler");

  /**
   * If the specified character triggers auto-popup, schedules the auto-popup appearance. This method is called even
   * in overwrite mode, when the rest of typed handler delegate methods are not called. It is invoked only for the primary caret.
   */
  public Result checkAutoPopup(char charTyped, final Project project, final Editor editor, final PsiFile file) {
    return Result.CONTINUE;
  }

  /**
   * Called before selected text is deleted.
   * This method is supposed to be overridden by handlers having custom behaviour with respect to selection.
   */
  public Result beforeSelectionRemoved(char c, final Project project, final Editor editor, final PsiFile file) {
    return Result.CONTINUE;
  }

  /**
   * Called before the specified character typed by the user is inserted in the editor.
   */
  public Result beforeCharTyped(char c, final Project project, final Editor editor, final PsiFile file, final FileType fileType) {
    return Result.CONTINUE;
  }

  /**
   * Called after the specified character typed by the user has been inserted in the editor.
   */
  public Result charTyped(char c, final Project project, final @NotNull Editor editor, @NotNull final PsiFile file) {
    return Result.CONTINUE;
  }

  public enum Result {
    STOP,
    CONTINUE,
    DEFAULT
  }
}

@@ -1,13 +1,10 @@
 /
-*%0A *
+/
  Copyrig
@@ -18,9 +18,9 @@
 -201
-3
+7
  Jet
@@ -33,21 +33,21 @@
  s.r.o.%0A
- *%0A *
+//%0A//
  License
@@ -103,18 +103,18 @@
 ense%22);%0A
- *
+//
  you may
@@ -171,18 +171,18 @@
 icense.%0A
- *
+//
  You may
@@ -214,21 +214,21 @@
 ense at%0A
- *%0A *
+//%0A//
  http://
@@ -263,21 +263,21 @@
 NSE-2.0%0A
- *%0A *
+//%0A//
  Unless 
@@ -337,18 +337,18 @@
 oftware%0A
- *
+//
  distrib
@@ -406,18 +406,18 @@
  BASIS,%0A
- *
+//
  WITHOUT
@@ -482,18 +482,18 @@
 mplied.%0A
- *
+//
  See the
@@ -553,18 +553,18 @@
 ons and%0A
- *
+//
  limitat
@@ -587,20 +587,16 @@
 icense.%0A
- */%0A
 package 
@@ -636,16 +636,61 @@
 tions;%0A%0A
+import com.intellij.openapi.editor.Document;%0A
 import c
@@ -956,16 +956,16 @@
 l;%0A%0A/**%0A
-
  * Handl
@@ -1013,16 +1013,336 @@
 editor.%0A
+ * %3Cp%3E%0A * Note that %3Ccode%3EPsiFile%3C/code%3E passed to handler's methods isn't guaranteed to be in sync with the document at the time of invocation%0A * (due to performance considerations). %7B@link com.intellij.psi.PsiDocumentManager#commitDocument(Document)%7D should be invoked explicitly,%0A * if an up-to-date PSI is required.%0A
  *%0A * @a

improve TypedHandlerDelegate javadoc