/*
 * Copyright 2000-2010 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.spellchecker.tokenizer;

import com.intellij.lang.Language;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.fileTypes.PlainTextLanguage;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNameIdentifierOwner;
import com.intellij.psi.PsiPlainText;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.psi.xml.XmlText;
import com.intellij.spellchecker.inspections.SplitterFactory;
import org.jetbrains.annotations.NotNull;

public class SpellcheckingStrategy {
  protected final Tokenizer<PsiPlainText> myPlainTextTokenizer = TokenizerBase.create(SplitterFactory.getInstance().getPlainTextSplitter());
  protected final Tokenizer<PsiComment> myCommentTokenizer = new CommentTokenizer();
  protected final Tokenizer<XmlAttributeValue> myXmlAttributeTokenizer = TokenizerBase.create(SplitterFactory.getInstance().getAttributeValueSplitter());
  protected final Tokenizer<XmlText> myXmlTextTokenizer = new XmlTextTokenizer();

  public static final ExtensionPointName<SpellcheckingStrategy> EP_NAME = ExtensionPointName.create("com.intellij.spellchecker.support");
  public static final Tokenizer EMPTY_TOKENIZER = new Tokenizer() {
    @Override
    public void tokenize(@NotNull PsiElement element, TokenConsumer consumer) {
    }
  };

  public static final Tokenizer<PsiElement> TEXT_TOKENIZER = new TokenizerBase<PsiElement>(SplitterFactory.getInstance().getPlainTextSplitter());

  @NotNull
  public Tokenizer getTokenizer(PsiElement element) {
    if (element instanceof PsiNameIdentifierOwner) return new PsiIdentifierOwnerTokenizer();
    if (element instanceof PsiComment) return myCommentTokenizer;
    if (element instanceof XmlAttributeValue) return myXmlAttributeTokenizer;
    if (element instanceof XmlText) return myXmlTextTokenizer;
    if (element instanceof PsiPlainText) return myPlainTextTokenizer;
    return EMPTY_TOKENIZER;
  }

  @NotNull
  public Language getLanguage() {
    return PlainTextLanguage.INSTANCE;
  }
}

@@ -1179,149 +1179,8 @@
 y %7B%0A
-  protected final Tokenizer%3CPsiPlainText%3E myPlainTextTokenizer = TokenizerBase.create(SplitterFactory.getInstance().getPlainTextSplitter());%0A
   pr
@@ -2373,28 +2373,22 @@
 urn 
-myPlainTextTokenizer
+TEXT_TOKENIZER
 ;%0A  

remove redundant tokenizer field