本文整理汇总了Java中com.intellij.lang.javascript.JSTokenTypes.RBRACE属性的典型用法代码示例。如果您正苦于以下问题:Java JSTokenTypes.RBRACE属性的具体用法?Java JSTokenTypes.RBRACE怎么用?Java JSTokenTypes.RBRACE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.lang.javascript.JSTokenTypes
的用法示例。
在下文中一共展示了JSTokenTypes.RBRACE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSwitchStatement
protected void parseSwitchStatement(final PsiBuilder builder)
{
StatementParsing.LOGGER.assertTrue(builder.getTokenType() == JSTokenTypes.SWITCH_KEYWORD);
final PsiBuilder.Marker statement = builder.mark();
builder.advanceLexer();
Parsing.checkMatches(builder, JSTokenTypes.LPAR, JavaScriptBundle.message("javascript.parser.message.expected.lparen"));
getExpressionParsing().parseExpression(builder);
Parsing.checkMatches(builder, JSTokenTypes.RPAR, JavaScriptBundle.message("javascript.parser.message.expected.rparen"));
Parsing.checkMatches(builder, JSTokenTypes.LBRACE, JavaScriptBundle.message("javascript.parser.message.expected.lbrace"));
while(builder.getTokenType() != JSTokenTypes.RBRACE)
{
if(builder.eof())
{
builder.error(JavaScriptBundle.message("javascript.parser.message.unexpected.end.of.file"));
statement.done(JSElementTypes.SWITCH_STATEMENT);
return;
}
parseCaseOrDefaultClause(builder);
}
builder.advanceLexer();
statement.done(JSElementTypes.SWITCH_STATEMENT);
}
示例2: parseCaseOrDefaultClause
private void parseCaseOrDefaultClause(final PsiBuilder builder)
{
final IElementType firstToken = builder.getTokenType();
final PsiBuilder.Marker clause = builder.mark();
if(firstToken != JSTokenTypes.CASE_KEYWORD && firstToken != JSTokenTypes.DEFAULT_KEYWORD)
{
builder.error(JavaScriptBundle.message("javascript.parser.message.expected.catch.or.default"));
}
builder.advanceLexer();
if(firstToken == JSTokenTypes.CASE_KEYWORD)
{
getExpressionParsing().parseExpression(builder);
}
Parsing.checkMatches(builder, JSTokenTypes.COLON, JavaScriptBundle.message("javascript.parser.message.expected.colon"));
while(true)
{
IElementType token = builder.getTokenType();
if(token == null || token == JSTokenTypes.CASE_KEYWORD || token == JSTokenTypes.DEFAULT_KEYWORD || token == JSTokenTypes.RBRACE)
{
break;
}
parseStatement(builder);
}
clause.done(JSElementTypes.CASE_CLAUSE);
}
示例3: evalAnchor
protected void evalAnchor(final Editor editor, final PsiFile file)
{
anchor = null;
final PsiElement at = file.findElementAt(editor.getCaretModel().getOffset());
PsiElement parent;
if(at != null && ((parent = at.getParent()) == myJsClass || (parent instanceof JSFile && myJsClass.getParent().getContainingFile() == parent
.getContext().getContainingFile())))
{
final ASTNode atNode = at.getNode();
if(atNode.getElementType() == JSTokenTypes.RBRACE)
{
return;
}
for(ASTNode node = atNode; node != null; node = node.getTreeNext())
{
if(node.getElementType() == JSTokenTypes.LBRACE)
{
return;
}
}
anchor = at;
}
}
示例4: deleteImport
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();
}
示例5: parseObjectLiteralExpression
public void parseObjectLiteralExpression(final PsiBuilder builder)
{
ExpressionParsing.LOGGER.assertTrue(builder.getTokenType() == JSTokenTypes.LBRACE);
final PsiBuilder.Marker expr = builder.mark();
builder.advanceLexer();
IElementType elementType = builder.getTokenType();
while(elementType != JSTokenTypes.RBRACE && elementType != null)
{
parseProperty(builder);
elementType = builder.getTokenType();
if(elementType == JSTokenTypes.RBRACE)
{
break;
}
else if(elementType == JSTokenTypes.COMMA)
{
builder.advanceLexer();
}
else
{
builder.error(JavaScriptBundle.message("javascript.parser.message.expected.comma"));
}
elementType = builder.getTokenType();
if(elementType == JSTokenTypes.RBRACE)
{
builder.error(JavaScriptBundle.message("javascript.parser.property.expected"));
}
else if(isNotPropertyStart(builder, elementType))
{
break;
}
}
Parsing.checkMatches(builder, JSTokenTypes.RBRACE, JavaScriptBundle.message("javascript.parser.message.expected.rbrace"));
expr.done(JSElementTypes.OBJECT_LITERAL_EXPRESSION);
}
示例6: hasSemanticLineBeforeNextToken
protected boolean hasSemanticLineBeforeNextToken(final PsiBuilder builder)
{
IElementType tokenType = builder.getTokenType();
// force end
if(tokenType == JSTokenTypes.RBRACE)
{
return true;
}
int step = 1;
IElementType rawElementType;
while((rawElementType = builder.rawLookup(step)) != null)
{
if(rawElementType == JSTokenTypes.WHITE_SPACE)
{
int tokenStart = builder.rawTokenTypeStart(step);
CharSequence originalText = builder.getOriginalText();
for(int i = tokenStart; i < originalText.length(); i++)
{
char c = originalText.charAt(i);
if(c == '\n')
{
return true;
}
else if(!Character.isWhitespace(c))
{
return false;
}
}
}
else
{
break;
}
}
return false;
}
示例7: isAppropriateElementTypeForLiteral
@Override
public boolean isAppropriateElementTypeForLiteral(@NotNull IElementType tokenType)
{
return JavaScriptTokenSets.COMMENTS.contains(tokenType) ||
tokenType == JSTokenTypes.WHITE_SPACE ||
tokenType == JSTokenTypes.SEMICOLON ||
tokenType == JSTokenTypes.COMMA ||
tokenType == JSTokenTypes.RPAR ||
tokenType == JSTokenTypes.RBRACKET ||
tokenType == JSTokenTypes.RBRACE ||
tokenType == JSTokenTypes.SINGLE_QUOTE_STRING_LITERAL ||
tokenType == JSTokenTypes.STRING_LITERAL;
}
示例8: visitObjectLiteralExpression
@Override
public void visitObjectLiteralExpression(final ASTNode node)
{
if(((type1 == JSTokenTypes.LBRACE && type2 != JSTokenTypes.RBRACE) ||
type1 == JSTokenTypes.COMMA ||
(type1 != JSTokenTypes.LBRACE && type2 == JSTokenTypes.RBRACE)) && shouldFormatObjectLiteralExpression())
{
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
示例9: visitEmbeddedContent
@Override
public void visitEmbeddedContent(final ASTNode node)
{
if(type2 == JSTokenTypes.END_OF_LINE_COMMENT)
{
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if(JSElementTypes.SOURCE_ELEMENTS.contains(type1) ||
JSElementTypes.SOURCE_ELEMENTS.contains(type2) && type1 != JSTokenTypes.DOT ||
type2 == JSTokenTypes.RBRACE)
{
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
示例10: isPairedBracesAllowedBeforeType
@Override
public boolean isPairedBracesAllowedBeforeType(@NotNull final IElementType lbraceType, @Nullable final IElementType tokenType)
{
return JSTokenTypes.WHITE_SPACE == tokenType || JSTokenTypes.COMMENTS.contains(tokenType) || tokenType == JSTokenTypes.SEMICOLON || tokenType ==
JSTokenTypes.COMMA || tokenType == JSTokenTypes.RPAR || tokenType == JSTokenTypes.RBRACKET || tokenType == JSTokenTypes.RBRACE || null ==
tokenType;
}
示例11: parseObjectLiteralExpression
public void parseObjectLiteralExpression(final PsiBuilder builder)
{
LOGGER.assertTrue(builder.getTokenType() == JSTokenTypes.LBRACE);
final PsiBuilder.Marker expr = builder.mark();
builder.advanceLexer();
IElementType elementType = builder.getTokenType();
while(elementType != JSTokenTypes.RBRACE && elementType != null)
{
parseProperty(builder);
elementType = builder.getTokenType();
if(elementType == JSTokenTypes.RBRACE)
{
break;
}
else if(elementType == JSTokenTypes.COMMA)
{
builder.advanceLexer();
}
else
{
builder.error(JavaScriptBundle.message("javascript.parser.message.expected.comma"));
}
elementType = builder.getTokenType();
if(elementType == JSTokenTypes.RBRACE)
{
builder.error(JavaScriptBundle.message("javascript.parser.property.expected"));
}
else if(isNotPropertyStart(elementType))
{
break;
}
}
Parsing.checkMatches(builder, JSTokenTypes.RBRACE, JavaScriptBundle.message("javascript.parser.message.expected.rbrace"));
expr.done(JSElementTypes.OBJECT_LITERAL_EXPRESSION);
}
示例12: parseBlockOrFunctionBody
protected void parseBlockOrFunctionBody(final PsiBuilder builder, BlockType type)
{
final PsiBuilder.Marker block = type != BlockType.PACKAGE_OR_CLASS_BODY ? builder.mark() : null;
if(builder.getTokenType() != JSTokenTypes.LBRACE)
{
if(block != null)
{
block.rollbackTo();
}
builder.error(JavaScriptBundle.message("javascript.parser.message.expected.lbrace"));
return;
}
builder.advanceLexer();
while(builder.getTokenType() != JSTokenTypes.RBRACE)
{
if(builder.eof())
{
builder.error(JavaScriptBundle.message("javascript.parser.message.missing.rbrace"));
if(block != null)
{
block.done(JSElementTypes.BLOCK_STATEMENT);
}
return;
}
if(type == BlockType.FUNCTION_BODY)
{
parseSourceElement(builder);
}
else if(type == BlockType.BLOCK)
{
parseStatement(builder);
}
else
{
parsePackageBodyStatement(builder);
}
}
builder.advanceLexer();
if(block != null)
{
block.done(JSElementTypes.BLOCK_STATEMENT);
}
}
示例13: getActualParametersRBraceType
@Override
@NotNull
public IElementType getActualParametersRBraceType()
{
return JSTokenTypes.RBRACE;
}
示例14: processBlock
private void processBlock(final ASTNode node)
{
if(JSElementTypes.SOURCE_ELEMENTS.contains(type1) || JSElementTypes.SOURCE_ELEMENTS.contains(type2) ||
type2 == JSTokenTypes.RBRACE)
{
if(isInjectedJSHack(type1, type2) ||
isInjectedJSHack(type2, type1) ||
(type2 == JSTokenTypes.END_OF_LINE_COMMENT && isInlineEndOfLineCommentOnLeft() && type1 != JSElementTypes.IMPORT_STATEMENT))
{
myResult = Spacing.getReadOnlySpacing();
}
else
{
final boolean keepOneLine = myParent.getPsi() instanceof JSFunction ? mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE : mySettings
.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE;
if(keepOneLine && (type1 == JSTokenTypes.LBRACE || type2 == JSTokenTypes.RBRACE))
{
myResult = Spacing.createDependentLFSpacing(0, 1, node.getTextRange(), mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else
{
if((JSElementTypes.IMPORT_STATEMENT == type1 && JSElementTypes.IMPORT_STATEMENT != type2 && JSTokenTypes.RBRACE != type2) || (JSElementTypes
.IMPORT_STATEMENT != type1 && JSTokenTypes.LBRACE != type1 && JSElementTypes.IMPORT_STATEMENT == type2))
{
myResult = Spacing.createSpacing(0, 0, 2, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if(JSElementTypes.IMPORT_STATEMENT == type1 && JSElementTypes.IMPORT_STATEMENT == type2)
{
myResult = getSpacingBetweenImports();
}
else
{
if(shouldPlaceExtraLinesAroundMethod())
{
myResult = Spacing.createSpacing(0, 0, 1 + mySettings.BLANK_LINES_AROUND_METHOD, mySettings.KEEP_LINE_BREAKS,
mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else
{
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
}
}
}
}
示例15: shouldPlaceExtraLinesAroundMethod
private boolean shouldPlaceExtraLinesAroundMethod()
{
return (type1 == JSElementTypes.FUNCTION_DECLARATION && type2 != JSTokenTypes.RBRACE) || (type1 == JSElementTypes.VAR_STATEMENT && type2 ==
JSElementTypes.FUNCTION_DECLARATION);
}