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
.xml
;
18 import com
.intellij
.lang
.ASTNode
;
19 import com
.intellij
.lang
.ParserDefinition
;
20 import com
.intellij
.lang
.PsiParser
;
21 import com
.intellij
.lexer
.Lexer
;
22 import com
.intellij
.lexer
.XmlLexer
;
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
.parsing
.xml
.XmlParser
;
28 import com
.intellij
.psi
.impl
.source
.xml
.XmlFileImpl
;
29 import com
.intellij
.psi
.tree
.IFileElementType
;
30 import com
.intellij
.psi
.tree
.TokenSet
;
31 import com
.intellij
.psi
.util
.PsiUtilBase
;
32 import com
.intellij
.psi
.xml
.XmlElementType
;
33 import com
.intellij
.psi
.xml
.XmlTokenType
;
34 import com
.intellij
.xml
.util
.XmlUtil
;
35 import org
.jetbrains
.annotations
.NotNull
;
38 * Created by IntelliJ IDEA.
42 * To change this template use File | Settings | File Templates.
44 public class XMLParserDefinition
implements ParserDefinition
{
46 public Lexer
createLexer(Project project
) {
47 return new XmlLexer();
50 public IFileElementType
getFileNodeType() {
51 return XmlElementType
.XML_FILE
;
55 public TokenSet
getWhitespaceTokens() {
56 return XmlTokenType
.WHITESPACES
;
60 public TokenSet
getCommentTokens() {
61 return XmlTokenType
.COMMENTS
;
65 public TokenSet
getStringLiteralElements() {
66 return TokenSet
.EMPTY
;
70 public PsiParser
createParser(final Project project
) {
71 return new XmlParser();
75 public PsiElement
createElement(ASTNode node
) {
76 return PsiUtilBase
.NULL_PSI_ELEMENT
;
79 public PsiFile
createFile(FileViewProvider viewProvider
) {
80 return new XmlFileImpl(viewProvider
, XmlElementType
.XML_FILE
);
83 public SpaceRequirements
spaceExistanceTypeBetweenTokens(ASTNode left
, ASTNode right
) {
84 final Lexer lexer
= createLexer(left
.getPsi().getProject());
85 return XmlUtil
.canStickTokensTogetherByLexerInXml(left
, right
, lexer
, 0);