This commit is contained in:
peter
2011-03-21 13:38:09 +01:00
parent ef7fe4fd47
commit 6d35fa4dd7
2 changed files with 0 additions and 107 deletions
@@ -1,70 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.auxilary;
import com.intellij.lang.PsiBuilder;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.plugins.groovy.GroovyBundle;
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.Pairs;
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
/**
* @autor: Dmitry.Krasilschikov
* @date: 16.03.2007
*/
public class BalancedBrackets implements GroovyElementTypes {
public static boolean parse(PsiBuilder builder) {
PsiBuilder.Marker bbm = builder.mark();
IElementType myBracket = null;
if (ParserUtils.getToken(builder, mLPAREN)) {
myBracket = mLPAREN;
}
if (ParserUtils.getToken(builder, mLCURLY)) {
myBracket = mLCURLY;
}
if (ParserUtils.getToken(builder, mGSTRING_BEGIN)) {
myBracket = mGSTRING_BEGIN;
}
if (myBracket == null) {
bbm.rollbackTo();
builder.error(GroovyBundle.message("lbrack.or.lparen.or.lcurly.or.string_ctor_start.expected"));
return false;
}
if (!BalancedTokens.parse(builder)) {
bbm.rollbackTo();
return false;
}
if (ParserUtils.getToken(builder, mRPAREN) && !mRPAREN.equals(Pairs.pairElementsMap.get(myBracket))
|| ParserUtils.getToken(builder, mRBRACK) && !mRBRACK.equals(Pairs.pairElementsMap.get(myBracket))
|| ParserUtils.getToken(builder, mRCURLY) && !mRCURLY.equals(Pairs.pairElementsMap.get(myBracket))
|| ParserUtils.getToken(builder, mGSTRING_END) && !mGSTRING_END.equals(Pairs.pairElementsMap.get(myBracket))) {
bbm.rollbackTo();
return false;
} else {
bbm.done(BALANCED_BRACKETS);
return true;
}
}
}
@@ -1,37 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.auxilary;
import com.intellij.lang.PsiBuilder;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
/**
* @autor: Dmitry.Krasilschikov
* @date: 16.03.2007
*/
public class BalancedTokens implements GroovyElementTypes {
public static boolean parse(PsiBuilder builder) {
//todo: handle differents brackets cases
do {
if (!BalancedBrackets.parse(builder)) break;
} while (true);
return true;
}
}