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
;
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
)) {
48 if(ourScriptQuoteHandler
!=null && ourScriptQuoteHandler
.isClosingQuote(iterator
, offset
)) {
54 public boolean isOpeningQuote(HighlighterIterator iterator
, int offset
) {
55 if (myBaseQuoteHandler
.isOpeningQuote(iterator
, offset
)) return true;
57 if(ourStyleQuoteHandler
!=null && ourStyleQuoteHandler
.isOpeningQuote(iterator
, offset
)) {
61 if(ourScriptQuoteHandler
!=null && ourScriptQuoteHandler
.isOpeningQuote(iterator
, offset
)) {
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
)) {
75 if(ourScriptQuoteHandler
!=null && ourScriptQuoteHandler
.hasNonClosedLiteral(editor
,iterator
, offset
)) {
82 public boolean isInsideLiteral(HighlighterIterator iterator
) {
83 if (myBaseQuoteHandler
.isInsideLiteral(iterator
)) return true;
85 if(ourStyleQuoteHandler
!=null && ourStyleQuoteHandler
.isInsideLiteral(iterator
)) {
89 if(ourScriptQuoteHandler
!=null && ourScriptQuoteHandler
.isInsideLiteral(iterator
)) {
96 public static void setScriptQuoteHandler(QuoteHandler scriptQuoteHandler
) {
97 ourScriptQuoteHandler
= scriptQuoteHandler
;