mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] use generated parser for docs, i.e. break last dependency on old parser
This commit is contained in:
+36
@@ -2945,6 +2945,42 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser {
|
||||
return r || p;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// short_code_reference doc_reference_tail*
|
||||
public static boolean doc_reference(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "doc_reference")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _COLLAPSE_, CODE_REFERENCE, "<doc reference>");
|
||||
r = short_code_reference(b, l + 1);
|
||||
r = r && doc_reference_1(b, l + 1);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
// doc_reference_tail*
|
||||
private static boolean doc_reference_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "doc_reference_1")) return false;
|
||||
while (true) {
|
||||
int c = current_position_(b);
|
||||
if (!doc_reference_tail(b, l + 1)) break;
|
||||
if (!empty_element_parsed_guard_(b, "doc_reference_1", c)) break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// '.' code_reference_part
|
||||
public static boolean doc_reference_tail(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "doc_reference_tail")) return false;
|
||||
if (!nextTokenIs(b, T_DOT)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _LEFT_, CODE_REFERENCE, null);
|
||||
r = consumeToken(b, T_DOT);
|
||||
r = r && code_reference_part(b, l + 1);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// DOLLAR_SLASHY_BEGIN fast_dollar_slashy_content? !'$' DOLLAR_SLASHY_END
|
||||
public static boolean dollar_slashy_literal(PsiBuilder b, int l) {
|
||||
|
||||
+6
-20
@@ -1,19 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
*/
|
||||
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.groovydoc.parser.elements;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -22,7 +7,6 @@ import com.intellij.lang.PsiBuilderFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import java.util.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.lexer.GroovyDocTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.lexer.IGroovyDocElementType;
|
||||
@@ -31,9 +15,10 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTag;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -106,8 +91,9 @@ public class GroovyDocTagValueTokenType extends GroovyDocChameleonElementType im
|
||||
PsiBuilder.Marker rootMarker = builder.mark();
|
||||
if (BUILT_IN_TYPES.contains(chameleon.getText())) {
|
||||
builder.advanceLexer();
|
||||
} else {
|
||||
ReferenceElement.parse(builder, false, false, false, false, false);
|
||||
}
|
||||
else {
|
||||
new GroovyParser().parseDocReference(builder);
|
||||
while (!builder.eof()) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
|
||||
+8
-1
@@ -1,5 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.parser;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
@@ -22,6 +21,9 @@ import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.imports.Impor
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.TypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.GroovyGeneratedParserUtils.adapt_builder_;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.GroovyElementTypes.CODE_REFERENCE;
|
||||
|
||||
/**
|
||||
* Parser for Groovy script files
|
||||
*
|
||||
@@ -451,4 +453,9 @@ public class GroovyParser extends GroovyGeneratedParser {
|
||||
marker.done(GroovyElementTypes.LABELED_STATEMENT);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void parseDocReference(PsiBuilder b) {
|
||||
b = adapt_builder_(CODE_REFERENCE, b, this, EXTENDS_SETS_);
|
||||
doc_reference(b, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1217,6 +1217,10 @@ private code_reference_identifiers_soft ::= 'def' | 'as' | 'in' | 'trait' { cons
|
||||
type_code_reference ::= code_reference { elementType = '' name = 'type' }
|
||||
|
||||
private qualified_name ::= <<qualifiedName code_reference>>
|
||||
|
||||
//noinspection BnfUnusedRule
|
||||
doc_reference ::= short_code_reference doc_reference_tail* { elementType = code_reference }
|
||||
left doc_reference_tail ::= '.' code_reference_part { elementType = code_reference }
|
||||
// endregion
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user