本文整理汇总了Java中com.intellij.lang.javascript.JSTokenTypes类的典型用法代码示例。如果您正苦于以下问题:Java JSTokenTypes类的具体用法?Java JSTokenTypes怎么用?Java JSTokenTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSTokenTypes类属于com.intellij.lang.javascript包,在下文中一共展示了JSTokenTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if(element.getParent() instanceof JSStringTemplateExpression) {
if(element.getNode().getElementType() == JSTokenTypes.STRING_TEMPLATE_PART) {
// when the annotator runs in non-typescript a JSStringTemplateExpression element is never
// passed as the element, so we have to resolve it manually here
if(!DialectDetector.isTypeScript(element)) {
element = element.getParent();
}
}
}
if(element instanceof JSStringTemplateExpression) {
if(JSGraphQLLanguageInjectionUtil.isJSGraphQLLanguageInjectionTarget(element)) {
for (ASTNode astNode : element.getNode().getChildren(null)) {
if (astNode.getElementType() == JSTokenTypes.STRING_TEMPLATE_PART) {
final Annotation annotation = holder.createInfoAnnotation(astNode, null);
annotation.setTextAttributes(RELAY_TEMPLATE);
}
}
}
}
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:23,代码来源:JSGraphQLRelayTemplateAnnotator.java
示例2: parseUnaryExpression
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
@Override
protected boolean parseUnaryExpression() {
final IElementType tokenType = builder.getTokenType();
if (tokenType == JSTokenTypes.OR) {
builder.advanceLexer();
return true;
}
if (tokenType == EmberJSTokenTypes.ONE_TIME_BINDING) {
final PsiBuilder.Marker expr = builder.mark();
builder.advanceLexer();
if (!super.parseUnaryExpression()) {
builder.error(JSBundle.message("javascript.parser.message.expected.expression"));
}
expr.done(JSElementTypes.PREFIX_EXPRESSION);
return true;
}
return super.parseUnaryExpression();
}
示例3: parseStringLiteral
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
private boolean parseStringLiteral(IElementType firstToken) {
final PsiBuilder.Marker mark = builder.mark();
IElementType currentToken = firstToken;
StringBuilder literal = new StringBuilder();
while (currentToken == JSTokenTypes.STRING_LITERAL ||
currentToken == EmberJSTokenTypes.ESCAPE_SEQUENCE ||
currentToken == EmberJSTokenTypes.INVALID_ESCAPE_SEQUENCE) {
literal.append(builder.getTokenText());
builder.advanceLexer();
currentToken = builder.getTokenType();
}
mark.done(JSElementTypes.LITERAL_EXPRESSION);
final String errorMessage = validateLiteralText(literal.toString());
if (errorMessage != null) {
builder.error(errorMessage);
}
return true;
}
示例4: parseInExpression
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
public boolean parseInExpression() {
final PsiBuilder.Marker expr = builder.mark();
if (isIdentifierToken(builder.getTokenType())) {
parseExplicitIdentifier();
} else {
final PsiBuilder.Marker keyValue = builder.mark();
parseKeyValue();
if (builder.getTokenType() != JSTokenTypes.IN_KEYWORD) {
expr.rollbackTo();
return false;
} else {
keyValue.done(JSElementTypes.PARENTHESIZED_EXPRESSION);
}
}
builder.advanceLexer();
parseExpression();
if (builder.getTokenType() == EmberJSTokenTypes.TRACK_BY_KEYWORD) {
builder.advanceLexer();
parseExpression();
}
expr.done(EmberJSElementTypes.REPEAT_EXPRESSION);
return true;
}
示例5: parseKeyValue
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
private void parseKeyValue() {
builder.advanceLexer();
final PsiBuilder.Marker comma = builder.mark();
parseExplicitIdentifierWithError();
if (builder.getTokenType() == JSTokenTypes.COMMA) {
builder.advanceLexer();
} else {
builder.error(JSBundle.message("javascript.parser.message.expected.comma"));
}
parseExplicitIdentifierWithError();
comma.done(JSElementTypes.COMMA_EXPRESSION);
if (builder.getTokenType() == JSTokenTypes.RPAR) {
builder.advanceLexer();
} else {
builder.error(JSBundle.message("javascript.parser.message.expected.rparen"));
}
}
示例6: moveImportToEnd
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
private PsiElement moveImportToEnd(JSArrayLiteralExpression imports, JSParameterList parameters, String module, String parameter, PsiElement lastDefine, PsiElement lastParameter)
{
// TODO move to AMDPsiUtil if we need to reuse this in the future
PsiElement lastChild = imports.getChildren()[imports.getChildren().length-1];
if(lastDefine != null)
{
lastChild = lastDefine;
}
PsiElement element = imports.addAfter(JSChangeUtil.createExpressionFromText(imports.getProject(), String.format("%s", module)).getPsi(), lastChild);
imports.getNode().addLeaf(JSTokenTypes.COMMA, ",", element.getNode());
imports.getNode().addLeaf(JSTokenTypes.WHITE_SPACE, "\n", element.getNode());
PsiElement lastParameterChild = parameters.getChildren()[parameters.getChildren().length-1];
if(lastParameter != null)
{
lastParameterChild = lastParameter;
}
PsiElement parameterElement = parameters.addAfter(JSChangeUtil.createExpressionFromText(imports.getProject(), String.format("%s", parameter)).getPsi(), lastParameterChild);
parameters.getNode().addLeaf(JSTokenTypes.COMMA, ",", parameterElement.getNode());
return element;
}
示例7: parseReferenceList
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
private void parseReferenceList(final PsiBuilder builder)
{
final IElementType tokenType = builder.getTokenType();
EcmaScript6StatementParsing.LOGGER.assertTrue(tokenType == JSTokenTypes.EXTENDS_KEYWORD || tokenType == JSTokenTypes.IMPLEMENTS_KEYWORD);
final PsiBuilder.Marker referenceList = builder.mark();
builder.advanceLexer();
if(getExpressionParsing().parseQualifiedTypeName(builder))
{
while(builder.getTokenType() == JSTokenTypes.COMMA)
{
builder.advanceLexer();
if(!getExpressionParsing().parseQualifiedTypeName(builder))
{
break;
}
}
}
referenceList.done(JSElementTypes.EXTENDS_LIST);
}
示例8: injectLanguages
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
@Override
@RequiredReadAction
public void injectLanguages(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context)
{
if(context instanceof JSSimpleLiteralExpression)
{
IElementType literalElementType = ((JSSimpleLiteralExpression) context).getLiteralElementType();
if(literalElementType == JSTokenTypes.REGEXP_LITERAL)
{
int textLength = context.getTextLength() - 1;
String text = context.getText();
if(text.charAt(textLength) != '/')
{
textLength --;
}
registrar.startInjecting(RegExpLanguage.INSTANCE).addPlace(null, null, (PsiLanguageInjectionHost) context, new TextRange(1, textLength)).doneInjecting();
}
}
}
示例9: visitElement
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
@Override public void visitElement(PsiElement element) {
if (element instanceof JSFunction) {
this.visitJSFunctionDeclaration((JSFunction) element);
} else if (element instanceof JSReferenceExpression) {
if (element == element.getParent().getChildren()[0]) {
final PsiElement firstChild = element.getParent().getFirstChild();
if (firstChild != null && firstChild.toString().indexOf(JSTokenTypes.NEW_KEYWORD.toString()) >= 0) {
this.visitJSNewExpression(new JSNewExpressionImpl(element.getParent().getNode()));
}
}
}
else if (element instanceof XmlFile) {
processFile((XmlFile)element);
}
super.visitElement(element);
for (final PsiElement childElement : element.getChildren()) {
childElement.accept(this);
}
}
示例10: deleteImport
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
private static void deleteImport(final JSImportStatement anImport)
{
if(!anImport.isValid())
{
return;
}
PsiElement nextSibling = anImport.getNextSibling();
if(nextSibling instanceof PsiWhiteSpace)
{
// remove with the following whitespace
String whitespace = nextSibling.getText();
if(whitespace.contains("]]>"))
{
nextSibling.replace(JSChangeUtil.createJSTreeFromText(anImport.getProject(), "]]>").getPsi());
}
// don't remove trailing line break if it is an injection suffix
else if(nextSibling.getNextSibling() == null || nextSibling.getNextSibling().getNode().getElementType() != JSTokenTypes.RBRACE ||
!(nextSibling.getParent() instanceof JSBlockStatement) ||
!ImportUtils.isAnonymousEventHandler((JSBlockStatement) nextSibling.getParent()))
{
nextSibling.delete();
}
}
anImport.delete();
}
示例11: parseNewExpression
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
protected boolean parseNewExpression(PsiBuilder builder)
{
ExpressionParsing.LOGGER.assertTrue(builder.getTokenType() == JSTokenTypes.NEW_KEYWORD);
builder.advanceLexer();
if(builder.getTokenType() == JSTokenTypes.FUNCTION_KEYWORD)
{
getFunctionParsing().parseFunctionExpression(builder);
return true;
}
if(!parseMemberExpression(builder, false))
{
builder.error(JavaScriptBundle.message("javascript.parser.message.expected.expression"));
}
return false;
}
示例12: parseDefaultNsStatement
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
private void parseDefaultNsStatement(final PsiBuilder builder)
{
EcmaScript4StatementParsing.LOGGER.assertTrue(builder.getTokenType() == JSTokenTypes.DEFAULT_KEYWORD);
final PsiBuilder.Marker marker = builder.mark();
builder.advanceLexer();
if(builder.getTokenType() == JSTokenTypes.IDENTIFIER && "xml".equals(builder.getTokenText()))
{
builder.advanceLexer();
if(checkMatches(builder, JSTokenTypes.NAMESPACE_KEYWORD, JavaScriptBundle.message("javascript.parser.message.expected.namespace")))
{
if(checkMatches(builder, JSTokenTypes.EQ, JavaScriptBundle.message("javascript.parser.message.expected.equal")))
{
getExpressionParsing().parseExpression(builder);
}
}
}
else
{
builder.error(JavaScriptBundle.message("javascript.parser.message.expected.xml"));
}
marker.done(JSElementTypes.ASSIGNMENT_EXPRESSION);
}
示例13: parseBitwiseORExpression
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
private boolean parseBitwiseORExpression(final PsiBuilder builder, final boolean allowIn)
{
PsiBuilder.Marker expr = builder.mark();
if(!parseBitwiseXORExpression(builder, allowIn))
{
expr.drop();
return false;
}
while(builder.getTokenType() == JSTokenTypes.OR)
{
builder.advanceLexer();
if(!parseBitwiseXORExpression(builder, allowIn))
{
builder.error(JavaScriptBundle.message("javascript.parser.message.expected.expression"));
}
expr.done(JSElementTypes.BINARY_EXPRESSION);
expr = expr.precede();
}
expr.drop();
return true;
}
示例14: visitFunctionDeclaration
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
@Override
public void visitFunctionDeclaration(final ASTNode node)
{
if(type1 == JSTokenTypes.FUNCTION_KEYWORD && type2 == JSElementTypes.REFERENCE_EXPRESSION)
{
setSingleSpace(true);
}
else if(type1 == JSElementTypes.REFERENCE_EXPRESSION && type2 == JSElementTypes.PARAMETER_LIST)
{
setSingleSpace(mySettings.SPACE_BEFORE_METHOD_PARENTHESES);
}
else if(type2 == JSElementTypes.BLOCK_STATEMENT)
{
setBraceSpace(mySettings.SPACE_BEFORE_METHOD_LBRACE, mySettings.METHOD_BRACE_STYLE, myChild1.getTextRange());
}
else if(type1 == JSElementTypes.ATTRIBUTE_LIST && type2 == JSTokenTypes.FUNCTION_KEYWORD)
{
setSingleSpace(true);
}
}
示例15: parseEqualityExpression
import com.intellij.lang.javascript.JSTokenTypes; //导入依赖的package包/类
private boolean parseEqualityExpression(final PsiBuilder builder, final boolean allowIn)
{
PsiBuilder.Marker expr = builder.mark();
if(!parseRelationalExpression(builder, allowIn))
{
expr.drop();
return false;
}
while(JSTokenTypes.EQUALITY_OPERATIONS.contains(builder.getTokenType()))
{
builder.advanceLexer();
if(!parseRelationalExpression(builder, allowIn))
{
builder.error(JavaScriptBundle.message("javascript.parser.message.expected.expression"));
}
expr.done(JSElementTypes.BINARY_EXPRESSION);
expr = expr.precede();
}
expr.drop();
return true;
}