mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
less classes for @interface parsing
This commit is contained in:
+1
-1
@@ -66,7 +66,7 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
return ENUM_DEFINITION;
|
||||
}
|
||||
|
||||
if (builder.getTokenType() == mAT && AnnotationDefinition.parse(builder, parser)) {
|
||||
if (builder.getTokenType() == mAT && AnnotationDefinition.parseAnnotationDefinition(builder, parser)) {
|
||||
return ANNOTATION_DEFINITION;
|
||||
}
|
||||
|
||||
|
||||
-54
@@ -1,54 +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.blocks;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.Separators;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members.AnnotationMember;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
|
||||
/**
|
||||
* @autor: Dmitry.Krasilschikov
|
||||
* @date: 18.03.2007
|
||||
*/
|
||||
public class AnnotationBlock implements GroovyElementTypes {
|
||||
public static boolean parse(PsiBuilder builder, GroovyParser parser) {
|
||||
//see also InterfaceBlock, EnumBlock, AnnotationBlock
|
||||
PsiBuilder.Marker abMarker = builder.mark();
|
||||
|
||||
if (!ParserUtils.getToken(builder, mLCURLY)) {
|
||||
builder.error(GroovyBundle.message("lcurly.expected"));
|
||||
abMarker.rollbackTo();
|
||||
return false;
|
||||
}
|
||||
|
||||
Separators.parse(builder);
|
||||
|
||||
while (!builder.eof() && builder.getTokenType() != mRCURLY) {
|
||||
if (!AnnotationMember.parse(builder, parser)) builder.advanceLexer();
|
||||
Separators.parse(builder);
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mRCURLY, GroovyBundle.message("rcurly.expected"));
|
||||
|
||||
abMarker.done(CLASS_BODY);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +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.members;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.TypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.declaration.Declaration;
|
||||
|
||||
/**
|
||||
* @author: Dmitry.Krasilschikov
|
||||
* @date: 03.04.2007
|
||||
*/
|
||||
public class AnnotationMember implements GroovyElementTypes {
|
||||
public static boolean parse(PsiBuilder builder, GroovyParser parser) {
|
||||
|
||||
//type definition
|
||||
PsiBuilder.Marker typeDeclStartMarker = builder.mark();
|
||||
|
||||
if (TypeDefinition.parse(builder, parser)) {
|
||||
typeDeclStartMarker.drop();
|
||||
return true;
|
||||
} else {
|
||||
typeDeclStartMarker.rollbackTo();
|
||||
}
|
||||
|
||||
PsiBuilder.Marker declMarker = builder.mark();
|
||||
|
||||
//typized var definition
|
||||
if (Declaration.parse(builder, true, true, parser)) {
|
||||
declMarker.drop();
|
||||
return true;
|
||||
} else {
|
||||
declMarker.rollbackTo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
-3
@@ -20,7 +20,9 @@ import com.intellij.lang.PsiBuilder;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.blocks.AnnotationBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.Separators;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.declaration.Declaration;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.TypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
|
||||
/**
|
||||
@@ -28,7 +30,7 @@ import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
* @date: 16.03.2007
|
||||
*/
|
||||
public class AnnotationDefinition implements GroovyElementTypes {
|
||||
public static boolean parse(PsiBuilder builder, GroovyParser parser) {
|
||||
public static boolean parseAnnotationDefinition(PsiBuilder builder, GroovyParser parser) {
|
||||
if (!ParserUtils.getToken(builder, mAT)) {
|
||||
return false;
|
||||
}
|
||||
@@ -42,8 +44,45 @@ public class AnnotationDefinition implements GroovyElementTypes {
|
||||
return false;
|
||||
}
|
||||
|
||||
AnnotationBlock.parse(builder, parser);
|
||||
PsiBuilder.Marker abMarker = builder.mark();
|
||||
|
||||
if (!ParserUtils.getToken(builder, mLCURLY, GroovyBundle.message("lcurly.expected"))) {
|
||||
abMarker.rollbackTo();
|
||||
return false;
|
||||
}
|
||||
|
||||
Separators.parse(builder);
|
||||
|
||||
while (!builder.eof() && builder.getTokenType() != mRCURLY) {
|
||||
if (!parseAnnotationMember(builder, parser)) builder.advanceLexer();
|
||||
Separators.parse(builder);
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mRCURLY, GroovyBundle.message("rcurly.expected"));
|
||||
|
||||
abMarker.done(CLASS_BODY);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean parseAnnotationMember(PsiBuilder builder, GroovyParser parser) {
|
||||
//type definition
|
||||
PsiBuilder.Marker typeDeclStartMarker = builder.mark();
|
||||
|
||||
if (TypeDefinition.parse(builder, parser)) {
|
||||
typeDeclStartMarker.drop();
|
||||
return true;
|
||||
}
|
||||
|
||||
typeDeclStartMarker.rollbackTo();
|
||||
|
||||
PsiBuilder.Marker declMarker = builder.mark();
|
||||
|
||||
if (Declaration.parse(builder, true, true, parser)) {
|
||||
declMarker.drop();
|
||||
return true;
|
||||
}
|
||||
|
||||
declMarker.rollbackTo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user