Java 类com.intellij.lang.javascript.JSElementTypes 实例源码

项目:emberjs-plugin    文件:EmberJSParser.java   
@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();
}
项目:emberjs-plugin    文件:EmberJSParser.java   
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;
}
项目:emberjs-plugin    文件:EmberJSParser.java   
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;
}
项目:emberjs-plugin    文件:EmberJSParser.java   
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"));
    }
}
项目:WebStormRequireJsPlugin    文件:RequirejsProjectComponent.java   
protected void parseMapConfigElement(TreeElement mapConfigElement) {
    if (null == mapConfigElement) {
        return;
    }

    if (mapConfigElement.getElementType() == JSElementTypes.PROPERTY) {
        String module = getJSPropertyName(mapConfigElement);

        TreeElement mapAliasesObject = (TreeElement) mapConfigElement
                .findChildByType(JSElementTypes.OBJECT_LITERAL_EXPRESSION);

        if (null != mapAliasesObject) {
            RequireMapModule requireMapModule = new RequireMapModule();

            requireMapModule.module = module;
            TreeElement mapAliasProperty = (TreeElement) mapAliasesObject.findChildByType(JSElementTypes.PROPERTY);
            parseMapAliasProperty(requireMapModule, mapAliasProperty);

            requireMap.addModule(requireMapModule);
        }
    }

    parseMapConfigElement(mapConfigElement.getTreeNext());
}
项目:WebStormRequireJsPlugin    文件:RequirejsProjectComponent.java   
protected void parseMapAliasProperty(RequireMapModule requireMapModule, TreeElement mapAliasProperty) {
    if (null == mapAliasProperty) {
        return;
    }

    if (mapAliasProperty.getElementType() == JSElementTypes.PROPERTY) {
        RequirePathAlias alias = new RequirePathAlias();
        alias.alias = getJSPropertyName(mapAliasProperty);
        alias.path = getJSPropertyLiteralValue(mapAliasProperty);

        if (null != alias.alias && alias.path != null) {
            requireMapModule.addAlias(alias);
        } else {
            LOG.debug("Error parse require js path", alias);
        }
    }

    parseMapAliasProperty(requireMapModule, mapAliasProperty.getTreeNext());
}
项目:consulo-javascript    文件:EcmaScript4StatementParsing.java   
private void parseReferenceList(final PsiBuilder builder)
{
    final IElementType tokenType = builder.getTokenType();
    EcmaScript4StatementParsing.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(tokenType == JSTokenTypes.EXTENDS_KEYWORD ? JSElementTypes.EXTENDS_LIST : JSElementTypes.IMPLEMENTS_LIST);
}
项目:WebStormRequireJsPlugin    文件:RequirejsProjectComponent.java   
private void parsePackage(TreeElement node) {
    if (null == node) {
        return;
    }
    if (node.getElementType() == JSElementTypes.OBJECT_LITERAL_EXPRESSION
        || node.getElementType() == JSElementTypes.LITERAL_EXPRESSION
    ) {
        // TODO: Not adding not resolve package
        Package p = new Package();
        packageConfig.packages.add(p);
        if (node.getElementType() == JSElementTypes.OBJECT_LITERAL_EXPRESSION) {
            TreeElement prop = (TreeElement) node.findChildByType(JSElementTypes.PROPERTY);
            parsePackageObject(prop, p);
        } else {
            p.name = dequote(node.getText());
        }
        normalizeParsedPackage(p);
        validatePackage(p);
    }
    TreeElement next = node.getTreeNext();
    parsePackage(next);
}
项目:consulo-javascript    文件:JSSpacingProcessor.java   
@Override
public void visitWithStatement(final ASTNode node)
{
    if(type1 == JSTokenTypes.WITH_KEYWORD && type2 == JSTokenTypes.LPAR)
    {
        setSingleSpace(mySettings.SPACE_BEFORE_WHILE_PARENTHESES);
    }
    else if(type1 == JSTokenTypes.RPAR && type2 == JSElementTypes.BLOCK_STATEMENT)
    {
        TextRange dependentRange = new TextRange(myParent.getStartOffset(), myChild1.getTextRange().getEndOffset());
        setBraceSpace(mySettings.SPACE_BEFORE_WHILE_LBRACE, mySettings.BRACE_STYLE, dependentRange);
    }
    else if(type1 == JSTokenTypes.LPAR || type2 == JSTokenTypes.RPAR)
    {
        setSingleSpace(mySettings.SPACE_WITHIN_WHILE_PARENTHESES);
    }
}
项目:WebStormRequireJsPlugin    文件:RequirejsProjectComponent.java   
@Nullable
private static String getJSPropertyLiteralValue(TreeElement jsProperty) {
    TokenSet availablePropertyValueTokenSet = TokenSet.create(
            JSElementTypes.LITERAL_EXPRESSION,
            JSElementTypes.BINARY_EXPRESSION,
            JSElementTypes.CONDITIONAL_EXPRESSION);
    TreeElement jsPropertyValue = (TreeElement) jsProperty.findChildByType(availablePropertyValueTokenSet);
    if (null == jsPropertyValue) {
        return null;
    }

    if (jsPropertyValue.getElementType() != JSElementTypes.LITERAL_EXPRESSION) {
        jsPropertyValue = (TreeElement) jsPropertyValue.findChildByType(JSElementTypes.LITERAL_EXPRESSION);
        if (null == jsPropertyValue) {
            return null;
        }
    }

    return dequote(jsPropertyValue.getText());
}
项目:consulo-javascript    文件:ExpressionParsing.java   
protected void parseProperty(final PsiBuilder builder)
{
    final IElementType nameToken = builder.getTokenType();
    final PsiBuilder.Marker property = builder.mark();

    if(isNotPropertyStart(builder, nameToken))
    {
        builder.error(JavaScriptBundle.message("javascript.parser.message.expected.identifier.string.literal.or.numeric.literal"));
    }
    builder.advanceLexer();

    Parsing.checkMatches(builder, JSTokenTypes.COLON, JavaScriptBundle.message("javascript.parser.message.expected.colon"));

    builder.putUserData(WITHIN_OBJECT_LITERAL_EXPRESSION, Boolean.TRUE);
    if(!parseAssignmentExpression(builder))
    {
        builder.error(JavaScriptBundle.message("javascript.parser.message.expected.expression"));
    }
    builder.putUserData(WITHIN_OBJECT_LITERAL_EXPRESSION, null);

    property.done(JSElementTypes.PROPERTY);
}
项目:consulo-javascript    文件:JSSpacingProcessor.java   
@Override
public void visitForInStatement(final ASTNode node)
{
    if(type1 == JSTokenTypes.VAR_KEYWORD || type2 == JSTokenTypes.VAR_KEYWORD)
    {
        setSingleSpace(true);
    }
    else if(type1 == JSTokenTypes.FOR_KEYWORD && type2 == JSTokenTypes.LPAR)
    {
        setSingleSpace(mySettings.SPACE_BEFORE_FOR_PARENTHESES);
    }
    else if(type1 == JSTokenTypes.RPAR && type2 == JSElementTypes.BLOCK_STATEMENT)
    {
        TextRange dependentRange = new TextRange(myParent.getStartOffset(), myChild1.getTextRange().getEndOffset());
        setBraceSpace(mySettings.SPACE_BEFORE_FOR_LBRACE, mySettings.BRACE_STYLE, dependentRange);
    }
    else if(type1 == JSTokenTypes.LPAR || type2 == JSTokenTypes.RPAR)
    {
        setSingleSpace(mySettings.SPACE_WITHIN_FOR_PARENTHESES);
    }
}
项目:consulo-javascript    文件:AS3InterfaceStubDumper.java   
@Override
protected void dumpInterfacesList(String indent, Traits it, boolean anInterface)
{
    String[] interfaces;
    if(it.interfaces.length > 0)
    {
        interfaces = new String[it.interfaces.length];

        int i = 0;
        for(Multiname name : it.interfaces)
        {
            interfaces[i++] = getMultinameAsPackageName(name, null, true);
        }
        new JSReferenceListStubImpl(interfaces, parents.getLast(), anInterface ? JSElementTypes.EXTENDS_LIST : JSElementTypes.IMPLEMENTS_LIST);
    }
}
项目:consulo-javascript    文件:ExpressionParsing.java   
private boolean parseBitwiseANDExpression(final PsiBuilder builder, final boolean allowIn)
{
    PsiBuilder.Marker expr = builder.mark();
    if(!parseEqualityExpression(builder, allowIn))
    {
        expr.drop();
        return false;
    }

    while(builder.getTokenType() == JSTokenTypes.AND)
    {
        builder.advanceLexer();
        if(!parseEqualityExpression(builder, allowIn))
        {
            builder.error(JavaScriptBundle.message("javascript.parser.message.expected.expression"));
        }
        expr.done(JSElementTypes.BINARY_EXPRESSION);
        expr = expr.precede();
    }

    expr.drop();
    return true;
}
项目:consulo-javascript    文件:JSTryStatementImpl.java   
@Override
public JSStatement getStatement()
{
    ASTNode child = getNode().getFirstChildNode();
    while(child != null)
    {
        final IElementType type = child.getElementType();
        if(JSElementTypes.STATEMENTS.contains(type))
        {
            return (JSStatement) child.getPsi();
        }
        if(type == JSTokenTypes.FINALLY_KEYWORD)
        {
            break;
        }
        child = child.getTreeNext();
    }
    return null;
}
项目:consulo-javascript    文件:JSSpacingProcessor.java   
@Override
public void visitTryStatement(final ASTNode node)
{
    if(type1 == JSTokenTypes.TRY_KEYWORD && type2 == JSElementTypes.BLOCK_STATEMENT)
    {
        setBraceSpace(mySettings.SPACE_BEFORE_TRY_LBRACE, mySettings.BRACE_STYLE, null);
    }
    else if(type2 == JSElementTypes.CATCH_BLOCK)
    {
        setLineBreakSpace(mySettings.CATCH_ON_NEW_LINE);
    }
    else if(type2 == JSTokenTypes.FINALLY_KEYWORD)
    {
        setLineBreakSpace(mySettings.FINALLY_ON_NEW_LINE);
    }
    else if(type1 == JSTokenTypes.FINALLY_KEYWORD)
    {
        setBraceSpace(mySettings.SPACE_BEFORE_FINALLY_LBRACE, mySettings.BRACE_STYLE, null);
    }
}
项目:consulo-javascript    文件:ExpressionParsing.java   
private boolean parseMultiplicativeExpression(final PsiBuilder builder)
{
    PsiBuilder.Marker expr = builder.mark();
    if(!parseIsAsExpression(builder))
    {
        expr.drop();
        return false;
    }

    while(JSTokenTypes.MULTIPLICATIVE_OPERATIONS.contains(builder.getTokenType()))
    {
        builder.advanceLexer();
        if(!parseUnaryExpression(builder))
        {
            builder.error(JavaScriptBundle.message("javascript.parser.message.expected.expression"));
        }
        expr.done(JSElementTypes.BINARY_EXPRESSION);
        expr = expr.precede();
    }

    expr.drop();
    return true;
}
项目:consulo-javascript    文件:ExpressionParsing.java   
private boolean parseUnaryExpression(final PsiBuilder builder)
{
    final IElementType tokenType = builder.getTokenType();
    if(JSTokenTypes.UNARY_OPERATIONS.contains(tokenType))
    {
        final PsiBuilder.Marker expr = builder.mark();
        builder.advanceLexer();
        if(!parseUnaryExpression(builder))
        {
            builder.error(JavaScriptBundle.message("javascript.parser.message.expected.expression"));
        }
        expr.done(JSElementTypes.PREFIX_EXPRESSION);
        return true;
    }
    else
    {
        return parsePostfixExpression(builder);
    }
}
项目:consulo-javascript    文件:ExpressionParsing.java   
private boolean parsePostfixExpression(PsiBuilder builder)
{
    final PsiBuilder.Marker expr = builder.mark();
    if(!parseMemberExpression(builder, true))
    {
        expr.drop();
        return false;
    }

    final IElementType tokenType = builder.getTokenType();
    if(tokenType == JSTokenTypes.PLUSPLUS || tokenType == JSTokenTypes.MINUSMINUS)
    {
        builder.advanceLexer();
        expr.done(JSElementTypes.POSTFIX_EXPRESSION);
    }
    else
    {
        expr.drop();
    }
    return true;
}
项目:consulo-javascript    文件:EcmaScript4StatementParsing.java   
private void parseClassNoMarker(final PsiBuilder builder, final @NotNull PsiBuilder.Marker clazz)
{
    final IElementType tokenType = builder.getTokenType();
    EcmaScript4StatementParsing.LOGGER.assertTrue(JSTokenTypes.CLASS_KEYWORD == tokenType || JSTokenTypes.INTERFACE_KEYWORD == tokenType);

    builder.advanceLexer();
    if(!getExpressionParsing().parseQualifiedTypeName(builder))
    {
        builder.error(JavaScriptBundle.message("javascript.parser.message.expected.typename"));
    }

    if(builder.getTokenType() == JSTokenTypes.EXTENDS_KEYWORD)
    {
        parseReferenceList(builder);
    }

    if(builder.getTokenType() == JSTokenTypes.IMPLEMENTS_KEYWORD)
    {
        parseReferenceList(builder);
    }

    parseBlockOrFunctionBody(builder, BlockType.PACKAGE_OR_CLASS_BODY);
    clazz.done(JSElementTypes.CLASS);
}
项目:consulo-javascript    文件:JSMergeParallelForInLoopsIntention.java   
/**
 * Method provided as a workaround of a bug in the JavaScript language IDEA plugin.
 * @param forInStatement the for-in statement
 * @return the for-in statement collection expression
 */
private static JSExpression getVariableExpression(JSForInStatement forInStatement) {
    final ASTNode statementNode = forInStatement.getNode();
    ASTNode       child         = ((statementNode == null) ? null : statementNode.getFirstChildNode());

    while (child != null) {
        if (child.getElementType() == JSTokenTypes.IN_KEYWORD) {
            return null;
        }

        if (JSElementTypes.EXPRESSIONS.contains(child.getElementType())) {
            return (JSExpression) child.getPsi();
        }
        child = child.getTreeNext();
    }

    return null;
}
项目:consulo-javascript    文件:StatementParsing.java   
protected void parseTryStatement(final PsiBuilder builder)
{
    StatementParsing.LOGGER.assertTrue(builder.getTokenType() == JSTokenTypes.TRY_KEYWORD);
    final PsiBuilder.Marker statement = builder.mark();
    builder.advanceLexer();
    parseBlock(builder);

    while(builder.getTokenType() == JSTokenTypes.CATCH_KEYWORD)
    {
        parseCatchBlock(builder);
    }

    if(builder.getTokenType() == JSTokenTypes.FINALLY_KEYWORD)
    {
        builder.advanceLexer();
        parseBlock(builder);
    }

    statement.done(JSElementTypes.TRY_STATEMENT);
}
项目:consulo-javascript    文件:EcmaScript4StatementParsing.java   
private boolean parseNamespaceNoMarker(final PsiBuilder builder, final @NotNull PsiBuilder.Marker useNSStatement)
{
    EcmaScript4StatementParsing.LOGGER.assertTrue(builder.getTokenType() == JSTokenTypes.NAMESPACE_KEYWORD);

    builder.advanceLexer();
    if(builder.getTokenType() == JSTokenTypes.LPAR)
    {
        useNSStatement.rollbackTo();
        return false;
    }

    if(!getExpressionParsing().parseQualifiedTypeName(builder))
    {
        builder.error(JavaScriptBundle.message("javascript.parser.message.expected.typename"));
    }
    if(builder.getTokenType() == JSTokenTypes.EQ)
    {
        builder.advanceLexer();
        checkMatches(builder, JSTokenTypes.STRING_LITERAL, JavaScriptBundle.message("javascript.parser.message.expected.string.literal"));
    }
    checkForSemicolon(builder);
    useNSStatement.done(JSElementTypes.NAMESPACE_DECLARATION);
    return true;
}
项目:consulo-javascript    文件:JSForStatementImpl.java   
@Override
public JSExpression getUpdate()
{
    ASTNode child = getNode().getFirstChildNode();
    int semicolonCount = 0;
    while(child != null)
    {
        if(child.getElementType() == JSTokenTypes.SEMICOLON)
        {
            semicolonCount++;
        }
        else if(semicolonCount == 2 && JSElementTypes.EXPRESSIONS.contains(child.getElementType()))
        {
            return (JSExpression) child.getPsi();
        }
        child = child.getTreeNext();
    }
    return null;
}
项目:consulo-javascript    文件:JSConditionalExpressionImpl.java   
@Override
public JSExpression getElse()
{
    boolean questPassed = false;
    boolean colonPassed = false;
    ASTNode child = getNode().getFirstChildNode();
    while(child != null)
    {
        final IElementType type = child.getElementType();
        if(type == JSTokenTypes.QUEST)
        {
            questPassed = true;
        }
        if(type == JSTokenTypes.COLON)
        {
            colonPassed = true;
        }
        if(questPassed && colonPassed && JSElementTypes.EXPRESSIONS.contains(type))
        {
            return (JSExpression) child.getPsi();
        }

        child = child.getTreeNext();
    }
    return null;
}
项目:consulo-javascript    文件:JSDocumentationUtils.java   
static
@Nullable
ASTNode findTrailingCommentInFunctionBody(final @NotNull JSFunction function)
{
    final ASTNode block = function.getNode().findChildByType(JSElementTypes.BLOCK_STATEMENT);
    if(block == null)
    {
        return null;
    }

    for(ASTNode prev = block.getLastChildNode(); prev != null; prev = prev.getTreePrev())
    {
        if(prev.getElementType() == JSElementTypes.RETURN_STATEMENT)
        {
            return block.findChildByType(JSTokenTypes.COMMENTS, prev);
        }
        else if(JSElementTypes.STATEMENTS.contains(prev.getElementType()))
        {
            break;
        }
    }
    return null;
}
项目:consulo-javascript    文件:JSTryStatementImpl.java   
@Override
public JSStatement getFinallyStatement()
{
    ASTNode child = getNode().getFirstChildNode();
    boolean foundFinally = false;
    while(child != null)
    {
        final IElementType type = child.getElementType();
        if(foundFinally && JSElementTypes.STATEMENTS.contains(type))
        {
            return (JSStatement) child.getPsi();
        }
        if(type == JSTokenTypes.FINALLY_KEYWORD)
        {
            foundFinally = true;
        }
        child = child.getTreeNext();
    }
    return null;
}
项目:consulo-javascript    文件:EcmaScript6StatementParsing.java   
private void parseClassNoMarker(final PsiBuilder builder, final @NotNull PsiBuilder.Marker clazz)
{
    builder.advanceLexer();
    if(!JSTokenTypes.IDENTIFIER_TOKENS_SET.contains(builder.getTokenType()))
    {
        builder.error(JavaScriptBundle.message("javascript.parser.message.expected.identifier"));
    }
    else
    {
        builder.advanceLexer();
    }

    if(builder.getTokenType() == JSTokenTypes.EXTENDS_KEYWORD)
    {
        parseReferenceList(builder);
    }

    parseClassBody(builder, BlockType.PACKAGE_OR_CLASS_BODY);
    clazz.done(JSElementTypes.CLASS);
}
项目:consulo-javascript    文件:EcmaScript4StatementParsing.java   
private void parsePackage(final PsiBuilder builder)
{
    final PsiBuilder.Marker packageMarker = builder.mark();
    builder.advanceLexer();
    if(builder.getTokenType() == JSTokenTypes.IDENTIFIER)
    {
        getExpressionParsing().parseQualifiedTypeName(builder);
    }

    if(builder.getTokenType() != JSTokenTypes.LBRACE)
    {
        builder.error(JavaScriptBundle.message("javascript.parser.message.expected.name.or.lbrace"));
    }
    else
    {
        parseBlockOrFunctionBody(builder, BlockType.PACKAGE_OR_CLASS_BODY);
    }
    packageMarker.done(JSElementTypes.PACKAGE_STATEMENT);
}
项目:consulo-javascript    文件:JSVariableBaseImpl.java   
@Override
public void delete() throws IncorrectOperationException
{
    final ASTNode myNode = getNode();
    final ASTNode parent = myNode.getTreeParent();

    if(parent.getElementType() == JSElementTypes.VAR_STATEMENT)
    {
        final JSVariable[] jsVariables = ((JSVarStatement) parent.getPsi()).getVariables();

        if(jsVariables.length == 1)
        {
            parent.getPsi().delete();
        }
        else
        {
            JSChangeUtil.removeRangeWithRemovalOfCommas(myNode, parent);
        }
        return;
    }

    throw new IncorrectOperationException("Cannot delete variable from parent : " + parent.getElementType());
}
项目:consulo-javascript    文件:JSSpacingProcessor.java   
@Override
public void visitWhileStatement(final ASTNode node)
{
    if(type1 == JSTokenTypes.WHILE_KEYWORD && type2 == JSTokenTypes.LPAR)
    {
        setSingleSpace(mySettings.SPACE_BEFORE_WHILE_PARENTHESES);
    }
    else if(type1 == JSTokenTypes.RPAR && type2 == JSElementTypes.BLOCK_STATEMENT)
    {
        TextRange dependentRange = new TextRange(myParent.getStartOffset(), myChild1.getTextRange().getEndOffset());
        setBraceSpace(mySettings.SPACE_BEFORE_WHILE_LBRACE, mySettings.BRACE_STYLE, dependentRange);
    }
    else if(type1 == JSTokenTypes.LPAR || type2 == JSTokenTypes.RPAR)
    {
        setSingleSpace(mySettings.SPACE_WITHIN_WHILE_PARENTHESES);
    }
}
项目:consulo-javascript    文件:JSSpacingProcessor.java   
@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);
    }
}
项目:consulo-javascript    文件:EcmaScript6StatementParsing.java   
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);
}
项目:consulo-javascript    文件:JSForInStatementImpl.java   
@Override
public JSStatement getBody()
{
    ASTNode child = getNode().getFirstChildNode();
    boolean passedRParen = false;
    while(child != null)
    {
        if(child.getElementType() == JSTokenTypes.RPAR)
        {
            passedRParen = true;
        }
        else if(passedRParen && JSElementTypes.STATEMENTS.contains(child.getElementType()))
        {
            return (JSStatement) child.getPsi();
        }
        child = child.getTreeNext();
    }

    return null;
}
项目:react-templates-plugin    文件:RTRepeatExpression.java   
public JSExpression getCollection() {
    final ASTNode myNode = getNode();
    final ASTNode secondExpression = myNode.findChildByType(
            JSElementTypes.EXPRESSIONS, myNode.findChildByType(JSTokenTypes.IN_KEYWORD)
    );
    return secondExpression != null ? (JSExpression) secondExpression.getPsi() : null;
}
项目:react-templates-plugin    文件:RTRepeatExpression.java   
public JSExpression getCollection() {
    final ASTNode myNode = getNode();
    final ASTNode secondExpression = myNode.findChildByType(
            JSElementTypes.EXPRESSIONS, myNode.findChildByType(JSTokenTypes.IN_KEYWORD)
    );
    return secondExpression != null ? (JSExpression) secondExpression.getPsi() : null;
}
项目:emberjs-plugin    文件:EmberJSParser.java   
public EmberJSParser(PsiBuilder builder) {
    super(JavaScriptSupportLoader.JAVASCRIPT_1_5, builder);
    myExpressionParser = new EmberJSExpressionParser();
    myStatementParser = new StatementParser<EmberJSParser>(this) {
        @Override
        protected void doParseStatement(boolean canHaveClasses) {
            final IElementType firstToken = builder.getTokenType();
            if (firstToken == JSTokenTypes.LBRACE) {
                parseExpressionStatement();
                checkForSemicolon();
                return;
            }
            if (isIdentifierToken(firstToken)) {
                final IElementType nextToken = builder.lookAhead(1);
                if (nextToken == JSTokenTypes.IN_KEYWORD) {
                    parseInStatement();
                    return;
                }
            }
            if (builder.getTokenType() == JSTokenTypes.LPAR) {
                if (parseInStatement()) {
                    return;
                }
            }
            super.doParseStatement(canHaveClasses);
        }

        private boolean parseInStatement() {
            PsiBuilder.Marker statement = builder.mark();
            if (!getExpressionParser().parseInExpression()) {
                statement.drop();
                return false;
            }
            statement.done(JSElementTypes.EXPRESSION_STATEMENT);
            return true;
        }
    };
}
项目:emberjs-plugin    文件:EmberJSParser.java   
private boolean parseAsExpression() {
    PsiBuilder.Marker expr = builder.mark();
    buildTokenElement(JSElementTypes.REFERENCE_EXPRESSION);
    builder.advanceLexer();
    parseExplicitIdentifierWithError();
    expr.done(EmberJSElementTypes.AS_EXPRESSION);
    return true;
}
项目:emberjs-plugin    文件:EmberJSRepeatExpression.java   
public JSExpression getCollection() {
    final ASTNode myNode = getNode();
    final ASTNode secondExpression = myNode.findChildByType(
            JSElementTypes.EXPRESSIONS, myNode.findChildByType(JSTokenTypes.IN_KEYWORD)
    );
    return secondExpression != null ? (JSExpression)secondExpression.getPsi() : null;
}
项目:WebStormRequireJsPlugin    文件:RequirejsProjectComponent.java   
public void parseMainJsFile(TreeElement node) {

        TreeElement firstChild = node.getFirstChildNode();
        if (firstChild != null) {
            parseMainJsFile(firstChild);
        }

        TreeElement nextNode = node.getTreeNext();
        if (nextNode != null) {
            parseMainJsFile(nextNode);
        }

        if (node.getElementType() == JSTokenTypes.IDENTIFIER) {
            if (node.getText().equals("requirejs") || node.getText().equals("require")) {
                TreeElement treeParent = node.getTreeParent();

                if (null != treeParent) {
                    ASTNode firstTreeChild = treeParent.findChildByType(JSElementTypes.OBJECT_LITERAL_EXPRESSION);
                    TreeElement nextTreeElement = treeParent.getTreeNext();
                    if (null != firstTreeChild) {
                        parseRequirejsConfig((TreeElement) firstTreeChild
                            .getFirstChildNode()
                        );
                    } else if (null != nextTreeElement && nextTreeElement.getElementType() == JSTokenTypes.DOT) {
                        nextTreeElement = nextTreeElement.getTreeNext();
                        if (null != nextTreeElement && nextTreeElement.getText().equals("config")) {
                            treeParent = nextTreeElement.getTreeParent();
                            findAndParseConfig(treeParent);
                        }
                    } else {
                        findAndParseConfig(treeParent);
                    }
                }
            }
        }
    }