From c951764a9fd25d9aaa75395f556f30efe84dc355 Mon Sep 17 00:00:00 2001 From: Maxim Mossienko Date: Fri, 11 Feb 2005 20:44:26 +0300 Subject: [PATCH] ELTokenTypes introduced, fixed issue with hanging during el parsing, CssElementFactory opened for Fabrique --- .../psi/tree/jsp/IJspElementType.java | 7 ++++++- .../editorActions/TypedHandler.java | 6 +++++- .../highlighting/BraceMatchingUtil.java | 21 ++++++++++--------- .../intellij/lexer/HtmlHighlightingLexer.java | 5 +++-- .../psi/impl/source/tree/Factory.java | 4 +--- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/openapi/src/com/intellij/psi/tree/jsp/IJspElementType.java b/openapi/src/com/intellij/psi/tree/jsp/IJspElementType.java index f96685c572d2..4493ffc19206 100644 --- a/openapi/src/com/intellij/psi/tree/jsp/IJspElementType.java +++ b/openapi/src/com/intellij/psi/tree/jsp/IJspElementType.java @@ -33,9 +33,14 @@ package com.intellij.psi.tree.jsp; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.psi.tree.IElementType; +import com.intellij.lang.Language; public class IJspElementType extends IElementType { public IJspElementType(String debugName) { - super(debugName, StdFileTypes.JSP.getLanguage()); + this(debugName, StdFileTypes.JSP.getLanguage()); + } + + protected IJspElementType(String debugName, Language language) { + super(debugName, language); } } \ No newline at end of file diff --git a/source/com/intellij/codeInsight/editorActions/TypedHandler.java b/source/com/intellij/codeInsight/editorActions/TypedHandler.java index d759acaea084..46b16f8ad5b9 100644 --- a/source/com/intellij/codeInsight/editorActions/TypedHandler.java +++ b/source/com/intellij/codeInsight/editorActions/TypedHandler.java @@ -27,6 +27,8 @@ import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.html.HtmlTag; import com.intellij.psi.impl.source.xml.XmlTokenImpl; import com.intellij.psi.jsp.*; +import com.intellij.psi.jsp.el.ELTokenType; +import com.intellij.psi.jsp.el.ELExpressionHolder; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; import com.intellij.psi.tree.java.IJavaElementType; @@ -139,7 +141,7 @@ public class TypedHandler implements TypedActionHandler { super(_baseHandler); myElHandler = new SimpleTokenSetQuoteHandler( - new IElementType[] {JspTokenType.JSP_EL_STRING_LITERAL} + new IElementType[] {ELTokenType.JSP_EL_STRING_LITERAL} ); } @@ -422,6 +424,8 @@ public class TypedHandler implements TypedActionHandler { PsiDocumentManager.getInstance(project).commitAllDocuments(); final int offset = editor.getCaretModel().getOffset(); PsiElement elementAt = file.findElementAt(offset-1); + elementAt = PsiTreeUtil.getParentOfType(elementAt,ELExpressionHolder.class); + elementAt = (elementAt!=null)?elementAt.getFirstChild():null; // TODO: handle it with insertAfterRParen(...) if (elementAt!=null && !JspxCompletionData.isJavaContext(elementAt)) { diff --git a/source/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java b/source/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java index c6cd69baf669..3ed9423c4e50 100644 --- a/source/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java +++ b/source/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java @@ -11,6 +11,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.psi.JavaDocTokenType; import com.intellij.psi.JavaTokenType; import com.intellij.psi.jsp.JspTokenType; +import com.intellij.psi.jsp.el.ELTokenType; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.java.IJavaDocElementType; import com.intellij.psi.tree.java.IJavaElementType; @@ -124,8 +125,8 @@ public class BraceMatchingUtil { PAIRING_TOKENS.put(JspTokenType.JSP_ACTION_ATTRIBUTE_VALUE_START_DELIMITER, JspTokenType.JSP_ACTION_ATTRIBUTE_VALUE_END_DELIMITER); PAIRING_TOKENS.put(JspTokenType.JSP_DIRECTIVE_ATTRIBUTE_VALUE_START_DELIMITER, JspTokenType.JSP_DIRECTIVE_ATTRIBUTE_VALUE_END_DELIMITER); PAIRING_TOKENS.put(JavaDocTokenType.DOC_INLINE_TAG_START, JavaDocTokenType.DOC_INLINE_TAG_END); - PAIRING_TOKENS.put(JspTokenType.JSP_EL_RBRACKET, JspTokenType.JSP_EL_LBRACKET); - PAIRING_TOKENS.put(JspTokenType.JSP_EL_RPARENTH, JspTokenType.JSP_EL_LPARENTH); + PAIRING_TOKENS.put(ELTokenType.JSP_EL_RBRACKET, ELTokenType.JSP_EL_LBRACKET); + PAIRING_TOKENS.put(ELTokenType.JSP_EL_RPARENTH, ELTokenType.JSP_EL_LPARENTH); } public int getTokenGroup(IElementType tokenType) { @@ -165,8 +166,8 @@ public class BraceMatchingUtil { tokenType == JspTokenType.JSP_ACTION_START || tokenType == JspTokenType.JSP_ACTION_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == JspTokenType.JSP_DIRECTIVE_ATTRIBUTE_VALUE_START_DELIMITER || - tokenType == JspTokenType.JSP_EL_LBRACKET || - tokenType == JspTokenType.JSP_EL_LPARENTH || + tokenType == ELTokenType.JSP_EL_LBRACKET || + tokenType == ELTokenType.JSP_EL_LPARENTH || tokenType == JavaDocTokenType.DOC_INLINE_TAG_START; } @@ -185,8 +186,8 @@ public class BraceMatchingUtil { tokenType == JspTokenType.JSP_EMPTY_ACTION_END || tokenType == JspTokenType.JSP_ACTION_ATTRIBUTE_VALUE_END_DELIMITER || tokenType == JspTokenType.JSP_DIRECTIVE_ATTRIBUTE_VALUE_END_DELIMITER || - tokenType == JspTokenType.JSP_EL_RBRACKET || - tokenType == JspTokenType.JSP_EL_RPARENTH || + tokenType == ELTokenType.JSP_EL_RBRACKET || + tokenType == ELTokenType.JSP_EL_RPARENTH || tokenType == JavaDocTokenType.DOC_INLINE_TAG_END) { return true; } @@ -261,10 +262,10 @@ public class BraceMatchingUtil { if (ch == ')') return JavaTokenType.RPARENTH; if (ch == '(') return JavaTokenType.LPARENTH; } else if(tokenType instanceof IJspElementType) { - if (ch == ']') return JspTokenType.JSP_EL_RBRACKET; - if (ch == '[') return JspTokenType.JSP_EL_LBRACKET; - if (ch == ')') return JspTokenType.JSP_EL_RPARENTH; - if (ch == '(') return JspTokenType.JSP_EL_LPARENTH; + if (ch == ']') return ELTokenType.JSP_EL_RBRACKET; + if (ch == '[') return ELTokenType.JSP_EL_LBRACKET; + if (ch == ')') return ELTokenType.JSP_EL_RPARENTH; + if (ch == '(') return ELTokenType.JSP_EL_LPARENTH; } return null; //TODO: add more here! diff --git a/source/com/intellij/lexer/HtmlHighlightingLexer.java b/source/com/intellij/lexer/HtmlHighlightingLexer.java index 6c43ec4e2af2..331751434dae 100644 --- a/source/com/intellij/lexer/HtmlHighlightingLexer.java +++ b/source/com/intellij/lexer/HtmlHighlightingLexer.java @@ -4,6 +4,7 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; import com.intellij.psi.xml.XmlTokenType; import com.intellij.psi.jsp.JspTokenType; +import com.intellij.psi.jsp.el.ELTokenType; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.diagnostic.Logger; @@ -70,7 +71,7 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { registerHandler(XmlTokenType.XML_COMMENT_CHARACTERS,value); if (withEl) { - registerHandler(JspTokenType.JSP_EL_CONTENT, new ElEmbeddmentHandler()); + registerHandler(ELTokenType.JSP_EL_CONTENT, new ElEmbeddmentHandler()); } } @@ -106,7 +107,7 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { } } newLexer = scriptLexer; - } else if (super.getTokenType() == JspTokenType.JSP_EL_CONTENT) { + } else if (super.getTokenType() == ELTokenType.JSP_EL_CONTENT) { if (elLexer==null) elLexer = new _ELLexer(); newLexer = elLexer; } diff --git a/source/com/intellij/psi/impl/source/tree/Factory.java b/source/com/intellij/psi/impl/source/tree/Factory.java index 425de95c93c1..26c475946415 100644 --- a/source/com/intellij/psi/impl/source/tree/Factory.java +++ b/source/com/intellij/psi/impl/source/tree/Factory.java @@ -16,6 +16,7 @@ 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; +import com.intellij.psi.jsp.el.ELTokenType; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.java.IJavaDocElementType; import com.intellij.psi.tree.java.IJavaElementType; @@ -520,9 +521,6 @@ public class Factory implements Constants { } else if (type == ANNOTATION_PARAMETER_LIST) { element = new PsiAnnotationParameterListImpl(); - } else if (type == CustomHighlighterTokenType.CUSTOM_CONTENT || - type == JspTokenType.JSP_EL_HOLDER) { - element = new XmlAnotherLanguageContent(type) {}; } else { if (type instanceof IAspectElementType) {