update copyright
[fedora-idea.git] / xml / impl / src / com / intellij / codeInsight / editorActions / HtmlQuoteHandler.java
blob87f92e70a45701dc8368581e671ff7e5fd937cb5
1 /*
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.editorActions;
18 import com.intellij.openapi.editor.Editor;
19 import com.intellij.openapi.editor.highlighter.HighlighterIterator;
21 /**
22 * @author peter
24 public class HtmlQuoteHandler implements QuoteHandler {
25 private static QuoteHandler ourStyleQuoteHandler;
26 private QuoteHandler myBaseQuoteHandler;
27 private static QuoteHandler ourScriptQuoteHandler;
29 public HtmlQuoteHandler() {
30 this(new XmlQuoteHandler());
33 public HtmlQuoteHandler(QuoteHandler _baseHandler) {
34 myBaseQuoteHandler = _baseHandler;
37 public static void setStyleQuoteHandler(QuoteHandler quoteHandler) {
38 ourStyleQuoteHandler = quoteHandler;
41 public boolean isClosingQuote(HighlighterIterator iterator, int offset) {
42 if (myBaseQuoteHandler.isClosingQuote(iterator, offset)) return true;
44 if(ourStyleQuoteHandler!=null && ourStyleQuoteHandler.isClosingQuote(iterator, offset)) {
45 return true;
48 if(ourScriptQuoteHandler!=null && ourScriptQuoteHandler.isClosingQuote(iterator, offset)) {
49 return true;
51 return false;
54 public boolean isOpeningQuote(HighlighterIterator iterator, int offset) {
55 if (myBaseQuoteHandler.isOpeningQuote(iterator, offset)) return true;
57 if(ourStyleQuoteHandler!=null && ourStyleQuoteHandler.isOpeningQuote(iterator, offset)) {
58 return true;
61 if(ourScriptQuoteHandler!=null && ourScriptQuoteHandler.isOpeningQuote(iterator, offset)) {
62 return true;
65 return false;
68 public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) {
69 if (myBaseQuoteHandler.hasNonClosedLiteral(editor,iterator, offset)) return true;
71 if(ourStyleQuoteHandler!=null && ourStyleQuoteHandler.hasNonClosedLiteral(editor,iterator, offset)) {
72 return true;
75 if(ourScriptQuoteHandler!=null && ourScriptQuoteHandler.hasNonClosedLiteral(editor,iterator, offset)) {
76 return true;
79 return false;
82 public boolean isInsideLiteral(HighlighterIterator iterator) {
83 if (myBaseQuoteHandler.isInsideLiteral(iterator)) return true;
85 if(ourStyleQuoteHandler!=null && ourStyleQuoteHandler.isInsideLiteral(iterator)) {
86 return true;
89 if(ourScriptQuoteHandler!=null && ourScriptQuoteHandler.isInsideLiteral(iterator)) {
90 return true;
93 return false;
96 public static void setScriptQuoteHandler(QuoteHandler scriptQuoteHandler) {
97 ourScriptQuoteHandler = scriptQuoteHandler;