update copyright
[fedora-idea.git] / xml / impl / src / com / intellij / lang / html / HTMLParserDefinition.java
blob950e96e18381b895cfe8eba6840059574a7d2003
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.lang.html;
18 import com.intellij.lang.ASTNode;
19 import com.intellij.lang.ParserDefinition;
20 import com.intellij.lang.PsiParser;
21 import com.intellij.lexer.HtmlLexer;
22 import com.intellij.lexer.Lexer;
23 import com.intellij.openapi.project.Project;
24 import com.intellij.psi.FileViewProvider;
25 import com.intellij.psi.PsiElement;
26 import com.intellij.psi.PsiFile;
27 import com.intellij.psi.impl.source.html.HtmlFileImpl;
28 import com.intellij.psi.tree.IFileElementType;
29 import com.intellij.psi.tree.TokenSet;
30 import com.intellij.psi.util.PsiUtilBase;
31 import com.intellij.psi.xml.XmlElementType;
32 import com.intellij.psi.xml.XmlTokenType;
33 import com.intellij.xml.util.XmlUtil;
34 import org.jetbrains.annotations.NotNull;
36 /**
37 * Created by IntelliJ IDEA.
38 * User: max
39 * Date: Jan 26, 2005
40 * Time: 1:01:36 PM
41 * To change this template use File | Settings | File Templates.
43 public class HTMLParserDefinition implements ParserDefinition {
44 @NotNull
45 public Lexer createLexer(Project project) {
46 return new HtmlLexer();
49 public IFileElementType getFileNodeType() {
50 return XmlElementType.HTML_FILE;
53 @NotNull
54 public TokenSet getWhitespaceTokens() {
55 return XmlTokenType.WHITESPACES;
58 @NotNull
59 public TokenSet getCommentTokens() {
60 return XmlTokenType.COMMENTS;
63 @NotNull
64 public TokenSet getStringLiteralElements() {
65 return TokenSet.EMPTY;
68 @NotNull
69 public PsiParser createParser(final Project project) {
70 return new HTMLParser();
73 @NotNull
74 public PsiElement createElement(ASTNode node) {
75 return PsiUtilBase.NULL_PSI_ELEMENT;
78 public PsiFile createFile(FileViewProvider viewProvider) {
79 return new HtmlFileImpl(viewProvider);
82 public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
83 final Lexer lexer = createLexer(left.getPsi().getProject());
84 return XmlUtil.canStickTokensTogetherByLexerInXml(left, right, lexer, 0);