mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
compact
This commit is contained in:
-58
@@ -1,58 +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.typeDefinitions;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement.ReferenceElementResult.*;
|
||||
|
||||
/**
|
||||
* @autor: Dmitry.Krasilschikov
|
||||
* @date: 16.03.2007
|
||||
*/
|
||||
public class ExtendsClause implements GroovyElementTypes {
|
||||
public static IElementType parse(PsiBuilder builder) {
|
||||
PsiBuilder.Marker sccMarker = builder.mark();
|
||||
|
||||
if (!ParserUtils.getToken(builder, kEXTENDS)) {
|
||||
sccMarker.rollbackTo();
|
||||
return NONE;
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (ReferenceElement.parseReferenceElement(builder) == fail) {
|
||||
sccMarker.rollbackTo();
|
||||
return WRONGWAY;
|
||||
}
|
||||
|
||||
while (ParserUtils.getToken(builder, mCOMMA)) {
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (ReferenceElement.parseReferenceElement(builder) == fail) {
|
||||
sccMarker.rollbackTo();
|
||||
return WRONGWAY;
|
||||
}
|
||||
}
|
||||
|
||||
sccMarker.done(EXTENDS_CLAUSE);
|
||||
return EXTENDS_CLAUSE;
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +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.typeDefinitions;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement.ReferenceElementResult.fail;
|
||||
|
||||
/**
|
||||
* @autor: Dmitry.Krasilschikov
|
||||
* @date: 16.03.2007
|
||||
*/
|
||||
public class ImplementsClause implements GroovyElementTypes {
|
||||
public static IElementType parse(PsiBuilder builder) {
|
||||
PsiBuilder.Marker isMarker = builder.mark();
|
||||
|
||||
if (!ParserUtils.getToken(builder, kIMPLEMENTS)) {
|
||||
isMarker.rollbackTo();
|
||||
return NONE;
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (ReferenceElement.parseReferenceElement(builder)== fail) {
|
||||
isMarker.rollbackTo();
|
||||
return WRONGWAY;
|
||||
}
|
||||
|
||||
while (ParserUtils.getToken(builder, mCOMMA)) {
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (ReferenceElement.parseReferenceElement(builder) == fail) {
|
||||
isMarker.rollbackTo();
|
||||
return WRONGWAY;
|
||||
}
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
isMarker.done(IMPLEMENTS_CLAUSE);
|
||||
return IMPLEMENTS_CLAUSE;
|
||||
}
|
||||
}
|
||||
+33
@@ -18,9 +18,11 @@ package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefiniti
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionInitializationContext;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeArguments;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.elements.GrReferenceListElementType;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement.ReferenceElementResult.fail;
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement.ReferenceElementResult.mayBeType;
|
||||
@@ -34,6 +36,37 @@ import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDe
|
||||
public class ReferenceElement implements GroovyElementTypes {
|
||||
public static final String DUMMY_IDENTIFIER = CompletionInitializationContext.DUMMY_IDENTIFIER_TRIMMED; //inserted by completion
|
||||
|
||||
public static IElementType parseReferenceList(PsiBuilder builder,
|
||||
final IElementType startElement,
|
||||
final GrReferenceListElementType<?> clauseType) {
|
||||
PsiBuilder.Marker isMarker = builder.mark();
|
||||
|
||||
if (!ParserUtils.getToken(builder, startElement)) {
|
||||
isMarker.rollbackTo();
|
||||
return NONE;
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (parseReferenceElement(builder)== fail) {
|
||||
isMarker.rollbackTo();
|
||||
return WRONGWAY;
|
||||
}
|
||||
|
||||
while (ParserUtils.getToken(builder, mCOMMA)) {
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (parseReferenceElement(builder) == fail) {
|
||||
isMarker.rollbackTo();
|
||||
return WRONGWAY;
|
||||
}
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
isMarker.done(clauseType);
|
||||
return clauseType;
|
||||
}
|
||||
|
||||
public enum ReferenceElementResult {
|
||||
mayBeType, mustBeType, fail
|
||||
}
|
||||
|
||||
+5
-5
@@ -95,10 +95,10 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
|
||||
TypeParameters.parse(builder);
|
||||
|
||||
ExtendsClause.parse(builder);
|
||||
ReferenceElement.parseReferenceList(builder, kEXTENDS, EXTENDS_CLAUSE);
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
ImplementsClause.parse(builder);
|
||||
ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE);
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (!parseInterfaceBlock(builder, name, parser)) {
|
||||
@@ -127,12 +127,12 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
TypeParameters.parse(builder);
|
||||
|
||||
if (kEXTENDS.equals(builder.getTokenType())) {
|
||||
ExtendsClause.parse(builder);
|
||||
ReferenceElement.parseReferenceList(builder, kEXTENDS, EXTENDS_CLAUSE);
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
}
|
||||
|
||||
if (kIMPLEMENTS.equals(builder.getTokenType())) {
|
||||
ImplementsClause.parse(builder);
|
||||
ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE);
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
@@ -161,7 +161,7 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
|
||||
if (WRONGWAY.equals(ImplementsClause.parse(builder))) {
|
||||
if (WRONGWAY.equals(ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user