Introducing Language to IElementType and PsiElement

This commit is contained in:
Maxim Shafirov
2005-01-24 12:54:33 +03:00
parent 0cc19e8a11
commit bcc3a2df31
51 changed files with 497 additions and 275 deletions

View File

@@ -1,12 +1,13 @@
package com.intellij.lang;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.PlainSyntaxHighlighter;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.EmptyLexer;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import java.util.HashMap;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
@@ -16,7 +17,25 @@ import com.intellij.psi.PsiMethod;
* To change this template use File | Settings | File Templates.
*/
public abstract class Language {
public SyntaxHighlighter getSyntaxHighlighter() {
private static final Logger LOG = Logger.getInstance("#com.intellij.lang.Language");
private static Map<String, Language> ourRegisteredLanguages = new HashMap<String, Language>();
private String myID;
protected Language(final String ID) {
myID = ID;
if (ourRegisteredLanguages.containsKey(ID)) {
LOG.error("Language '" + ID + "' is already registered");
return;
}
ourRegisteredLanguages.put(ID, this);
}
public static Language findByID(String id) {
return ourRegisteredLanguages.get(id);
}
public SyntaxHighlighter getSyntaxHighlighter(Project project) {
return new PlainSyntaxHighlighter();
}
@@ -28,5 +47,7 @@ public abstract class Language {
return null;
}
public String toString() {
return "Language: " + myID;
}
}

View File

@@ -3,6 +3,7 @@ package com.intellij.lang;
import com.intellij.lexer.Lexer;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
/**
* Created by IntelliJ IDEA.
@@ -14,7 +15,11 @@ import com.intellij.psi.tree.IElementType;
public interface ParserDefinition {
Lexer createLexer();
PsiParser createParser();
IElementType getFileNodeType();
TokenSet getWhitespaceTokens();
TokenSet getCommentTokens();
PsiParser createParser();
PsiElement createElement(ASTNode node);
}

View File

@@ -1,8 +1,6 @@
package com.intellij.lang;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import com.intellij.lexer.Lexer;
/**
* Created by IntelliJ IDEA.
@@ -12,5 +10,5 @@ import com.intellij.lexer.Lexer;
* To change this template use File | Settings | File Templates.
*/
public interface PsiParser {
PsiElement parse(IElementType root, Lexer lexer, PsiBuilder builder);
ASTNode parse(IElementType root, PsiBuilder builder);
}

View File

@@ -6,6 +6,7 @@ package com.intellij.openapi.fileTypes;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.lang.Language;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
@@ -37,8 +38,9 @@ public interface FileType {
FileTypeSupportCapabilities getSupportCapabilities();
PseudoTextBuilder getPseudoTextBuilder();
StructureViewModel getStructureViewModel(VirtualFile file, Project project);
Language getLanguage();
}

View File

@@ -0,0 +1,40 @@
package com.intellij.openapi.fileTypes;
import com.intellij.lang.Language;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 24, 2005
* Time: 11:34:06 AM
* To change this template use File | Settings | File Templates.
*/
public abstract class LanguageFileType implements FileType{
private Language myLanguage;
protected LanguageFileType(final Language language) {
myLanguage = language;
}
public final Language getLanguage() {
return myLanguage;
}
public final SyntaxHighlighter getHighlighter(Project project) {
return myLanguage.getSyntaxHighlighter(project);
}
public final boolean isBinary() {
return false;
}
public final boolean isReadOnly() {
return false;
}
public String getCharset(VirtualFile file) {
return null;
}
}

View File

@@ -32,8 +32,8 @@
package com.intellij.openapi.fileTypes;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.lang.Language;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
@@ -109,4 +109,8 @@ public abstract class UserFileType <T extends UserFileType> implements FileType,
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -14,7 +14,7 @@ import com.intellij.psi.tree.IElementType;
public interface CustomHighlighterTokenType {
class CustomElementType extends IElementType {
public CustomElementType(String debugName) {
super(debugName);
super(debugName, null);
}
}

View File

@@ -4,6 +4,7 @@
*/
package com.intellij.psi;
import com.intellij.lang.Language;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.util.Key;
@@ -18,6 +19,8 @@ public interface PsiElement extends UserDataHolder, Iconable {
Project getProject();
Language getLanguage();
PsiManager getManager();
PsiElement[] getChildren();

View File

@@ -11,6 +11,6 @@ import com.intellij.psi.tree.IElementType;
* @author max
*/
public interface StringEscapesTokenTypes {
IElementType VALID_STRING_ESCAPE_TOKEN = new IElementType("VALID_STRING_ESCAPE_TOKEN");
IElementType INVALID_STRING_ESCAPE_TOKEN = new IElementType("INVALID_STRING_ESCAPE_TOKEN");
IElementType VALID_STRING_ESCAPE_TOKEN = new IElementType("VALID_STRING_ESCAPE_TOKEN", null);
IElementType INVALID_STRING_ESCAPE_TOKEN = new IElementType("INVALID_STRING_ESCAPE_TOKEN", null);
}

View File

@@ -31,13 +31,13 @@
*/
package com.intellij.psi.tree;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import gnu.trove.TIntObjectHashMap;
import java.util.ArrayList;
import java.util.List;
import com.intellij.openapi.diagnostic.Logger;
public class IElementType {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.tree.IElementType");
@@ -52,6 +52,7 @@ public class IElementType {
};
public static final IElementType[] EMPTY_ARRAY = new IElementType[0];
private String myDebugName;
private Language myLanguage;
public static IElementType[] enumerate(Predicate p) {
List matches = new ArrayList();
@@ -65,13 +66,18 @@ public class IElementType {
return (IElementType[])matches.toArray(new IElementType[matches.size()]);
}
public IElementType(String debugName) {
public IElementType(String debugName, Language language) {
myDebugName = debugName;
myLanguage = language;
myIndex = (short) ourCounter++;
LOG.assertTrue(ourCounter < Short.MAX_VALUE, "Too many element types registered. Out of (short) range.");
ourRegistry.put(myIndex, this);
}
public Language getLanguage() {
return myLanguage;
}
public final short getIndex() {
return myIndex;
}

View File

@@ -31,10 +31,11 @@
*/
package com.intellij.psi.tree.java;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.psi.tree.IElementType;
public class IJavaDocElementType extends IElementType {
public IJavaDocElementType(String debugName) {
super(debugName);
super(debugName, StdFileTypes.JAVA.getLanguage()); //TODO: should be a separate language for javadoc?
}
}

View File

@@ -31,10 +31,11 @@
*/
package com.intellij.psi.tree.java;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.psi.tree.IElementType;
public class IJavaElementType extends IElementType {
public IJavaElementType(String debugName) {
super(debugName);
super(debugName, StdFileTypes.JAVA.getLanguage());
}
}

View File

@@ -31,10 +31,11 @@
*/
package com.intellij.psi.tree.jsp;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.psi.tree.IElementType;
public class IJspElementType extends IElementType {
public IJspElementType(String debugName) {
super(debugName);
super(debugName, StdFileTypes.JSP.getLanguage());
}
}

View File

@@ -1,5 +1,6 @@
package com.intellij.psi.tree.xml;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.psi.tree.IElementType;
/**
@@ -11,6 +12,6 @@ import com.intellij.psi.tree.IElementType;
*/
public class IDTDElementType extends IElementType{
public IDTDElementType(String debugName) {
super(debugName);
super(debugName, StdFileTypes.DTD.getLanguage());
}
}

View File

@@ -1,40 +1,17 @@
/*
* Copyright (c) 2004 JetBrains s.r.o. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduct the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the distribution.
*
* Neither the name of JetBrains or IntelliJ IDEA
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. JETBRAINS AND ITS LICENSORS SHALL NOT
* BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
* OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL JETBRAINS OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
* IF JETBRAINS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
*/
package com.intellij.psi.tree.xml;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.psi.tree.IElementType;
public class IXmlElementType extends IElementType {
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 24, 2005
* Time: 12:01:36 PM
* To change this template use File | Settings | File Templates.
*/
public class IXmlElementType extends IElementType{
public IXmlElementType(String debugName) {
super(debugName);
super(debugName, StdFileTypes.XML.getLanguage());
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2004 JetBrains s.r.o. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduct the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the distribution.
*
* Neither the name of JetBrains or IntelliJ IDEA
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. JETBRAINS AND ITS LICENSORS SHALL NOT
* BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
* OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL JETBRAINS OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
* IF JETBRAINS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
*/
package com.intellij.psi.tree.xml;
public class IXmlLeafElementType extends IXmlElementType {
public IXmlLeafElementType(String debugName) {
super(debugName);
}
}

View File

@@ -6,74 +6,74 @@ package com.intellij.psi.xml;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.xml.IXmlElementType;
import com.intellij.psi.tree.xml.IXmlLeafElementType;
public interface XmlTokenType {
IElementType XML_START_TAG_START = new IXmlElementType("XML_START_TAG_START");
IElementType XML_END_TAG_START = new IXmlElementType("XML_END_TAG_START");
IElementType XML_TAG_END = new IXmlElementType("XML_TAG_END");
IElementType XML_EMPTY_ELEMENT_END = new IXmlElementType("XML_EMPTY_ELEMENT_END");
IElementType XML_TAG_NAME = new IXmlElementType("XML_TAG_NAME");
IElementType XML_NAME = new IXmlElementType("XML_NAME");
IElementType XML_ATTRIBUTE_VALUE_TOKEN = new IXmlElementType("XML_ATTRIBUTE_VALUE_TOKEN");
IElementType XML_ATTRIBUTE_VALUE_START_DELIMITER = new IXmlElementType("XML_ATTRIBUTE_VALUE_START_DELIMITER");
IElementType XML_ATTRIBUTE_VALUE_END_DELIMITER = new IXmlElementType("XML_ATTRIBUTE_VALUE_END_DELIMITER");
IElementType XML_EQ = new IXmlElementType("XML_EQ");
IElementType XML_DATA_CHARACTERS = new IXmlElementType("XML_DATA_CHARACTERS");
IElementType XML_START_TAG_START = new IXmlLeafElementType("XML_START_TAG_START");
IElementType XML_END_TAG_START = new IXmlLeafElementType("XML_END_TAG_START");
IElementType XML_TAG_END = new IXmlLeafElementType("XML_TAG_END");
IElementType XML_EMPTY_ELEMENT_END = new IXmlLeafElementType("XML_EMPTY_ELEMENT_END");
IElementType XML_TAG_NAME = new IXmlLeafElementType("XML_TAG_NAME");
IElementType XML_NAME = new IXmlLeafElementType("XML_NAME");
IElementType XML_ATTRIBUTE_VALUE_TOKEN = new IXmlLeafElementType("XML_ATTRIBUTE_VALUE_TOKEN");
IElementType XML_ATTRIBUTE_VALUE_START_DELIMITER = new IXmlLeafElementType("XML_ATTRIBUTE_VALUE_START_DELIMITER");
IElementType XML_ATTRIBUTE_VALUE_END_DELIMITER = new IXmlLeafElementType("XML_ATTRIBUTE_VALUE_END_DELIMITER");
IElementType XML_EQ = new IXmlLeafElementType("XML_EQ");
IElementType XML_DATA_CHARACTERS = new IXmlLeafElementType("XML_DATA_CHARACTERS");
IElementType XML_WHITE_SPACE = JavaTokenType.WHITE_SPACE;
IElementType XML_REAL_WHITE_SPACE = new IXmlElementType("XML_WHITE_SPACE");
IElementType XML_COMMENT_START = new IXmlElementType("XML_COMMENT_START");
IElementType XML_COMMENT_END = new IXmlElementType("XML_COMMENT_END");
IElementType XML_COMMENT_CHARACTERS = new IXmlElementType("XML_COMMENT_CHARACTERS");
IElementType XML_REAL_WHITE_SPACE = new IXmlLeafElementType("XML_WHITE_SPACE");
IElementType XML_COMMENT_START = new IXmlLeafElementType("XML_COMMENT_START");
IElementType XML_COMMENT_END = new IXmlLeafElementType("XML_COMMENT_END");
IElementType XML_COMMENT_CHARACTERS = new IXmlLeafElementType("XML_COMMENT_CHARACTERS");
IElementType XML_DECL_START = new IXmlElementType("XML_DECL_START");
IElementType XML_DECL_END = new IXmlElementType("XML_DECL_END");
IElementType XML_DECL_START = new IXmlLeafElementType("XML_DECL_START");
IElementType XML_DECL_END = new IXmlLeafElementType("XML_DECL_END");
IElementType XML_DOCTYPE_START = new IXmlElementType("XML_DOCTYPE_START");
IElementType XML_DOCTYPE_END = new IXmlElementType("XML_DOCTYPE_END");
IElementType XML_DOCTYPE_SYSTEM = new IXmlElementType("XML_DOCTYPE_SYSTEM");
IElementType XML_DOCTYPE_PUBLIC = new IXmlElementType("XML_DOCTYPE_PUBLIC");
IElementType XML_DOCTYPE_START = new IXmlLeafElementType("XML_DOCTYPE_START");
IElementType XML_DOCTYPE_END = new IXmlLeafElementType("XML_DOCTYPE_END");
IElementType XML_DOCTYPE_SYSTEM = new IXmlLeafElementType("XML_DOCTYPE_SYSTEM");
IElementType XML_DOCTYPE_PUBLIC = new IXmlLeafElementType("XML_DOCTYPE_PUBLIC");
IElementType XML_MARKUP_START = new IXmlElementType("XML_MARKUP_START");
IElementType XML_MARKUP_END = new IXmlElementType("XML_MARKUP_END");
IElementType XML_MARKUP_START = new IXmlLeafElementType("XML_MARKUP_START");
IElementType XML_MARKUP_END = new IXmlLeafElementType("XML_MARKUP_END");
IElementType XML_CDATA_START = new IXmlElementType("XML_CDATA_START");
IElementType XML_CDATA_END = new IXmlElementType("XML_CDATA_END");
IElementType XML_CDATA_START = new IXmlLeafElementType("XML_CDATA_START");
IElementType XML_CDATA_END = new IXmlLeafElementType("XML_CDATA_END");
IElementType XML_ELEMENT_DECL_START = new IXmlElementType("XML_ELEMENT_DECL_START");
IElementType XML_NOTATION_DECL_START = new IXmlElementType("XML_NOTATION_DECL_START");
IElementType XML_ATTLIST_DECL_START = new IXmlElementType("XML_ATTLIST_DECL_START");
IElementType XML_ENTITY_DECL_START = new IXmlElementType("XML_ENTITY_DECL_START");
IElementType XML_ELEMENT_DECL_START = new IXmlLeafElementType("XML_ELEMENT_DECL_START");
IElementType XML_NOTATION_DECL_START = new IXmlLeafElementType("XML_NOTATION_DECL_START");
IElementType XML_ATTLIST_DECL_START = new IXmlLeafElementType("XML_ATTLIST_DECL_START");
IElementType XML_ENTITY_DECL_START = new IXmlLeafElementType("XML_ENTITY_DECL_START");
IElementType XML_PCDATA = new IXmlElementType("XML_PCDATA");
IElementType XML_LEFT_PAREN = new IXmlElementType("XML_LEFT_PAREN");
IElementType XML_RIGHT_PAREN = new IXmlElementType("XML_RIGHT_PAREN");
IElementType XML_CONTENT_EMPTY = new IXmlElementType("XML_CONTENT_EMPTY");
IElementType XML_CONTENT_ANY = new IXmlElementType("XML_CONTENT_ANY");
IElementType XML_QUESTION = new IXmlElementType("XML_QUESTION");
IElementType XML_STAR = new IXmlElementType("XML_STAR");
IElementType XML_PLUS = new IXmlElementType("XML_PLUS");
IElementType XML_BAR = new IXmlElementType("XML_BAR");
IElementType XML_COMMA = new IXmlElementType("XML_COMMA");
IElementType XML_AMP = new IXmlElementType("XML_AMP");
IElementType XML_SEMI = new IXmlElementType("XML_SEMI");
IElementType XML_PERCENT = new IXmlElementType("XML_PERCENT");
IElementType XML_PCDATA = new IXmlLeafElementType("XML_PCDATA");
IElementType XML_LEFT_PAREN = new IXmlLeafElementType("XML_LEFT_PAREN");
IElementType XML_RIGHT_PAREN = new IXmlLeafElementType("XML_RIGHT_PAREN");
IElementType XML_CONTENT_EMPTY = new IXmlLeafElementType("XML_CONTENT_EMPTY");
IElementType XML_CONTENT_ANY = new IXmlLeafElementType("XML_CONTENT_ANY");
IElementType XML_QUESTION = new IXmlLeafElementType("XML_QUESTION");
IElementType XML_STAR = new IXmlLeafElementType("XML_STAR");
IElementType XML_PLUS = new IXmlLeafElementType("XML_PLUS");
IElementType XML_BAR = new IXmlLeafElementType("XML_BAR");
IElementType XML_COMMA = new IXmlLeafElementType("XML_COMMA");
IElementType XML_AMP = new IXmlLeafElementType("XML_AMP");
IElementType XML_SEMI = new IXmlLeafElementType("XML_SEMI");
IElementType XML_PERCENT = new IXmlLeafElementType("XML_PERCENT");
IElementType XML_ATT_IMPLIED = new IXmlElementType("XML_ATT_IMPLIED");
IElementType XML_ATT_REQUIRED = new IXmlElementType("XML_ATT_REQUIRED");
IElementType XML_ATT_FIXED = new IXmlElementType("XML_ATT_FIXED");
IElementType XML_ATT_IMPLIED = new IXmlLeafElementType("XML_ATT_IMPLIED");
IElementType XML_ATT_REQUIRED = new IXmlLeafElementType("XML_ATT_REQUIRED");
IElementType XML_ATT_FIXED = new IXmlLeafElementType("XML_ATT_FIXED");
IElementType XML_ENTITY_REF_TOKEN = new IXmlElementType("XML_ENTITY_REF_TOKEN");
IElementType XML_ENTITY_REF_TOKEN = new IXmlLeafElementType("XML_ENTITY_REF_TOKEN");
IElementType TAG_WHITE_SPACE = new IXmlElementType("TAG_WHITE_SPACE");
IElementType TAG_WHITE_SPACE = new IXmlLeafElementType("TAG_WHITE_SPACE");
IElementType XML_PI_START = new IXmlElementType("XML_PI_START");
IElementType XML_PI_END = new IXmlElementType("XML_PI_END");
IElementType XML_PI_TARGET = new IXmlElementType("XML_PI_TARGET");
IElementType XML_PI_START = new IXmlLeafElementType("XML_PI_START");
IElementType XML_PI_END = new IXmlLeafElementType("XML_PI_END");
IElementType XML_PI_TARGET = new IXmlLeafElementType("XML_PI_TARGET");
IElementType XML_CHAR_ENTITY_REF = new IXmlElementType("XML_CHAR_ENTITY_REF");
IElementType XML_CHAR_ENTITY_REF = new IXmlLeafElementType("XML_CHAR_ENTITY_REF");
IElementType XML_BAD_CHARACTER = new IXmlElementType("XML_BAD_CHARACTER");
IElementType XML_BAD_CHARACTER = new IXmlLeafElementType("XML_BAD_CHARACTER");
IElementType XML_MARKUP = XmlElementType.XML_MARKUP_DECL; //chameleon
IElementType XML_EMBEDDED_CHAMELEON = XmlElementType.XML_EMBEDDED_CHAMELEON; //chameleon
}

View File

@@ -21,7 +21,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.java.IJavaElementType;
import com.intellij.psi.tree.jsp.IJspElementType;
import com.intellij.psi.tree.xml.IXmlElementType;
import com.intellij.psi.tree.xml.IXmlLeafElementType;
public class CodeBlockUtil {
private static final int JAVA_BLOCK_BRACE = 1,
@@ -33,7 +33,7 @@ public class CodeBlockUtil {
final IElementType type = iterator.getTokenType();
if (type instanceof IJavaElementType) {
return JAVA_BLOCK_BRACE;
} else if (type instanceof IXmlElementType) {
} else if (type instanceof IXmlLeafElementType) {
return XML_TAG_BRACE;
} else if (type instanceof IJspElementType) {
return JSP_TAG_BRACE;

View File

@@ -12,7 +12,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.java.IJavaDocElementType;
import com.intellij.psi.tree.java.IJavaElementType;
import com.intellij.psi.tree.jsp.IJspElementType;
import com.intellij.psi.tree.xml.IXmlElementType;
import com.intellij.psi.tree.xml.IXmlLeafElementType;
import com.intellij.psi.xml.XmlTokenType;
import com.intellij.util.containers.BidirectionalMap;
import com.intellij.xml.util.HtmlUtil;
@@ -63,7 +63,7 @@ public class BraceMatchingUtil {
if (tokenType instanceof IJavaElementType) {
return JAVA_TOKEN_GROUP;
}
else if (tokenType instanceof IXmlElementType) {
else if (tokenType instanceof IXmlLeafElementType) {
return tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER
? XML_VALUE_DELIMITER_GROUP
: XML_TAG_TOKEN_GROUP;

View File

@@ -3,7 +3,7 @@ package com.intellij.codeInsight.template.impl;
import com.intellij.psi.tree.IElementType;
interface TemplateTokenType {
IElementType TEXT = new IElementType("TEXT");
IElementType VARIABLE = new IElementType("VARIABLE");
IElementType ESCAPE_DOLLAR = new IElementType("ESCAPE_DOLLAR");
IElementType TEXT = new IElementType("TEXT", null);
IElementType VARIABLE = new IElementType("VARIABLE", null);
IElementType ESCAPE_DOLLAR = new IElementType("ESCAPE_DOLLAR", null);
}

View File

@@ -3,7 +3,7 @@ package com.intellij.ide.fileTemplates.impl;
import com.intellij.psi.tree.IElementType;
interface FileTemplateTokenType {
IElementType TEXT = new IElementType("TEXT");
IElementType MACRO = new IElementType("MACRO");
IElementType DIRECTIVE = new IElementType("DIRECTIVE");
IElementType TEXT = new IElementType("TEXT", null);
IElementType MACRO = new IElementType("MACRO", null);
IElementType DIRECTIVE = new IElementType("DIRECTIVE", null);
}

View File

@@ -32,11 +32,11 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
@@ -101,4 +101,8 @@ public class ArchiveFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -32,11 +32,10 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.lang.dtd.DTDLanguage;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
@@ -48,9 +47,13 @@ import com.intellij.psi.impl.source.xml.XmlFileImpl;
import javax.swing.*;
public class DTDFileType implements FileType {
public class DTDFileType extends LanguageFileType {
private static final Icon ICON = IconLoader.getIcon("/fileTypes/dtd.png");
public DTDFileType() {
super(new DTDLanguage());
}
public String getName() {
return "DTD";
}
@@ -67,23 +70,6 @@ public class DTDFileType implements FileType {
return ICON;
}
public boolean isBinary() {
return false;
}
public boolean isReadOnly() {
return false;
}
public String getCharset(VirtualFile file) {
return null;
}
public SyntaxHighlighter getHighlighter(Project project) {
//TODO: should be antoher?
return new XmlFileHighlighter(true);
}
public PsiFile createPsiFile(VirtualFile file, Project project) {
return new XmlFileImpl((PsiManagerImpl)PsiManager.getInstance(project), file);
}

View File

@@ -32,11 +32,11 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
@@ -101,4 +101,8 @@ public class GuiFormFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -35,10 +35,10 @@ import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.codeFormatting.xml.html.HtmlPseudoTextBuilder;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.lang.html.HTMLLanguage;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
@@ -50,9 +50,13 @@ import com.intellij.psi.xml.XmlFile;
import javax.swing.*;
public class HtmlFileType implements FileType {
public class HtmlFileType extends LanguageFileType {
private static final Icon ICON = IconLoader.getIcon("/fileTypes/html.png");
public HtmlFileType() {
super(new HTMLLanguage());
}
public String getName() {
return "HTML";
}
@@ -69,22 +73,6 @@ public class HtmlFileType implements FileType {
return ICON;
}
public boolean isBinary() {
return false;
}
public boolean isReadOnly() {
return false;
}
public String getCharset(VirtualFile file) {
return null;
}
public SyntaxHighlighter getHighlighter(Project project) {
return new HtmlFileHighlighter();
}
public PsiFile createPsiFile(VirtualFile file, Project project) {
return new HtmlFileImpl((PsiManagerImpl)PsiManager.getInstance(project), file);
}

View File

@@ -32,11 +32,11 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
@@ -115,4 +115,8 @@ public class JavaClassFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -34,15 +34,15 @@ package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.impl.java.JavaFileTreeModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiJavaFile;
import com.intellij.psi.PsiManager;
@@ -53,9 +53,13 @@ import com.intellij.psi.impl.source.codeStyle.java.JavaAdapter;
import javax.swing.*;
public class JavaFileType implements FileType {
public class JavaFileType extends LanguageFileType {
private static final Icon ICON = IconLoader.getIcon("/fileTypes/java.png");
public JavaFileType() {
super(new JavaLanguage());
}
public String getName() {
return "JAVA";
}
@@ -72,23 +76,6 @@ public class JavaFileType implements FileType {
return ICON;
}
public boolean isBinary() {
return false;
}
public boolean isReadOnly() {
return false;
}
public String getCharset(VirtualFile file) {
return null;
}
public SyntaxHighlighter getHighlighter(Project project) {
LanguageLevel level = project != null ? PsiManager.getInstance(project).getEffectiveLanguageLevel() : LanguageLevel.HIGHEST;
return new JavaFileHighlighter(level);
}
public PsiFile createPsiFile(VirtualFile file, Project project) {
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
if (fileIndex.isInSource(file)) {

View File

@@ -32,11 +32,11 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
@@ -101,4 +101,8 @@ public class ModuleFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -32,11 +32,11 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
@@ -101,4 +101,8 @@ public class ProjectFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -32,11 +32,11 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
@@ -98,4 +98,8 @@ public class UnknownFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -32,11 +32,11 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
@@ -101,4 +101,8 @@ public class WorkspaceFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -32,11 +32,10 @@
package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.lang.xhtml.XHTMLLanguage;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
@@ -48,9 +47,13 @@ import com.intellij.psi.impl.source.xml.XmlFileImpl;
import javax.swing.*;
public class XHtmlFileType implements FileType {
public class XHtmlFileType extends LanguageFileType {
private static final Icon ICON = IconLoader.getIcon("/fileTypes/xhtml.png");
public XHtmlFileType() {
super(new XHTMLLanguage());
}
public String getName() {
return "XHTML";
}
@@ -67,22 +70,6 @@ public class XHtmlFileType implements FileType {
return ICON;
}
public boolean isBinary() {
return false;
}
public boolean isReadOnly() {
return false;
}
public String getCharset(VirtualFile file) {
return null;
}
public SyntaxHighlighter getHighlighter(Project project) {
return new XmlFileHighlighter(false,true);
}
public PsiFile createPsiFile(VirtualFile file, Project project) {
return new XmlFileImpl((PsiManagerImpl)PsiManager.getInstance(project), file);
}

View File

@@ -33,30 +33,33 @@ package com.intellij.ide.highlighter;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.codeFormatting.xml.xml.XmlPseudoTextBuilder;
import com.intellij.codeFormatting.xml.xml.XmlPseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.psi.impl.source.codeStyle.CodeFormatterFacade;
import com.intellij.psi.impl.source.codeStyle.java.JavaAdapter;
import com.intellij.psi.impl.source.xml.XmlFileImpl;
import com.intellij.psi.xml.XmlFile;
import javax.swing.*;
public class XmlFileType implements FileType {
public class XmlFileType extends LanguageFileType {
private static final Icon ICON = IconLoader.getIcon("/fileTypes/xml.png");
public XmlFileType() {
super(new XMLLanguage());
}
public String getName() {
return "XML";
}
@@ -73,22 +76,6 @@ public class XmlFileType implements FileType {
return ICON;
}
public boolean isBinary() {
return false;
}
public boolean isReadOnly() {
return false;
}
public String getCharset(VirtualFile file) {
return null;
}
public SyntaxHighlighter getHighlighter(Project project) {
return new XmlFileHighlighter();
}
public PsiFile createPsiFile(VirtualFile file, Project project) {
return new XmlFileImpl((PsiManagerImpl)PsiManager.getInstance(project), file);
}
@@ -117,5 +104,4 @@ public class XmlFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return new XmlStructureViewTreeModel((XmlFile)PsiManager.getInstance(project).findFile(file));
}
}

View File

@@ -0,0 +1,25 @@
package com.intellij.lang.dtd;
import com.intellij.ide.highlighter.XmlFileHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 24, 2005
* Time: 10:53:26 AM
* To change this template use File | Settings | File Templates.
*/
public class DTDLanguage extends Language {
public DTDLanguage() {
super("DTD");
}
public SyntaxHighlighter getSyntaxHighlighter(Project project) {
//TODO: should be antoher?
return new XmlFileHighlighter(true);
}
}

View File

@@ -0,0 +1,23 @@
package com.intellij.lang.html;
import com.intellij.ide.highlighter.HtmlFileHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 24, 2005
* Time: 11:00:06 AM
* To change this template use File | Settings | File Templates.
*/
public class HTMLLanguage extends Language {
public HTMLLanguage() {
super("HTML");
}
public SyntaxHighlighter getSyntaxHighlighter(Project project) {
return new HtmlFileHighlighter();
}
}

View File

@@ -0,0 +1,26 @@
package com.intellij.lang.java;
import com.intellij.ide.highlighter.JavaFileHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiManager;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 22, 2005
* Time: 11:16:59 PM
* To change this template use File | Settings | File Templates.
*/
public class JavaLanguage extends Language {
public JavaLanguage() {
super("JAVA");
}
public SyntaxHighlighter getSyntaxHighlighter(Project project) {
LanguageLevel level = project != null ? PsiManager.getInstance(project).getEffectiveLanguageLevel() : LanguageLevel.HIGHEST;
return new JavaFileHighlighter(level);
}
}

View File

@@ -0,0 +1,23 @@
package com.intellij.lang.xhtml;
import com.intellij.ide.highlighter.XmlFileHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 24, 2005
* Time: 11:01:05 AM
* To change this template use File | Settings | File Templates.
*/
public class XHTMLLanguage extends Language {
public XHTMLLanguage() {
super("XHTML");
}
public SyntaxHighlighter getSyntaxHighlighter(Project project) {
return new XmlFileHighlighter(false,true);
}
}

View File

@@ -0,0 +1,23 @@
package com.intellij.lang.xml;
import com.intellij.ide.highlighter.XmlFileHighlighter;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 24, 2005
* Time: 10:59:22 AM
* To change this template use File | Settings | File Templates.
*/
public class XMLLanguage extends Language {
public XMLLanguage() {
super("XML");
}
public SyntaxHighlighter getSyntaxHighlighter(Project project) {
return new XmlFileHighlighter();
}
}

View File

@@ -32,8 +32,8 @@
package com.intellij.openapi.fileTypes;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.lang.Language;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
@@ -98,4 +98,8 @@ public class PlainTextFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -7,8 +7,8 @@
package com.intellij.openapi.fileTypes.ex;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.ide.util.treeView.smartTree.TreeModel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
import com.intellij.openapi.project.Project;
@@ -59,4 +59,8 @@ public abstract class FakeFileType implements FileType {
public StructureViewModel getStructureViewModel(VirtualFile file, Project project) {
return null;
}
public Language getLanguage() {
return null;
}
}

View File

@@ -2,6 +2,7 @@
package com.intellij.psi.impl;
import com.intellij.ide.util.EditSourceUtil;
import com.intellij.lang.Language;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FileStatus;
@@ -123,4 +124,8 @@ public abstract class PsiElementBase extends ElementBase implements PsiElement {
public Project getProject() {
return getManager().getProject();
}
public Language getLanguage() {
return null;
}
}

View File

@@ -1,6 +1,8 @@
package com.intellij.psi.impl.compiled;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiElementBase;
@@ -13,6 +15,10 @@ abstract class ClsElementImpl extends PsiElementBase implements PsiCompiledEleme
protected TreeElement myMirror = null;
public Language getLanguage() {
return StdFileTypes.JAVA.getLanguage();
}
public PsiManager getManager() {
return getParent().getManager();
}
@@ -77,7 +83,6 @@ abstract class ClsElementImpl extends PsiElementBase implements PsiCompiledEleme
if (myMirror == null) {
getContainingFile().getText(); // to initialize mirror
}
;
}
return SourceTreeToPsiMap.treeElementToPsi(myMirror);
}

View File

@@ -1,21 +1,22 @@
package com.intellij.psi.impl.source;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.impl.ElementBase;
import com.intellij.psi.impl.SharedPsiElementImplUtil;
import com.intellij.ide.util.EditSourceUtil;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.FileStatusManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.ElementBase;
import com.intellij.psi.impl.SharedPsiElementImplUtil;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.IncorrectOperationException;
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.NavigationItem;
import com.intellij.ide.util.EditSourceUtil;
/**
* Created by IntelliJ IDEA.
@@ -259,4 +260,8 @@ public class ASTWrapperPsiElement extends ElementBase implements PsiElement, Nav
public ASTNode getNode() {
return myNode;
}
public Language getLanguage() {
return myNode.getElementType().getLanguage();
}
}

View File

@@ -1,10 +1,11 @@
package com.intellij.psi.impl.source;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.ex.DocumentEx;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
@@ -19,7 +20,6 @@ import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.LocalTimeCounter;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.lang.ASTNode;
public abstract class PsiFileImpl extends NonSlaveRepositoryPsiElement implements PsiFile, PsiFileEx {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiFileImpl");
@@ -335,4 +335,8 @@ public abstract class PsiFileImpl extends NonSlaveRepositoryPsiElement implement
}
public abstract Lexer createLexer();
public Language getLanguage() {
return getFileType().getLanguage();
}
}

View File

@@ -1,15 +1,17 @@
package com.intellij.psi.impl.source.html;
import com.intellij.psi.impl.source.xml.XmlTagImpl;
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.psi.html.HtmlTag;
import com.intellij.psi.impl.source.xml.XmlTagImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import com.intellij.xml.XmlNSDescriptor;
import com.intellij.xml.util.XmlUtil;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
/**
* Created by IntelliJ IDEA.
@@ -101,4 +103,8 @@ public class HtmlTagImpl extends XmlTagImpl implements HtmlTag {
public String toString() {
return "HtmlTag:" + getName();
}
public Language getLanguage() {
return StdFileTypes.HTML.getLanguage();
}
}

View File

@@ -1,6 +1,8 @@
package com.intellij.psi.impl.source.tree;
import com.intellij.ide.util.EditSourceUtil;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.diagnostic.Logger;
@@ -19,7 +21,6 @@ import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.IncorrectOperationException;
import com.intellij.lang.ASTNode;
public abstract class CompositePsiElement extends CompositeElement implements PsiElement, NavigationItem {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.CompositePsiElement");
@@ -236,4 +237,8 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
public Project getProject() {
return getManager().getProject();
}
public Language getLanguage() {
return getElementType().getLanguage();
}
}

View File

@@ -17,12 +17,12 @@ public interface ElementType extends
JspElementType,
XmlElementType,
AspectElementType {
IElementType PLAIN_TEXT_FILE = new IElementType("PLAIN_TEXT_FILE");
IElementType PLAIN_TEXT = new IElementType("PLAIN_TEXT");
IElementType NEW_LINE_INDENT = new IElementType("NEW_LINE_INDENT");
IElementType CODE_FRAGMENT = new IElementType("CODE_FRAGMENT");
IElementType DUMMY_HOLDER = new IElementType("DUMMY_HOLDER");
IElementType GRAMMAR_CHAMELEON = new IElementType("GRAMMAR_CHAMELEON");
IElementType PLAIN_TEXT_FILE = new IElementType("PLAIN_TEXT_FILE", null);
IElementType PLAIN_TEXT = new IElementType("PLAIN_TEXT", null);
IElementType NEW_LINE_INDENT = new IElementType("NEW_LINE_INDENT", null);
IElementType CODE_FRAGMENT = new IElementType("CODE_FRAGMENT", null);
IElementType DUMMY_HOLDER = new IElementType("DUMMY_HOLDER", null);
IElementType GRAMMAR_CHAMELEON = new IElementType("GRAMMAR_CHAMELEON", null);
TokenSet WHITE_SPACE_BIT_SET = TokenSet.create(new IElementType[]{WHITE_SPACE, JSP_DIRECTIVE_WHITE_SPACE, JSP_ACTION_WHITE_SPACE});

View File

@@ -9,9 +9,9 @@ import com.intellij.psi.impl.source.html.HtmlDocumentImpl;
import com.intellij.psi.impl.source.html.HtmlTagImpl;
import com.intellij.psi.impl.source.javadoc.*;
import com.intellij.psi.impl.source.jsp.*;
import com.intellij.psi.impl.source.jsp.jspJava.JspText;
import com.intellij.psi.impl.source.jsp.jspJava.JspTemplateStatement;
import com.intellij.psi.impl.source.jsp.jspJava.JspTemplateDeclaration;
import com.intellij.psi.impl.source.jsp.jspJava.JspTemplateStatement;
import com.intellij.psi.impl.source.jsp.jspJava.JspText;
import com.intellij.psi.impl.source.tree.java.*;
import com.intellij.psi.impl.source.xml.*;
import com.intellij.psi.jsp.JspTokenType;
@@ -19,7 +19,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.java.IJavaDocElementType;
import com.intellij.psi.tree.java.IJavaElementType;
import com.intellij.psi.tree.jsp.IJspElementType;
import com.intellij.psi.tree.xml.IXmlElementType;
import com.intellij.psi.tree.xml.IXmlLeafElementType;
import com.intellij.util.CharTable;
import java.util.ArrayList;
@@ -64,7 +64,7 @@ public class Factory implements Constants {
if (type == JAVA_FILE_TEXT) {
element = new JavaFileChameleonElement(buffer, startOffset, endOffset, lexerState, table);
}
else if (type instanceof IXmlElementType) {
else if (type instanceof IXmlLeafElementType) {
element = new XmlTokenImpl(type, buffer, startOffset, endOffset, lexerState, table);
}
else if (type == JSP_FILE_TEXT) {

View File

@@ -85,7 +85,7 @@ public interface JavaElementType {
IElementType LABELED_STATEMENT = new IJavaElementType("LABELED_STATEMENT");
IElementType ASSERT_STATEMENT = new IJavaElementType("ASSERT_STATEMENT");
IElementType CATCH_SECTION = new IElementType("CATCH_SECTION");
IElementType CATCH_SECTION = new IJavaElementType("CATCH_SECTION");
IElementType ANNOTATION_METHOD = new IJavaElementType("ANNOTATION_METHOD");
IElementType ANNOTATION_ARRAY_INITIALIZER = new IJavaElementType("ANNOTATION_ARRAY_INITIALIZER");

View File

@@ -1,5 +1,7 @@
package com.intellij.psi.impl.source.tree;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -13,7 +15,6 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.CharTable;
import com.intellij.util.IncorrectOperationException;
import com.intellij.lang.ASTNode;
public class LeafPsiElement extends LeafElementImpl implements PsiElement {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.LeafPsiElement");
@@ -184,4 +185,8 @@ public class LeafPsiElement extends LeafElementImpl implements PsiElement {
public Project getProject() {
return getManager().getProject();
}
public Language getLanguage() {
return getElementType().getLanguage();
}
}

View File

@@ -1,22 +1,21 @@
package com.intellij.psi.impl.source.xml;
import com.intellij.lang.ASTNode;
import com.intellij.lexer.FilterLexer;
import com.intellij.lexer.Lexer;
import com.intellij.lexer._OldXmlLexer;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenTypeLinks;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.xml.IXmlElementType;
import com.intellij.psi.impl.source.DummyHolder;
import com.intellij.psi.impl.source.ParsingContext;
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
import com.intellij.lexer.FilterLexer;
import com.intellij.lexer.*;
import com.intellij.psi.impl.source.parsing.xml.XmlParsing;
import com.intellij.psi.impl.source.parsing.xml.XmlPsiLexer;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.psi.tree.xml.IXmlLeafElementType;
import com.intellij.psi.xml.*;
import com.intellij.xml.util.XmlUtil;
import com.intellij.lang.ASTNode;
import java.util.HashSet;
import java.util.Set;
@@ -204,7 +203,7 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl {
private boolean isInternalReference() {
for (ASTNode e = getFirstChildNode(); e != null; e = e.getTreeNext()) {
if (e.getElementType() instanceof IXmlElementType) {
if (e.getElementType() instanceof IXmlLeafElementType) {
XmlToken token = (XmlToken)SourceTreeToPsiMap.treeElementToPsi(e);
if (token.getTokenType() == XmlTokenType.XML_DOCTYPE_PUBLIC || token.getTokenType() == XmlToken.XML_DOCTYPE_SYSTEM) {
return false;