mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] support for new module-info syntax and .class file format
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -37,12 +37,12 @@ public interface RefJavaModule extends RefElement {
|
||||
class RequiredModule {
|
||||
@NotNull public final String moduleName;
|
||||
@NotNull public final Map<String, List<String>> packagesExportedByModule;
|
||||
public final boolean isPublic;
|
||||
public final boolean isTransitive;
|
||||
|
||||
public RequiredModule(@NotNull String moduleName, @NotNull Map<String, List<String>> packagesExportedByModule, boolean isPublic) {
|
||||
public RequiredModule(@NotNull String moduleName, @NotNull Map<String, List<String>> packagesExportedByModule, boolean isTransitive) {
|
||||
this.moduleName = moduleName;
|
||||
this.packagesExportedByModule = packagesExportedByModule;
|
||||
this.isPublic = isPublic;
|
||||
this.isTransitive = isTransitive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -1706,9 +1706,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
public void visitProvidesStatement(PsiProvidesStatement statement) {
|
||||
super.visitProvidesStatement(statement);
|
||||
if (myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_9)) {
|
||||
PsiJavaCodeReferenceElement intRef = statement.getInterfaceReference();
|
||||
PsiJavaCodeReferenceElement implRef = statement.getImplementationReference();
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(ModuleHighlightUtil.checkServiceImplementation(implRef, intRef));
|
||||
if (!myHolder.hasErrorResults()) myHolder.addAll(ModuleHighlightUtil.checkServiceImplementations(statement));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -128,27 +128,27 @@ public class JavaModuleGraphUtil {
|
||||
// The resulting graph is used for tracing readability.
|
||||
private static RequiresGraph buildRequiresGraph(Project project) {
|
||||
MultiMap<PsiJavaModule, PsiJavaModule> relations = MultiMap.create();
|
||||
Set<String> publicEdges = ContainerUtil.newTroveSet();
|
||||
Set<String> transitiveEdges = ContainerUtil.newTroveSet();
|
||||
for (Module module : ModuleManager.getInstance(project).getModules()) {
|
||||
Collection<VirtualFile> files = FilenameIndex.getVirtualFilesByName(project, MODULE_INFO_FILE, module.getModuleScope(false));
|
||||
Optional.ofNullable(ContainerUtil.getFirstItem(files))
|
||||
.map(PsiManager.getInstance(project)::findFile)
|
||||
.map(f -> f instanceof PsiJavaFile ? ((PsiJavaFile)f).getModuleDeclaration() : null)
|
||||
.ifPresent(m -> visit(m, relations, publicEdges));
|
||||
.ifPresent(m -> visit(m, relations, transitiveEdges));
|
||||
}
|
||||
|
||||
Graph<PsiJavaModule> graph = GraphGenerator.generate(new ChameleonGraph<>(relations, true));
|
||||
return new RequiresGraph(graph, publicEdges);
|
||||
return new RequiresGraph(graph, transitiveEdges);
|
||||
}
|
||||
|
||||
private static void visit(PsiJavaModule module, MultiMap<PsiJavaModule, PsiJavaModule> relations, Set<String> publicEdges) {
|
||||
private static void visit(PsiJavaModule module, MultiMap<PsiJavaModule, PsiJavaModule> relations, Set<String> transitiveEdges) {
|
||||
if (!relations.containsKey(module)) {
|
||||
relations.putValues(module, Collections.emptyList());
|
||||
for (PsiRequiresStatement statement : module.getRequires()) {
|
||||
for (PsiJavaModule dependency : PsiJavaModuleReference.multiResolve(statement, statement.getModuleName(), false)) {
|
||||
relations.putValue(module, dependency);
|
||||
if (statement.isPublic()) publicEdges.add(RequiresGraph.key(dependency, module));
|
||||
visit(dependency, relations, publicEdges);
|
||||
if (statement.hasModifierProperty(PsiModifier.TRANSITIVE)) transitiveEdges.add(RequiresGraph.key(dependency, module));
|
||||
visit(dependency, relations, transitiveEdges);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,11 +156,11 @@ public class JavaModuleGraphUtil {
|
||||
|
||||
private static class RequiresGraph {
|
||||
private final OutboundSemiGraph<PsiJavaModule> myGraph;
|
||||
private final Set<String> myPublicEdges;
|
||||
private final Set<String> myTransitiveEdges;
|
||||
|
||||
public RequiresGraph(OutboundSemiGraph<PsiJavaModule> graph, Set<String> publicEdges) {
|
||||
public RequiresGraph(OutboundSemiGraph<PsiJavaModule> graph, Set<String> transitiveEdges) {
|
||||
myGraph = graph;
|
||||
myPublicEdges = publicEdges;
|
||||
myTransitiveEdges = transitiveEdges;
|
||||
}
|
||||
|
||||
public boolean reads(PsiJavaModule source, PsiJavaModule destination) {
|
||||
@@ -169,7 +169,7 @@ public class JavaModuleGraphUtil {
|
||||
Iterator<PsiJavaModule> directReaders = myGraph.getOut(destination);
|
||||
while (directReaders.hasNext()) {
|
||||
PsiJavaModule next = directReaders.next();
|
||||
if (source.equals(next) || myPublicEdges.contains(key(destination, next)) && reads(source, next)) {
|
||||
if (source.equals(next) || myTransitiveEdges.contains(key(destination, next)) && reads(source, next)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+53
-28
@@ -48,7 +48,6 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.intellij.openapi.util.Pair.pair;
|
||||
import static com.intellij.psi.PsiJavaModule.MODULE_INFO_FILE;
|
||||
|
||||
public class ModuleHighlightUtil {
|
||||
@@ -131,23 +130,26 @@ public class ModuleHighlightUtil {
|
||||
checkDuplicateRefs(
|
||||
module.getRequires(),
|
||||
st -> Optional.ofNullable(st.getReferenceElement()).map(PsiJavaModuleReferenceElement::getReferenceText),
|
||||
"module.duplicate.requires", results);
|
||||
"module.duplicate.requires",
|
||||
results);
|
||||
|
||||
checkDuplicateRefs(
|
||||
module.getExports(),
|
||||
st -> Optional.ofNullable(st.getPackageReference()).map(ModuleHighlightUtil::refText),
|
||||
"module.duplicate.export", results);
|
||||
"module.duplicate.export",
|
||||
results);
|
||||
|
||||
checkDuplicateRefs(
|
||||
module.getUses(),
|
||||
st -> Optional.ofNullable(st.getClassReference()).map(ModuleHighlightUtil::refText),
|
||||
"module.duplicate.uses", results);
|
||||
"module.duplicate.uses",
|
||||
results);
|
||||
|
||||
checkDuplicateRefs(
|
||||
module.getProvides(),
|
||||
st -> Optional.of(pair(st.getInterfaceReference(), st.getImplementationReference()))
|
||||
.map(p -> p.first != null && p.second != null ? refText(p.first) + " / " + refText(p.second) : null),
|
||||
"module.duplicate.provides", results);
|
||||
st -> Optional.ofNullable(st.getInterfaceReference()).map(ModuleHighlightUtil::refText),
|
||||
"module.duplicate.provides",
|
||||
results);
|
||||
|
||||
return results;
|
||||
}
|
||||
@@ -290,7 +292,11 @@ public class ModuleHighlightUtil {
|
||||
static HighlightInfo checkServiceReference(@Nullable PsiJavaCodeReferenceElement refElement) {
|
||||
if (refElement != null) {
|
||||
PsiElement target = refElement.resolve();
|
||||
if (target instanceof PsiClass && ((PsiClass)target).isEnum()) {
|
||||
if (target == null) {
|
||||
String message = JavaErrorMessages.message("cannot.resolve.symbol", refElement.getReferenceName());
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(refElement)).description(message).create();
|
||||
}
|
||||
else if (target instanceof PsiClass && ((PsiClass)target).isEnum()) {
|
||||
String message = JavaErrorMessages.message("module.service.enum", ((PsiClass)target).getName());
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(refElement)).description(message).create();
|
||||
}
|
||||
@@ -300,37 +306,56 @@ public class ModuleHighlightUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkServiceImplementation(@Nullable PsiJavaCodeReferenceElement implRef,
|
||||
@Nullable PsiJavaCodeReferenceElement intRef) {
|
||||
if (implRef != null && intRef != null) {
|
||||
PsiElement implTarget = implRef.resolve(), intTarget = intRef.resolve();
|
||||
if (implTarget instanceof PsiClass && intTarget instanceof PsiClass) {
|
||||
static List<HighlightInfo> checkServiceImplementations(@NotNull PsiProvidesStatement statement) {
|
||||
PsiReferenceList implRefList = statement.getImplementationList();
|
||||
if (implRefList == null) return null;
|
||||
|
||||
List<HighlightInfo> results = ContainerUtil.newSmartList();
|
||||
PsiJavaCodeReferenceElement intRef = statement.getInterfaceReference();
|
||||
PsiElement intTarget = intRef != null ? intRef.resolve() : null;
|
||||
|
||||
Set<String> filter = ContainerUtil.newTroveSet();
|
||||
for (PsiJavaCodeReferenceElement implRef : implRefList.getReferenceElements()) {
|
||||
String refText = refText(implRef);
|
||||
if (!filter.add(refText)) {
|
||||
String message = JavaErrorMessages.message("module.duplicate.impl", refText);
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(implRef).description(message).create();
|
||||
QuickFixAction.registerQuickFixAction(info, new DeleteElementFix(implRef));
|
||||
results.add(info);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(intTarget instanceof PsiClass)) continue;
|
||||
|
||||
PsiElement implTarget = implRef.resolve();
|
||||
if (implTarget instanceof PsiClass) {
|
||||
PsiClass implClass = (PsiClass)implTarget;
|
||||
if (!InheritanceUtil.isInheritorOrSelf(implClass, (PsiClass)intTarget, true)) {
|
||||
String message = JavaErrorMessages.message("module.service.subtype");
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).description(message).create();
|
||||
results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).description(message).create());
|
||||
}
|
||||
if (implClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
else if (implClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
String message = JavaErrorMessages.message("module.service.abstract", implClass.getName());
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).description(message).create();
|
||||
results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).description(message).create());
|
||||
}
|
||||
|
||||
PsiMethod[] constructors = implClass.getConstructors();
|
||||
if (constructors.length > 0) {
|
||||
PsiMethod constructor = JBIterable.of(constructors).find(c -> c.getParameterList().getParametersCount() == 0);
|
||||
if (constructor == null) {
|
||||
String message = JavaErrorMessages.message("module.service.no.ctor", implClass.getName());
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).description(message).create();
|
||||
}
|
||||
if (!constructor.hasModifierProperty(PsiModifier.PUBLIC)) {
|
||||
String message = JavaErrorMessages.message("module.service.hidden.ctor", implClass.getName());
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).description(message).create();
|
||||
else {
|
||||
PsiMethod[] constructors = implClass.getConstructors();
|
||||
if (constructors.length > 0) {
|
||||
PsiMethod constructor = JBIterable.of(constructors).find(c -> c.getParameterList().getParametersCount() == 0);
|
||||
if (constructor == null) {
|
||||
String message = JavaErrorMessages.message("module.service.no.ctor", implClass.getName());
|
||||
results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).description(message).create());
|
||||
}
|
||||
else if (!constructor.hasModifierProperty(PsiModifier.PUBLIC)) {
|
||||
String message = JavaErrorMessages.message("module.service.hidden.ctor", implClass.getName());
|
||||
results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).description(message).create());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return results;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@ public class Java9RedundantRequiresStatementInspection extends GlobalJavaBatchIn
|
||||
|
||||
List<PsiJavaModule> transitiveModules = StreamEx
|
||||
.of(dependencyModule.getRequires().iterator())
|
||||
.filter(PsiRequiresStatement::isPublic)
|
||||
.filter(statement -> statement.hasModifierProperty(PsiModifier.TRANSITIVE))
|
||||
.filter(requiresStatement -> !directDependencies.contains(requiresStatement.getModuleName()))
|
||||
.map(Java9RedundantRequiresStatementInspection::resolveRequiredModule)
|
||||
.nonNull()
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class RefJavaModuleImpl extends RefElementImpl implements RefJavaModule {
|
||||
PsiJavaModule requiredModule = (PsiJavaModule)element;
|
||||
Map<String, List<String>> packagesExportedByModule = getPackagesExportedByModule(requiredModule);
|
||||
if (myRequiredModules == null) myRequiredModules = new ArrayList<>(1);
|
||||
myRequiredModules.add(new RequiredModule(requiredModule.getName(), packagesExportedByModule, statement.isPublic()));
|
||||
myRequiredModules.add(new RequiredModule(requiredModule.getName(), packagesExportedByModule, statement.hasModifierProperty(PsiModifier.TRANSITIVE)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class JavaModuleCompletion {
|
||||
addModuleReferences(context, result);
|
||||
}
|
||||
else if (context instanceof PsiJavaCodeReferenceElement) {
|
||||
addCodeReferences(context, result, resultSet);
|
||||
addClassOrPackageReferences(context, result, resultSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,30 +106,33 @@ class JavaModuleCompletion {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addCodeReferences(PsiElement context, Consumer<LookupElement> result, CompletionResultSet resultSet) {
|
||||
PsiElement statement = context.getParent();
|
||||
if (statement instanceof PsiPackageAccessibilityStatement) {
|
||||
private static void addClassOrPackageReferences(PsiElement context, Consumer<LookupElement> result, CompletionResultSet resultSet) {
|
||||
PsiElement refOwner = context.getParent();
|
||||
if (refOwner instanceof PsiPackageAccessibilityStatement) {
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(context);
|
||||
PsiPackage topPackage = JavaPsiFacade.getInstance(context.getProject()).findPackage("");
|
||||
if (module != null && topPackage != null) {
|
||||
processPackage(topPackage, module.getModuleScope(false), result);
|
||||
}
|
||||
}
|
||||
else if (statement instanceof PsiUsesStatement) {
|
||||
else if (refOwner instanceof PsiUsesStatement) {
|
||||
processClasses(context.getProject(), null, resultSet, SERVICE_FILTER, TailType.SEMICOLON);
|
||||
}
|
||||
else if (statement instanceof PsiProvidesStatement) {
|
||||
PsiJavaCodeReferenceElement intRef = ((PsiProvidesStatement)statement).getInterfaceReference();
|
||||
if (context == intRef) {
|
||||
processClasses(context.getProject(), null, resultSet, SERVICE_FILTER, TailType.HUMBLE_SPACE_BEFORE_WORD);
|
||||
}
|
||||
else if (context == ((PsiProvidesStatement)statement).getImplementationReference() && intRef != null) {
|
||||
PsiElement service = intRef.resolve();
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(context);
|
||||
if (service instanceof PsiClass && module != null) {
|
||||
Predicate<PsiClass> filter = psiClass -> !psiClass.hasModifierProperty(PsiModifier.ABSTRACT) &&
|
||||
InheritanceUtil.isInheritorOrSelf(psiClass, (PsiClass)service, true);
|
||||
processClasses(context.getProject(), module.getModuleScope(false), resultSet, filter, TailType.SEMICOLON);
|
||||
else if (refOwner instanceof PsiProvidesStatement) {
|
||||
processClasses(context.getProject(), null, resultSet, SERVICE_FILTER, TailType.HUMBLE_SPACE_BEFORE_WORD);
|
||||
}
|
||||
else if (refOwner instanceof PsiReferenceList) {
|
||||
PsiElement statement = refOwner.getParent();
|
||||
if (statement instanceof PsiProvidesStatement) {
|
||||
PsiJavaCodeReferenceElement intRef = ((PsiProvidesStatement)statement).getInterfaceReference();
|
||||
if (intRef != null) {
|
||||
PsiElement service = intRef.resolve();
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(context);
|
||||
if (service instanceof PsiClass && module != null) {
|
||||
Predicate<PsiClass> filter = psiClass -> !psiClass.hasModifierProperty(PsiModifier.ABSTRACT) &&
|
||||
InheritanceUtil.isInheritorOrSelf(psiClass, (PsiClass)service, true);
|
||||
processClasses(context.getProject(), module.getModuleScope(false), resultSet, filter, TailType.SEMICOLON);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -23,6 +23,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @since 2016.3
|
||||
*/
|
||||
public interface PsiProvidesStatement extends PsiElement {
|
||||
PsiProvidesStatement[] EMPTY_ARRAY = new PsiProvidesStatement[0];
|
||||
|
||||
@Nullable PsiJavaCodeReferenceElement getInterfaceReference();
|
||||
@Nullable PsiJavaCodeReferenceElement getImplementationReference();
|
||||
@Nullable PsiReferenceList getImplementationList();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -18,28 +18,24 @@ package com.intellij.psi;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a list of Java classes referenced by the {@code implements},
|
||||
* {@code extends} or {@code throws} clause.
|
||||
* Represents a list of Java classes referenced by the {@code implements}, {@code extends}, {@code throws}, or {@code with} clause.
|
||||
*
|
||||
* @see PsiClass#getExtendsList()
|
||||
* @see PsiClass#getImplementsList()
|
||||
* @see PsiMethod#getThrowsList()
|
||||
* @see PsiProvidesStatement#getImplementationList()
|
||||
*/
|
||||
public interface PsiReferenceList extends PsiElement {
|
||||
PsiReferenceList[] EMPTY_ARRAY = new PsiReferenceList[0];
|
||||
|
||||
/**
|
||||
* Returns the array of reference elements contained in the list.
|
||||
*
|
||||
* @return the array of reference elements.
|
||||
*/
|
||||
@NotNull
|
||||
PsiJavaCodeReferenceElement[] getReferenceElements();
|
||||
|
||||
/**
|
||||
* Returns the array of classes referenced by elements in the list.
|
||||
*
|
||||
* @return the array of referenced classes.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClassType[] getReferencedTypes();
|
||||
@@ -50,6 +46,7 @@ public interface PsiReferenceList extends PsiElement {
|
||||
THROWS_LIST,
|
||||
EXTENDS_LIST,
|
||||
IMPLEMENTS_LIST,
|
||||
EXTENDS_BOUNDS_LIST
|
||||
EXTENDS_BOUNDS_LIST,
|
||||
PROVIDES_WITH_LIST
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,4 @@ public interface PsiRequiresStatement extends PsiModifierListOwner {
|
||||
|
||||
@Nullable PsiJavaModuleReferenceElement getReferenceElement();
|
||||
@Nullable String getModuleName();
|
||||
|
||||
boolean isPublic();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @since 2016.3
|
||||
*/
|
||||
public interface PsiUsesStatement extends PsiElement {
|
||||
@Nullable
|
||||
PsiJavaCodeReferenceElement getClassReference();
|
||||
PsiUsesStatement[] EMPTY_ARRAY = new PsiUsesStatement[0];
|
||||
|
||||
@Nullable PsiJavaCodeReferenceElement getClassReference();
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiKeyword;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -50,48 +49,50 @@ public class FileParser {
|
||||
@NotNull TokenSet importListStoppers,
|
||||
@NotNull AbstractBundle bundle,
|
||||
@NotNull String errorMessageKey) {
|
||||
if (PsiKeyword.MODULE.equals(builder.getTokenText())) {
|
||||
ModuleParser.parseModule(builder);
|
||||
return;
|
||||
}
|
||||
|
||||
parsePackageStatement(builder);
|
||||
|
||||
Pair<PsiBuilder.Marker, Boolean> impListInfo = parseImportList(builder, importListStoppers);
|
||||
|
||||
Pair<PsiBuilder.Marker, Boolean> impListInfo = parseImportList(builder, importListStoppers); // (importList, isEmpty)
|
||||
Boolean firstDeclarationOk = null;
|
||||
PsiBuilder.Marker firstDeclaration = null;
|
||||
PsiBuilder.Marker invalidElements = null;
|
||||
while (!builder.eof()) {
|
||||
if (builder.getTokenType() == JavaTokenType.SEMICOLON) {
|
||||
builder.advanceLexer();
|
||||
continue;
|
||||
}
|
||||
|
||||
final PsiBuilder.Marker declaration = parseInitial(builder);
|
||||
if (declaration != null) {
|
||||
if (invalidElements != null) {
|
||||
invalidElements.errorBefore(error(bundle, errorMessageKey), declaration);
|
||||
invalidElements = null;
|
||||
}
|
||||
if (firstDeclarationOk == null) {
|
||||
firstDeclarationOk = exprType(declaration) != JavaElementType.MODIFIER_LIST;
|
||||
if (firstDeclarationOk) {
|
||||
firstDeclaration = declaration;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (invalidElements == null) {
|
||||
invalidElements = builder.mark();
|
||||
}
|
||||
builder.advanceLexer();
|
||||
if (firstDeclarationOk == null) firstDeclarationOk = false;
|
||||
PsiBuilder.Marker module = myParser.getModuleParser().parse(builder);
|
||||
if (module != null) {
|
||||
firstDeclarationOk = true;
|
||||
firstDeclaration = module;
|
||||
}
|
||||
else {
|
||||
PsiBuilder.Marker invalidElements = null;
|
||||
while (!builder.eof()) {
|
||||
if (builder.getTokenType() == JavaTokenType.SEMICOLON) {
|
||||
builder.advanceLexer();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (invalidElements != null) {
|
||||
invalidElements.error(error(bundle, errorMessageKey));
|
||||
final PsiBuilder.Marker declaration = parseInitial(builder);
|
||||
if (declaration != null) {
|
||||
if (invalidElements != null) {
|
||||
invalidElements.errorBefore(error(bundle, errorMessageKey), declaration);
|
||||
invalidElements = null;
|
||||
}
|
||||
if (firstDeclarationOk == null) {
|
||||
firstDeclarationOk = exprType(declaration) != JavaElementType.MODIFIER_LIST;
|
||||
if (firstDeclarationOk) {
|
||||
firstDeclaration = declaration;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (invalidElements == null) {
|
||||
invalidElements = builder.mark();
|
||||
}
|
||||
builder.advanceLexer();
|
||||
if (firstDeclarationOk == null) firstDeclarationOk = false;
|
||||
}
|
||||
|
||||
if (invalidElements != null) {
|
||||
invalidElements.error(error(bundle, errorMessageKey));
|
||||
}
|
||||
}
|
||||
|
||||
if (impListInfo.second && firstDeclarationOk == Boolean.TRUE) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -21,6 +21,7 @@ public class JavaParser {
|
||||
public static final JavaParser INSTANCE = new JavaParser();
|
||||
|
||||
private final FileParser myFileParser;
|
||||
private final ModuleParser myModuleParser;
|
||||
private final DeclarationParser myDeclarationParser;
|
||||
private final StatementParser myStatementParser;
|
||||
private final ExpressionParser myExpressionParser;
|
||||
@@ -28,6 +29,7 @@ public class JavaParser {
|
||||
|
||||
public JavaParser() {
|
||||
myFileParser = new FileParser(this);
|
||||
myModuleParser = new ModuleParser(this);
|
||||
myDeclarationParser = new DeclarationParser(this);
|
||||
myStatementParser = new StatementParser(this);
|
||||
myExpressionParser = new ExpressionParser(this);
|
||||
@@ -39,6 +41,11 @@ public class JavaParser {
|
||||
return myFileParser;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ModuleParser getModuleParser() {
|
||||
return myModuleParser;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DeclarationParser getDeclarationParser() {
|
||||
return myDeclarationParser;
|
||||
@@ -58,4 +65,4 @@ public class JavaParser {
|
||||
public ReferenceParser getReferenceParser() {
|
||||
return myReferenceParser;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -19,10 +19,12 @@ import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiKeyword;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -34,9 +36,40 @@ public class ModuleParser {
|
||||
private static final Set<String> STATEMENT_KEYWORDS =
|
||||
ContainerUtil.newHashSet(PsiKeyword.REQUIRES, PsiKeyword.EXPORTS, PsiKeyword.USES, PsiKeyword.PROVIDES);
|
||||
|
||||
public static void parseModule(@NotNull PsiBuilder builder) {
|
||||
private final JavaParser myParser;
|
||||
|
||||
public ModuleParser(@NotNull JavaParser parser) {
|
||||
myParser = parser;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiBuilder.Marker parse(@NotNull PsiBuilder builder) {
|
||||
PsiBuilder.Marker module = builder.mark();
|
||||
mapAndAdvance(builder, JavaTokenType.MODULE_KEYWORD);
|
||||
|
||||
PsiBuilder.Marker firstAnnotation = myParser.getDeclarationParser().parseAnnotations(builder);
|
||||
|
||||
IElementType type = builder.getTokenType();
|
||||
String text = builder.getTokenText();
|
||||
if (type != JavaTokenType.IDENTIFIER || !(PsiKeyword.OPEN.equals(text) || PsiKeyword.MODULE.equals(text))) {
|
||||
module.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiBuilder.Marker modifierList = firstAnnotation != null ? firstAnnotation.precede() : builder.mark();
|
||||
if (PsiKeyword.OPEN.equals(text)) {
|
||||
mapAndAdvance(builder, JavaTokenType.OPEN_KEYWORD);
|
||||
text = builder.getTokenText();
|
||||
}
|
||||
JavaParserUtil.done(modifierList, JavaElementType.MODIFIER_LIST);
|
||||
|
||||
if (PsiKeyword.MODULE.equals(text)) {
|
||||
mapAndAdvance(builder, JavaTokenType.MODULE_KEYWORD);
|
||||
}
|
||||
else {
|
||||
module.drop();
|
||||
parseExtras(builder, JavaErrorMessages.message("expected.module.declaration"));
|
||||
return module;
|
||||
}
|
||||
|
||||
if (parseName(builder) == null) {
|
||||
module.drop();
|
||||
@@ -46,7 +79,7 @@ public class ModuleParser {
|
||||
else {
|
||||
error(builder, JavaErrorMessages.message("expected.identifier"));
|
||||
}
|
||||
return;
|
||||
return module;
|
||||
}
|
||||
|
||||
if (!expect(builder, JavaTokenType.LBRACE)) {
|
||||
@@ -66,6 +99,8 @@ public class ModuleParser {
|
||||
if (builder.getTokenType() != null) {
|
||||
parseExtras(builder, JavaErrorMessages.message("unexpected.tokens"));
|
||||
}
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
private static PsiBuilder.Marker parseName(PsiBuilder builder) {
|
||||
@@ -99,7 +134,7 @@ public class ModuleParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseModuleContent(PsiBuilder builder) {
|
||||
private void parseModuleContent(PsiBuilder builder) {
|
||||
IElementType token;
|
||||
PsiBuilder.Marker invalid = null;
|
||||
|
||||
@@ -137,10 +172,11 @@ public class ModuleParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static PsiBuilder.Marker parseStatement(PsiBuilder builder) {
|
||||
private PsiBuilder.Marker parseStatement(PsiBuilder builder) {
|
||||
String kw = builder.getTokenText();
|
||||
if (PsiKeyword.REQUIRES.equals(kw)) return parseRequiresStatement(builder);
|
||||
if (PsiKeyword.EXPORTS.equals(kw)) return parseExportsStatement(builder);
|
||||
if (PsiKeyword.OPENS.equals(kw)) return parseOpensStatement(builder);
|
||||
if (PsiKeyword.USES.equals(kw)) return parseUsesStatement(builder);
|
||||
if (PsiKeyword.PROVIDES.equals(kw)) return parseProvidesStatement(builder);
|
||||
return null;
|
||||
@@ -150,7 +186,16 @@ public class ModuleParser {
|
||||
PsiBuilder.Marker statement = builder.mark();
|
||||
mapAndAdvance(builder, JavaTokenType.REQUIRES_KEYWORD);
|
||||
|
||||
expect(builder, JavaTokenType.PUBLIC_KEYWORD);
|
||||
PsiBuilder.Marker modifierList = builder.mark();
|
||||
while (true) {
|
||||
if (expect(builder, ElementType.MODIFIER_BIT_SET)) continue;
|
||||
if (builder.getTokenType() == JavaTokenType.IDENTIFIER && PsiKeyword.TRANSITIVE.equals(builder.getTokenText())) {
|
||||
mapAndAdvance(builder, JavaTokenType.TRANSITIVE_KEYWORD);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
JavaParserUtil.done(modifierList, JavaElementType.MODIFIER_LIST);
|
||||
|
||||
if (parseNameRef(builder) != null) {
|
||||
semicolon(builder);
|
||||
@@ -163,10 +208,21 @@ public class ModuleParser {
|
||||
return statement;
|
||||
}
|
||||
|
||||
private static PsiBuilder.Marker parseExportsStatement(PsiBuilder builder) {
|
||||
private PsiBuilder.Marker parseExportsStatement(PsiBuilder builder) {
|
||||
PsiBuilder.Marker statement = builder.mark();
|
||||
boolean hasError = false;
|
||||
mapAndAdvance(builder, JavaTokenType.EXPORTS_KEYWORD);
|
||||
return parsePackageStatement(builder, statement, JavaElementType.EXPORTS_STATEMENT);
|
||||
}
|
||||
|
||||
private PsiBuilder.Marker parseOpensStatement(PsiBuilder builder) {
|
||||
PsiBuilder.Marker statement = builder.mark();
|
||||
mapAndAdvance(builder, JavaTokenType.OPENS_KEYWORD);
|
||||
return parsePackageStatement(builder, statement, JavaElementType.OPENS_STATEMENT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PsiBuilder.Marker parsePackageStatement(PsiBuilder builder, PsiBuilder.Marker statement, IElementType type) {
|
||||
boolean hasError = false;
|
||||
|
||||
if (parseClassOrPackageRef(builder) != null) {
|
||||
if (PsiKeyword.TO.equals(builder.getTokenText())) {
|
||||
@@ -193,11 +249,11 @@ public class ModuleParser {
|
||||
expect(builder, JavaTokenType.SEMICOLON);
|
||||
}
|
||||
|
||||
statement.done(JavaElementType.EXPORTS_STATEMENT);
|
||||
statement.done(type);
|
||||
return statement;
|
||||
}
|
||||
|
||||
private static PsiBuilder.Marker parseUsesStatement(PsiBuilder builder) {
|
||||
private PsiBuilder.Marker parseUsesStatement(PsiBuilder builder) {
|
||||
PsiBuilder.Marker statement = builder.mark();
|
||||
mapAndAdvance(builder, JavaTokenType.USES_KEYWORD);
|
||||
|
||||
@@ -213,7 +269,7 @@ public class ModuleParser {
|
||||
return statement;
|
||||
}
|
||||
|
||||
private static PsiBuilder.Marker parseProvidesStatement(PsiBuilder builder) {
|
||||
private PsiBuilder.Marker parseProvidesStatement(PsiBuilder builder) {
|
||||
PsiBuilder.Marker statement = builder.mark();
|
||||
boolean hasError = false;
|
||||
mapAndAdvance(builder, JavaTokenType.PROVIDES_KEYWORD);
|
||||
@@ -224,11 +280,8 @@ public class ModuleParser {
|
||||
}
|
||||
|
||||
if (PsiKeyword.WITH.equals(builder.getTokenText())) {
|
||||
mapAndAdvance(builder, JavaTokenType.WITH_KEYWORD);
|
||||
if (parseClassOrPackageRef(builder) == null) {
|
||||
error(builder, JavaErrorMessages.message("expected.class.reference"));
|
||||
hasError = true;
|
||||
}
|
||||
builder.remapCurrentToken(JavaTokenType.WITH_KEYWORD);
|
||||
hasError = myParser.getReferenceParser().parseReferenceList(builder, JavaTokenType.WITH_KEYWORD, JavaElementType.PROVIDES_WITH_LIST, JavaTokenType.COMMA);
|
||||
}
|
||||
else if (!hasError) {
|
||||
IElementType next = builder.getTokenType();
|
||||
@@ -273,7 +326,7 @@ public class ModuleParser {
|
||||
extras.error(message);
|
||||
}
|
||||
|
||||
private static PsiBuilder.Marker parseClassOrPackageRef(PsiBuilder builder) {
|
||||
return JavaParser.INSTANCE.getReferenceParser().parseJavaCodeReference(builder, true, false, false, false);
|
||||
private PsiBuilder.Marker parseClassOrPackageRef(PsiBuilder builder) {
|
||||
return myParser.getReferenceParser().parseJavaCodeReference(builder, true, false, false, false);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -377,15 +377,17 @@ public class ReferenceParser {
|
||||
return param;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiBuilder.Marker parseReferenceList(PsiBuilder builder, IElementType start, @Nullable IElementType type, IElementType delimiter) {
|
||||
final PsiBuilder.Marker element = builder.mark();
|
||||
public boolean parseReferenceList(PsiBuilder builder, IElementType start, @Nullable IElementType type, IElementType delimiter) {
|
||||
PsiBuilder.Marker element = builder.mark();
|
||||
|
||||
boolean endsWithError = false;
|
||||
if (expect(builder, start)) {
|
||||
while (true) {
|
||||
final PsiBuilder.Marker classReference = parseJavaCodeReference(builder, true, true, false, false);
|
||||
endsWithError = false;
|
||||
PsiBuilder.Marker classReference = parseJavaCodeReference(builder, true, true, false, false);
|
||||
if (classReference == null) {
|
||||
error(builder, JavaErrorMessages.message("expected.identifier"));
|
||||
endsWithError = true;
|
||||
}
|
||||
if (!expect(builder, delimiter)) {
|
||||
break;
|
||||
@@ -399,7 +401,7 @@ public class ReferenceParser {
|
||||
else {
|
||||
element.error(JavaErrorMessages.message("bound.not.expected"));
|
||||
}
|
||||
return element;
|
||||
return endsWithError;
|
||||
}
|
||||
|
||||
private static boolean isKeywordAny(PsiBuilder builder) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -147,7 +147,7 @@ public class PsiJavaParserFacadeImpl implements PsiJavaParserFacade {
|
||||
private static final JavaParserUtil.ParserWrapper MODULE = new JavaParserUtil.ParserWrapper() {
|
||||
@Override
|
||||
public void parse(final PsiBuilder builder) {
|
||||
ModuleParser.parseModule(builder);
|
||||
JavaParser.INSTANCE.getModuleParser().parse(builder);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -38,7 +38,7 @@ import static com.intellij.psi.compiled.ClassFileDecompilers.Full;
|
||||
public class ClassFileStubBuilder implements BinaryFileStubBuilder {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClassFileStubBuilder");
|
||||
|
||||
public static final int STUB_VERSION = 18;
|
||||
public static final int STUB_VERSION = 19;
|
||||
|
||||
@Override
|
||||
public boolean acceptsFile(@NotNull VirtualFile file) {
|
||||
|
||||
@@ -645,18 +645,17 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
ClassReader reader = new ClassReader(bytes);
|
||||
String className = file.getNameWithoutExtension();
|
||||
String internalName = reader.getClassName();
|
||||
boolean module = internalName.endsWith("/module-info") && BitUtil.isSet(reader.getAccess(), Opcodes.ACC_MODULE);
|
||||
String packageName = getPackageName(internalName);
|
||||
boolean module = internalName.equals("module-info") && BitUtil.isSet(reader.getAccess(), Opcodes.ACC_MODULE);
|
||||
LanguageLevel level = ClsParsingUtil.getLanguageLevelByVersion(reader.readShort(6));
|
||||
|
||||
if (module) {
|
||||
PsiJavaFileStub stub = new PsiJavaFileStubImpl(null, "", level, true);
|
||||
ModuleStubBuildingVisitor visitor = new ModuleStubBuildingVisitor(stub, packageName);
|
||||
ModuleStubBuildingVisitor visitor = new ModuleStubBuildingVisitor(stub);
|
||||
reader.accept(visitor, EMPTY_ATTRIBUTES, ClassReader.SKIP_FRAMES);
|
||||
if (visitor.getResult() != null) return stub;
|
||||
}
|
||||
else {
|
||||
PsiJavaFileStub stub = new PsiJavaFileStubImpl(null, packageName, level, true);
|
||||
PsiJavaFileStub stub = new PsiJavaFileStubImpl(null, getPackageName(internalName), level, true);
|
||||
try {
|
||||
FileContentPair source = new FileContentPair(file, bytes);
|
||||
StubBuildingVisitor<FileContentPair> visitor = new StubBuildingVisitor<FileContentPair>(source, STRATEGY, stub, 0, className);
|
||||
|
||||
@@ -31,13 +31,12 @@ import com.intellij.util.containers.JBIterable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.util.containers.ContainerUtil.newArrayList;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ClsJavaModuleImpl extends ClsRepositoryPsiElement<PsiJavaModuleStub> implements PsiJavaModule {
|
||||
private PsiJavaModuleReferenceElement myReference;
|
||||
private final PsiJavaModuleReferenceElement myReference;
|
||||
|
||||
public ClsJavaModuleImpl(PsiJavaModuleStub stub) {
|
||||
super(stub);
|
||||
@@ -65,31 +64,37 @@ public class ClsJavaModuleImpl extends ClsRepositoryPsiElement<PsiJavaModuleStub
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterable<PsiUsesStatement> getUses() {
|
||||
return Collections.emptyList();
|
||||
return JBIterable.of(getStub().getChildrenByType(JavaElementType.USES_STATEMENT, PsiUsesStatement.EMPTY_ARRAY));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterable<PsiProvidesStatement> getProvides() {
|
||||
return Collections.emptyList();
|
||||
return JBIterable.of(getStub().getChildrenByType(JavaElementType.PROVIDES_STATEMENT, PsiProvidesStatement.EMPTY_ARRAY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
appendText(getModifierList(), indentLevel, buffer);
|
||||
buffer.append("module ").append(getName()).append(" {\n");
|
||||
|
||||
int newIndentLevel = indentLevel + getIndentSize();
|
||||
int newIndentLevel = indentLevel + getIndentSize(), start = buffer.length();
|
||||
appendChildren(getRequires(), buffer, newIndentLevel, start);
|
||||
appendChildren(getExports(), buffer, newIndentLevel, start);
|
||||
appendChildren(getOpens(), buffer, newIndentLevel, start);
|
||||
appendChildren(getUses(), buffer, newIndentLevel, start);
|
||||
appendChildren(getProvides(), buffer, newIndentLevel, start);
|
||||
|
||||
int position = buffer.length();
|
||||
for (PsiRequiresStatement statement : getRequires()) appendText(statement, newIndentLevel, buffer);
|
||||
StringUtil.repeatSymbol(buffer, ' ', indentLevel);
|
||||
buffer.append('}');
|
||||
}
|
||||
|
||||
if (buffer.length() > position) buffer.append('\n');
|
||||
position = buffer.length();
|
||||
for (PsiPackageAccessibilityStatement statement : getExports()) appendText(statement, newIndentLevel, buffer);
|
||||
|
||||
if (buffer.length() > position) buffer.append('\n');
|
||||
StringUtil.repeatSymbol(buffer, ' ', newIndentLevel);
|
||||
buffer.append("/* ... */\n}");
|
||||
private static void appendChildren(Iterable<? extends PsiElement> children, StringBuilder buffer, int indentLevel, int start) {
|
||||
List<PsiElement> statements = newArrayList(children);
|
||||
if (!statements.isEmpty()) {
|
||||
if (buffer.length() > start) buffer.append('\n');
|
||||
for (PsiElement statement : statements) appendText(statement, indentLevel, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,12 +104,17 @@ public class ClsJavaModuleImpl extends ClsRepositoryPsiElement<PsiJavaModuleStub
|
||||
PsiJavaModule mirror = SourceTreeToPsiMap.treeToPsiNotNull(element);
|
||||
|
||||
setMirror(getNameIdentifier(), mirror.getNameIdentifier());
|
||||
//setMirror(getModifierList(), mirror.getModifierList());
|
||||
setMirror(getModifierList(), mirror.getModifierList());
|
||||
|
||||
setMirrors(asList(getStub().getChildrenByType(JavaElementType.REQUIRES_STATEMENT, PsiRequiresStatement.EMPTY_ARRAY)),
|
||||
newArrayList(mirror.getRequires()));
|
||||
setMirrors(asList(getStub().getChildrenByType(JavaElementType.EXPORTS_STATEMENT, PsiPackageAccessibilityStatement.EMPTY_ARRAY)),
|
||||
newArrayList(mirror.getExports()));
|
||||
setMirrors(getRequires(), mirror.getRequires());
|
||||
setMirrors(getExports(), mirror.getExports());
|
||||
setMirrors(getOpens(), mirror.getOpens());
|
||||
setMirrors(getUses(), mirror.getUses());
|
||||
setMirrors(getProvides(), mirror.getProvides());
|
||||
}
|
||||
|
||||
private static <T extends PsiElement> void setMirrors(Iterable<T> stubs, Iterable<T> mirrors) {
|
||||
setMirrors(newArrayList(stubs), newArrayList(mirrors));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -84,7 +84,8 @@ public class ClsModifierListImpl extends ClsRepositoryPsiElement<PsiModifierList
|
||||
public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
PsiElement parent = getParent();
|
||||
PsiAnnotation[] annotations = getAnnotations();
|
||||
boolean separateAnnotations = parent instanceof PsiClass || parent instanceof PsiMethod || parent instanceof PsiField;
|
||||
boolean separateAnnotations =
|
||||
parent instanceof PsiClass || parent instanceof PsiMethod || parent instanceof PsiField || parent instanceof PsiJavaModule;
|
||||
|
||||
for (PsiAnnotation annotation : annotations) {
|
||||
appendText(annotation, indentLevel, buffer, separateAnnotations ? NEXT_LINE : " ");
|
||||
@@ -136,6 +137,12 @@ public class ClsModifierListImpl extends ClsRepositoryPsiElement<PsiModifierList
|
||||
if (hasModifierProperty(PsiModifier.DEFAULT)) {
|
||||
buffer.append(PsiModifier.DEFAULT).append(' ');
|
||||
}
|
||||
if (hasModifierProperty(PsiModifier.OPEN)) {
|
||||
buffer.append(PsiModifier.OPEN).append(' ');
|
||||
}
|
||||
if (hasModifierProperty(PsiModifier.TRANSITIVE)) {
|
||||
buffer.append(PsiModifier.TRANSITIVE).append(' ');
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-10
@@ -16,7 +16,9 @@
|
||||
package com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.openapi.util.AtomicNotNullLazyValue;
|
||||
import com.intellij.openapi.util.AtomicNullableLazyValue;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.NullableLazyValue;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiJavaModuleReferenceElement;
|
||||
@@ -27,22 +29,23 @@ import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.intellij.openapi.util.text.StringUtil.nullize;
|
||||
|
||||
public class ClsPackageAccessibilityStatementImpl extends ClsRepositoryPsiElement<PsiPackageAccessibilityStatementStub> implements PsiPackageAccessibilityStatement {
|
||||
private final NotNullLazyValue<PsiJavaCodeReferenceElement> myPackageReference;
|
||||
private final NullableLazyValue<PsiJavaCodeReferenceElement> myPackageReference;
|
||||
private final NotNullLazyValue<Iterable<PsiJavaModuleReferenceElement>> myModuleReferences;
|
||||
|
||||
public ClsPackageAccessibilityStatementImpl(PsiPackageAccessibilityStatementStub stub) {
|
||||
super(stub);
|
||||
myPackageReference = new AtomicNotNullLazyValue<PsiJavaCodeReferenceElement>() {
|
||||
@NotNull
|
||||
myPackageReference = new AtomicNullableLazyValue<PsiJavaCodeReferenceElement>() {
|
||||
@Override
|
||||
protected PsiJavaCodeReferenceElement compute() {
|
||||
return new ClsJavaCodeReferenceElementImpl(ClsPackageAccessibilityStatementImpl.this, getStub().getPackageName());
|
||||
String packageName = getPackageName();
|
||||
return packageName != null ? new ClsJavaCodeReferenceElementImpl(ClsPackageAccessibilityStatementImpl.this, packageName) : null;
|
||||
}
|
||||
};
|
||||
myModuleReferences = new AtomicNotNullLazyValue<Iterable<PsiJavaModuleReferenceElement>>() {
|
||||
@@ -70,10 +73,9 @@ public class ClsPackageAccessibilityStatementImpl extends ClsRepositoryPsiElemen
|
||||
return myPackageReference.getValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
return StringUtil.nullize(getStub().getPackageName());
|
||||
return nullize(getStub().getPackageName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -91,9 +93,8 @@ public class ClsPackageAccessibilityStatementImpl extends ClsRepositoryPsiElemen
|
||||
@Override
|
||||
public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
StringUtil.repeatSymbol(buffer, ' ', indentLevel);
|
||||
PsiPackageAccessibilityStatementStub stub = getStub();
|
||||
buffer.append(getRole().toString().toLowerCase(Locale.US)).append(' ').append(stub.getPackageName());
|
||||
List<String> targets = stub.getTargets();
|
||||
buffer.append(getRole().toString().toLowerCase(Locale.US)).append(' ').append(getPackageName());
|
||||
List<String> targets = getStub().getTargets();
|
||||
if (!targets.isEmpty()) {
|
||||
buffer.append(" to ");
|
||||
for (int i = 0; i < targets.size(); i++) {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiProvidesStatement;
|
||||
import com.intellij.psi.PsiReferenceList;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiProvidesStatementStub;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClsProvidesStatementImpl extends ClsRepositoryPsiElement<PsiProvidesStatementStub> implements PsiProvidesStatement {
|
||||
private final ClsJavaCodeReferenceElementImpl myClassReference;
|
||||
|
||||
public ClsProvidesStatementImpl(PsiProvidesStatementStub stub) {
|
||||
super(stub);
|
||||
myClassReference = new ClsJavaCodeReferenceElementImpl(this, stub.getInterface());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiJavaCodeReferenceElement getInterfaceReference() {
|
||||
return myClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiReferenceList getImplementationList() {
|
||||
StubElement<PsiReferenceList> stub = getStub().findChildStubByType(JavaStubElementTypes.PROVIDES_WITH_LIST);
|
||||
return stub != null ? stub.getPsi() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
StringUtil.repeatSymbol(buffer, ' ', indentLevel);
|
||||
buffer.append("provides ").append(myClassReference.getCanonicalText()).append(' ');
|
||||
appendText(getImplementationList(), indentLevel, buffer);
|
||||
buffer.append(";\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMirror(@NotNull TreeElement element) throws InvalidMirrorException {
|
||||
setMirrorCheckingType(element, JavaElementType.PROVIDES_STATEMENT);
|
||||
setMirror(getInterfaceReference(), SourceTreeToPsiMap.<PsiProvidesStatement>treeToPsiNotNull(element).getInterfaceReference());
|
||||
setMirrorIfPresent(getImplementationList(), SourceTreeToPsiMap.<PsiProvidesStatement>treeToPsiNotNull(element).getImplementationList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiProvidesStatement";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -74,10 +74,9 @@ public class ClsReferenceListImpl extends ClsRepositoryPsiElement<PsiClassRefere
|
||||
|
||||
@Override
|
||||
public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
final String[] names = getStub().getReferencedNames();
|
||||
String[] names = getStub().getReferencedNames();
|
||||
if (names.length != 0) {
|
||||
final Role role = getStub().getRole();
|
||||
switch (role) {
|
||||
switch (getRole()) {
|
||||
case EXTENDS_BOUNDS_LIST:
|
||||
case EXTENDS_LIST:
|
||||
buffer.append(PsiKeyword.EXTENDS).append(' ');
|
||||
@@ -88,6 +87,9 @@ public class ClsReferenceListImpl extends ClsRepositoryPsiElement<PsiClassRefere
|
||||
case THROWS_LIST:
|
||||
buffer.append(PsiKeyword.THROWS).append(' ');
|
||||
break;
|
||||
case PROVIDES_WITH_LIST:
|
||||
buffer.append(PsiKeyword.WITH).append(' ');
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (i > 0) buffer.append(", ");
|
||||
@@ -116,4 +118,4 @@ public class ClsReferenceListImpl extends ClsRepositoryPsiElement<PsiClassRefere
|
||||
public String toString() {
|
||||
return "PsiReferenceList";
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-13
@@ -28,7 +28,6 @@ import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ClsRequiresStatementImpl extends ClsRepositoryPsiElement<PsiRequiresStatementStub> implements PsiRequiresStatement {
|
||||
private final NotNullLazyValue<PsiJavaModuleReferenceElement> myModuleReference;
|
||||
@@ -44,37 +43,28 @@ public class ClsRequiresStatementImpl extends ClsRepositoryPsiElement<PsiRequire
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiJavaModuleReferenceElement getReferenceElement() {
|
||||
return myModuleReference.getValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return getStub().getModuleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPublic() {
|
||||
return getStub().isPublic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
StringUtil.repeatSymbol(buffer, ' ', indentLevel);
|
||||
PsiRequiresStatementStub stub = getStub();
|
||||
buffer.append("requires ");
|
||||
if (stub.isPublic()) buffer.append("public ");
|
||||
if (stub.isStatic()) buffer.append("static ");
|
||||
buffer.append(stub.getModuleName()).append(";\n");
|
||||
appendText(getModifierList(), indentLevel, buffer);
|
||||
buffer.append(getModuleName()).append(";\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMirror(@NotNull TreeElement element) throws InvalidMirrorException {
|
||||
setMirrorCheckingType(element, JavaElementType.REQUIRES_STATEMENT);
|
||||
//setMirror(getModifierList(), SourceTreeToPsiMap.<PsiRequiresStatement>treeToPsiNotNull(element).getModifierList());
|
||||
setMirror(getModifierList(), SourceTreeToPsiMap.<PsiRequiresStatement>treeToPsiNotNull(element).getModifierList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiUsesStatement;
|
||||
import com.intellij.psi.impl.java.stubs.PsiUsesStatementStub;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClsUsesStatementImpl extends ClsRepositoryPsiElement<PsiUsesStatementStub> implements PsiUsesStatement {
|
||||
private final ClsJavaCodeReferenceElementImpl myClassReference;
|
||||
|
||||
public ClsUsesStatementImpl(PsiUsesStatementStub stub) {
|
||||
super(stub);
|
||||
myClassReference = new ClsJavaCodeReferenceElementImpl(this, stub.getClassName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiJavaCodeReferenceElement getClassReference() {
|
||||
return myClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
StringUtil.repeatSymbol(buffer, ' ', indentLevel);
|
||||
buffer.append("uses ").append(myClassReference.getCanonicalText()).append(";\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMirror(@NotNull TreeElement element) throws InvalidMirrorException {
|
||||
setMirrorCheckingType(element, JavaElementType.USES_STATEMENT);
|
||||
setMirror(getClassReference(), SourceTreeToPsiMap.<PsiUsesStatement>treeToPsiNotNull(element).getClassReference());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiUsesStatement";
|
||||
}
|
||||
}
|
||||
+62
-18
@@ -15,32 +15,32 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.psi.impl.cache.ModifierFlags;
|
||||
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub;
|
||||
import com.intellij.psi.impl.java.stubs.PsiJavaModuleStub;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiJavaModuleStubImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiPackageAccessibilityStatementStubImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiRequiresStatementStubImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.*;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.ModuleVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.intellij.psi.impl.java.stubs.JavaStubElementTypes.EXPORTS_STATEMENT;
|
||||
import static com.intellij.psi.impl.java.stubs.JavaStubElementTypes.*;
|
||||
import static com.intellij.util.BitUtil.isSet;
|
||||
import static com.intellij.util.containers.ContainerUtil.map2Array;
|
||||
|
||||
public class ModuleStubBuildingVisitor extends ClassVisitor {
|
||||
private static final int ACC_TRANSITIVE = 0x0010;
|
||||
private static final int ACC_STATIC_PHASE = 0x0020;
|
||||
private static final Function<String, String> NAME_MAPPER = name1 -> name1.replace('/', '.');
|
||||
|
||||
private final PsiJavaFileStub myParent;
|
||||
private final String myModuleName;
|
||||
private PsiJavaModuleStub myResult;
|
||||
private PsiModifierListStubImpl myModList;
|
||||
|
||||
public ModuleStubBuildingVisitor(PsiJavaFileStub parent, String moduleName) {
|
||||
public ModuleStubBuildingVisitor(PsiJavaFileStub parent) {
|
||||
super(Opcodes.API_VERSION);
|
||||
myParent = parent;
|
||||
myModuleName = moduleName;
|
||||
}
|
||||
|
||||
public PsiJavaModuleStub getResult() {
|
||||
@@ -48,22 +48,66 @@ public class ModuleStubBuildingVisitor extends ClassVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleVisitor visitModule() {
|
||||
myResult = new PsiJavaModuleStubImpl(myParent, myModuleName);
|
||||
public ModuleVisitor visitModule(String name, int access, String version) {
|
||||
myResult = new PsiJavaModuleStubImpl(myParent, name);
|
||||
|
||||
myModList = new PsiModifierListStubImpl(myResult, moduleFlags(access));
|
||||
|
||||
return new ModuleVisitor(Opcodes.API_VERSION) {
|
||||
@Override
|
||||
public void visitRequire(String module, int access) {
|
||||
if (!isSet(access, Opcodes.ACC_SYNTHETIC) && !isSet(access, Opcodes.ACC_MANDATED)) {
|
||||
boolean isPublic = isSet(access, ACC_TRANSITIVE) | isSet(access, Opcodes.ACC_PUBLIC);
|
||||
new PsiRequiresStatementStubImpl(myResult, module, isPublic, isSet(access, ACC_STATIC_PHASE));
|
||||
public void visitRequire(String module, int access, String version) {
|
||||
if (!isGenerated(access)) {
|
||||
PsiRequiresStatementStubImpl statementStub = new PsiRequiresStatementStubImpl(myResult, module);
|
||||
new PsiModifierListStubImpl(statementStub, requiresFlags(access));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExport(String packageName, String... modules) {
|
||||
new PsiPackageAccessibilityStatementStubImpl(
|
||||
myResult, EXPORTS_STATEMENT, packageName.replace('/', '.'), modules == null ? null : Arrays.asList(modules));
|
||||
public void visitExport(String packageName, int access, String... modules) {
|
||||
if (!isGenerated(access)) {
|
||||
new PsiPackageAccessibilityStatementStubImpl(
|
||||
myResult, EXPORTS_STATEMENT, NAME_MAPPER.fun(packageName), modules == null ? null : Arrays.asList(modules));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitOpen(String packageName, int access, String... modules) {
|
||||
if (!isGenerated(access)) {
|
||||
new PsiPackageAccessibilityStatementStubImpl(
|
||||
myResult, OPENS_STATEMENT, NAME_MAPPER.fun(packageName), modules == null ? null : Arrays.asList(modules));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitUse(String service) {
|
||||
new PsiUsesStatementStubImpl(myResult, NAME_MAPPER.fun(service));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitProvide(String service, String... providers) {
|
||||
PsiProvidesStatementStubImpl statementStub = new PsiProvidesStatementStubImpl(myResult, NAME_MAPPER.fun(service));
|
||||
new PsiClassReferenceListStubImpl(PROVIDES_WITH_LIST, statementStub, map2Array(providers, String.class, NAME_MAPPER));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||
return StubBuildingVisitor.getAnnotationTextCollector(desc, text -> new PsiAnnotationStubImpl(myModList, text));
|
||||
}
|
||||
|
||||
private static boolean isGenerated(int access) {
|
||||
return isSet(access, Opcodes.ACC_SYNTHETIC) || isSet(access, Opcodes.ACC_MANDATED);
|
||||
}
|
||||
|
||||
private static int moduleFlags(int access) {
|
||||
return isSet(access, Opcodes.ACC_OPEN) ? ModifierFlags.OPEN_MASK : 0;
|
||||
}
|
||||
|
||||
private static int requiresFlags(int access) {
|
||||
int flags = 0;
|
||||
if (isSet(access, Opcodes.ACC_TRANSITIVE)) flags |= ModifierFlags.TRANSITIVE_MASK;
|
||||
if (isSet(access, Opcodes.ACC_STATIC_PHASE) || isSet(access, Opcodes.ACC_FINAL)) flags |= ModifierFlags.STATIC_MASK;
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiNameHelper;
|
||||
import com.intellij.psi.PsiReferenceList;
|
||||
import com.intellij.psi.impl.cache.ModifierFlags;
|
||||
import com.intellij.psi.impl.cache.TypeInfo;
|
||||
import com.intellij.psi.impl.java.stubs.*;
|
||||
@@ -188,9 +187,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
}
|
||||
|
||||
private static void newReferenceList(@NotNull JavaClassReferenceListElementType type, StubElement parent, @NotNull String[] types) {
|
||||
PsiReferenceList.Role role = JavaClassReferenceListElementType.elementTypeToRole(type);
|
||||
|
||||
new PsiClassReferenceListStubImpl(type, parent, types, role);
|
||||
new PsiClassReferenceListStubImpl(type, parent, types);
|
||||
}
|
||||
|
||||
private static int packCommonFlags(int access) {
|
||||
@@ -867,4 +864,8 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
return canonicalText.replace('/', '.');
|
||||
}
|
||||
};
|
||||
|
||||
public static AnnotationVisitor getAnnotationTextCollector(String desc, Consumer<String> consumer) {
|
||||
return new AnnotationTextCollector(desc, GUESSING_MAPPER, consumer);
|
||||
}
|
||||
}
|
||||
@@ -113,4 +113,14 @@ public class ClsStubPsiFactory extends StubPsiFactory {
|
||||
public PsiPackageAccessibilityStatement createPackageAccessibilityStatement(PsiPackageAccessibilityStatementStub stub) {
|
||||
return new ClsPackageAccessibilityStatementImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiUsesStatement createUsesStatement(PsiUsesStatementStub stub) {
|
||||
return new ClsUsesStatementImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiProvidesStatement createProvidesStatement(PsiProvidesStatementStub stub) {
|
||||
return new ClsProvidesStatementImpl(stub);
|
||||
}
|
||||
}
|
||||
+6
-44
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -33,7 +33,6 @@ import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -43,7 +42,7 @@ import java.util.List;
|
||||
* @author max
|
||||
*/
|
||||
public abstract class JavaClassReferenceListElementType extends JavaStubElementType<PsiClassReferenceListStub, PsiReferenceList> {
|
||||
public JavaClassReferenceListElementType(@NotNull @NonNls String id) {
|
||||
public JavaClassReferenceListElementType(@NotNull String id) {
|
||||
super(id, true);
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ public abstract class JavaClassReferenceListElementType extends JavaStubElementT
|
||||
@Override
|
||||
public PsiClassReferenceListStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
|
||||
JavaClassReferenceListElementType type = (JavaClassReferenceListElementType)node.getTokenType();
|
||||
return new PsiClassReferenceListStubImpl(type, parentStub, getTexts(tree, node), elementTypeToRole(type));
|
||||
return new PsiClassReferenceListStubImpl(type, parentStub, getTexts(tree, node));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -75,9 +74,6 @@ public abstract class JavaClassReferenceListElementType extends JavaStubElementT
|
||||
|
||||
@Override
|
||||
public void serialize(@NotNull PsiClassReferenceListStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||
byte role = encodeRole(stub.getRole());
|
||||
dataStream.writeByte(role);
|
||||
|
||||
String[] names = stub.getReferencedNames();
|
||||
dataStream.writeVarInt(names.length);
|
||||
for (String name : names) {
|
||||
@@ -88,16 +84,12 @@ public abstract class JavaClassReferenceListElementType extends JavaStubElementT
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiClassReferenceListStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
byte role = dataStream.readByte();
|
||||
|
||||
int len = dataStream.readVarInt();
|
||||
StringRef[] names = StringRef.createArray(len);
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
names[i] = dataStream.readName();
|
||||
}
|
||||
|
||||
PsiReferenceList.Role decodedRole = decodeRole(role);
|
||||
return new PsiClassReferenceListStubImpl(roleToElementType(decodedRole), parentStub, names, decodedRole);
|
||||
return new PsiClassReferenceListStubImpl(this, parentStub, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,37 +125,7 @@ public abstract class JavaClassReferenceListElementType extends JavaStubElementT
|
||||
if (type == JavaStubElementTypes.EXTENDS_LIST) return PsiReferenceList.Role.EXTENDS_LIST;
|
||||
if (type == JavaStubElementTypes.IMPLEMENTS_LIST) return PsiReferenceList.Role.IMPLEMENTS_LIST;
|
||||
if (type == JavaStubElementTypes.THROWS_LIST) return PsiReferenceList.Role.THROWS_LIST;
|
||||
if (type == JavaStubElementTypes.PROVIDES_WITH_LIST) return PsiReferenceList.Role.PROVIDES_WITH_LIST;
|
||||
throw new RuntimeException("Unknown element type: " + type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JavaClassReferenceListElementType roleToElementType(@NotNull PsiReferenceList.Role role) {
|
||||
switch (role) {
|
||||
case EXTENDS_BOUNDS_LIST: return JavaStubElementTypes.EXTENDS_BOUND_LIST;
|
||||
case EXTENDS_LIST: return JavaStubElementTypes.EXTENDS_LIST;
|
||||
case IMPLEMENTS_LIST: return JavaStubElementTypes.IMPLEMENTS_LIST;
|
||||
case THROWS_LIST: return JavaStubElementTypes.THROWS_LIST;
|
||||
}
|
||||
throw new RuntimeException("Unknown role: " + role);
|
||||
}
|
||||
|
||||
private static byte encodeRole(PsiReferenceList.Role role) {
|
||||
switch (role) {
|
||||
case EXTENDS_LIST: return 0;
|
||||
case IMPLEMENTS_LIST: return 1;
|
||||
case THROWS_LIST: return 2;
|
||||
case EXTENDS_BOUNDS_LIST: return 3;
|
||||
}
|
||||
throw new RuntimeException("Unknown role: " + role);
|
||||
}
|
||||
|
||||
private static PsiReferenceList.Role decodeRole(byte code) {
|
||||
switch (code) {
|
||||
case 0: return PsiReferenceList.Role.EXTENDS_LIST;
|
||||
case 1: return PsiReferenceList.Role.IMPLEMENTS_LIST;
|
||||
case 2: return PsiReferenceList.Role.THROWS_LIST;
|
||||
case 3: return PsiReferenceList.Role.EXTENDS_BOUNDS_LIST;
|
||||
}
|
||||
throw new RuntimeException("Unknown role code: " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -31,6 +31,7 @@ import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -73,14 +74,14 @@ public class JavaPackageAccessibilityStatementElementType extends JavaStubElemen
|
||||
|
||||
@Override
|
||||
public void serialize(@NotNull PsiPackageAccessibilityStatementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeUTFFast(stub.getPackageName());
|
||||
dataStream.writeName(stub.getPackageName());
|
||||
dataStream.writeUTFFast(StringUtil.join(stub.getTargets(), "/"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiPackageAccessibilityStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
String packageName = dataStream.readUTFFast();
|
||||
String packageName = StringRef.toString(dataStream.readName());
|
||||
List<String> targets = StringUtil.split(dataStream.readUTFFast(), "/");
|
||||
return new PsiPackageAccessibilityStatementStubImpl(parentStub, this, packageName, targets);
|
||||
}
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.psi.PsiProvidesStatement;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiProvidesStatementStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiProvidesStatementImpl;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaSourceUtil;
|
||||
import com.intellij.psi.impl.source.tree.LightTreeUtil;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class JavaProvidesStatementElementType extends JavaStubElementType<PsiProvidesStatementStub, PsiProvidesStatement> {
|
||||
public JavaProvidesStatementElementType() {
|
||||
super("PROVIDES_STATEMENT");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new CompositeElement(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiProvidesStatement createPsi(@NotNull PsiProvidesStatementStub stub) {
|
||||
return getPsiFactory(stub).createProvidesStatement(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiProvidesStatement createPsi(@NotNull ASTNode node) {
|
||||
return new PsiProvidesStatementImpl(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiProvidesStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
|
||||
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.JAVA_CODE_REFERENCE);
|
||||
String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null;
|
||||
return new PsiProvidesStatementStubImpl(parentStub, refText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NotNull PsiProvidesStatementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeName(stub.getInterface());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiProvidesStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
return new PsiProvidesStatementStubImpl(parentStub, StringRef.toString(dataStream.readName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexStub(@NotNull PsiProvidesStatementStub stub, @NotNull IndexSink sink) { }
|
||||
}
|
||||
+6
-20
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -18,25 +18,22 @@ package com.intellij.psi.impl.java.stubs;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiRequiresStatement;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiRequiresStatementStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiRequiresStatementImpl;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaSourceUtil;
|
||||
import com.intellij.psi.impl.source.tree.LightTreeUtil;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
|
||||
public class JavaRequiresStatementElementType extends JavaStubElementType<PsiRequiresStatementStub, PsiRequiresStatement> {
|
||||
public JavaRequiresStatementElementType() {
|
||||
super("REQUIRES_STATEMENT");
|
||||
@@ -60,31 +57,20 @@ public class JavaRequiresStatementElementType extends JavaStubElementType<PsiReq
|
||||
|
||||
@Override
|
||||
public PsiRequiresStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
|
||||
String refText = null;
|
||||
boolean isPublic = false, isStatic = false;
|
||||
|
||||
for (LighterASTNode child : tree.getChildren(node)) {
|
||||
IElementType type = child.getTokenType();
|
||||
if (type == JavaElementType.MODULE_REFERENCE) refText = JavaSourceUtil.getReferenceText(tree, child);
|
||||
else if (type == JavaTokenType.PUBLIC_KEYWORD) isPublic = true;
|
||||
else if (type == JavaTokenType.STATIC_KEYWORD) isStatic = true;
|
||||
}
|
||||
|
||||
return new PsiRequiresStatementStubImpl(parentStub, notNull(refText, ""), isPublic, isStatic);
|
||||
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.MODULE_REFERENCE);
|
||||
String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null;
|
||||
return new PsiRequiresStatementStubImpl(parentStub, refText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NotNull PsiRequiresStatementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeName(stub.getModuleName());
|
||||
dataStream.writeByte(stub.getFlags());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiRequiresStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
String name = StringRef.toString(dataStream.readName());
|
||||
byte flags = dataStream.readByte();
|
||||
return new PsiRequiresStatementStubImpl(parentStub, name, flags);
|
||||
return new PsiRequiresStatementStubImpl(parentStub, StringRef.toString(dataStream.readName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.impl.source.JavaFileElementType;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.java.*;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -40,6 +41,8 @@ public interface JavaStubElementTypes {
|
||||
JavaImportListElementType IMPORT_LIST = new JavaImportListElementType();
|
||||
JavaModuleElementType MODULE = new JavaModuleElementType();
|
||||
JavaRequiresStatementElementType REQUIRES_STATEMENT = new JavaRequiresStatementElementType();
|
||||
JavaUsesStatementElementType USES_STATEMENT = new JavaUsesStatementElementType();
|
||||
JavaProvidesStatementElementType PROVIDES_STATEMENT = new JavaProvidesStatementElementType();
|
||||
|
||||
JavaPackageAccessibilityStatementElementType EXPORTS_STATEMENT = new JavaPackageAccessibilityStatementElementType("EXPORTS_STATEMENT");
|
||||
JavaPackageAccessibilityStatementElementType OPENS_STATEMENT = new JavaPackageAccessibilityStatementElementType("OPENS_STATEMENT");
|
||||
@@ -124,6 +127,13 @@ public interface JavaStubElementTypes {
|
||||
return new TypeParameterExtendsBoundsListElement();
|
||||
}
|
||||
};
|
||||
JavaClassReferenceListElementType PROVIDES_WITH_LIST = new JavaClassReferenceListElementType("PROVIDES_WITH_LIST") {
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new CompositeElement(this);
|
||||
}
|
||||
};
|
||||
|
||||
JavaImportStatementElementType IMPORT_STATEMENT = new JavaImportStatementElementType("IMPORT_STATEMENT") {
|
||||
@NotNull
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.psi.PsiUsesStatement;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiUsesStatementStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiUsesStatementImpl;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaSourceUtil;
|
||||
import com.intellij.psi.impl.source.tree.LightTreeUtil;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class JavaUsesStatementElementType extends JavaStubElementType<PsiUsesStatementStub, PsiUsesStatement> {
|
||||
public JavaUsesStatementElementType() {
|
||||
super("USES_STATEMENT");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode createCompositeNode() {
|
||||
return new CompositeElement(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiUsesStatement createPsi(@NotNull PsiUsesStatementStub stub) {
|
||||
return getPsiFactory(stub).createUsesStatement(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiUsesStatement createPsi(@NotNull ASTNode node) {
|
||||
return new PsiUsesStatementImpl(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiUsesStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
|
||||
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.JAVA_CODE_REFERENCE);
|
||||
String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null;
|
||||
return new PsiUsesStatementStubImpl(parentStub, refText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NotNull PsiUsesStatementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeName(stub.getClassName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiUsesStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
return new PsiUsesStatementStubImpl(parentStub, StringRef.toString(dataStream.readName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexStub(@NotNull PsiUsesStatementStub stub, @NotNull IndexSink sink) { }
|
||||
}
|
||||
+4
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -25,10 +25,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface PsiClassReferenceListStub extends StubElement<PsiReferenceList> {
|
||||
@NotNull
|
||||
PsiClassType[] getReferencedTypes();
|
||||
@NotNull
|
||||
String[] getReferencedNames();
|
||||
@NotNull
|
||||
PsiReferenceList.Role getRole();
|
||||
@NotNull PsiClassType[] getReferencedTypes();
|
||||
@NotNull String[] getReferencedNames();
|
||||
@NotNull PsiReferenceList.Role getRole();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.psi.PsiProvidesStatement;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
|
||||
public interface PsiProvidesStatementStub extends StubElement<PsiProvidesStatement> {
|
||||
String getInterface();
|
||||
}
|
||||
+1
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -20,7 +20,4 @@ import com.intellij.psi.stubs.StubElement;
|
||||
|
||||
public interface PsiRequiresStatementStub extends StubElement<PsiRequiresStatement> {
|
||||
String getModuleName();
|
||||
byte getFlags();
|
||||
boolean isPublic();
|
||||
boolean isStatic();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.psi.impl.java.stubs;
|
||||
|
||||
import com.intellij.psi.PsiUsesStatement;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
|
||||
public interface PsiUsesStatementStub extends StubElement<PsiUsesStatement> {
|
||||
String getClassName();
|
||||
}
|
||||
@@ -27,12 +27,8 @@ public class SourceStubPsiFactory extends StubPsiFactory {
|
||||
|
||||
@Override
|
||||
public PsiClass createClass(PsiClassStub stub) {
|
||||
if (stub.isEnumConstantInitializer()) {
|
||||
return new PsiEnumConstantInitializerImpl(stub);
|
||||
}
|
||||
if (stub.isAnonymous()) {
|
||||
return new PsiAnonymousClassImpl(stub);
|
||||
}
|
||||
if (stub.isEnumConstantInitializer()) return new PsiEnumConstantInitializerImpl(stub);
|
||||
if (stub.isAnonymous()) return new PsiAnonymousClassImpl(stub);
|
||||
return new PsiClassImpl(stub);
|
||||
}
|
||||
|
||||
@@ -48,7 +44,7 @@ public class SourceStubPsiFactory extends StubPsiFactory {
|
||||
|
||||
@Override
|
||||
public PsiReferenceList createClassReferenceList(PsiClassReferenceListStub stub) {
|
||||
return new PsiReferenceListImpl(stub, stub.getStubType());
|
||||
return new PsiReferenceListImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,12 +59,7 @@ public class SourceStubPsiFactory extends StubPsiFactory {
|
||||
|
||||
@Override
|
||||
public PsiImportStatementBase createImportStatement(PsiImportStatementStub stub) {
|
||||
if (stub.isStatic()) {
|
||||
return new PsiImportStaticStatementImpl(stub);
|
||||
}
|
||||
else {
|
||||
return new PsiImportStatementImpl(stub);
|
||||
}
|
||||
return stub.isStatic()? new PsiImportStaticStatementImpl(stub) : new PsiImportStatementImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,4 +116,14 @@ public class SourceStubPsiFactory extends StubPsiFactory {
|
||||
public PsiPackageAccessibilityStatement createPackageAccessibilityStatement(PsiPackageAccessibilityStatementStub stub) {
|
||||
return new PsiPackageAccessibilityStatementImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiUsesStatement createUsesStatement(PsiUsesStatementStub stub) {
|
||||
return new PsiUsesStatementImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiProvidesStatement createProvidesStatement(PsiProvidesStatementStub stub) {
|
||||
return new PsiProvidesStatementImpl(stub);
|
||||
}
|
||||
}
|
||||
@@ -62,4 +62,12 @@ public abstract class StubPsiFactory {
|
||||
public PsiPackageAccessibilityStatement createPackageAccessibilityStatement(PsiPackageAccessibilityStatementStub stub) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PsiUsesStatement createUsesStatement(PsiUsesStatementStub stub) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PsiProvidesStatement createProvidesStatement(PsiProvidesStatementStub stub) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+10
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -32,13 +32,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author max
|
||||
*/
|
||||
public class PsiClassReferenceListStubImpl extends StubBase<PsiReferenceList> implements PsiClassReferenceListStub {
|
||||
@NotNull
|
||||
private final PsiReferenceList.Role myRole;
|
||||
private final StringRef[] myNames;
|
||||
private PsiClassType[] myTypes;
|
||||
|
||||
public PsiClassReferenceListStubImpl(@NotNull JavaClassReferenceListElementType type, final StubElement parent, @NotNull String[] names, @NotNull PsiReferenceList.Role role) {
|
||||
this(type, parent, toStringRefs(names), role);
|
||||
public PsiClassReferenceListStubImpl(@NotNull JavaClassReferenceListElementType type, StubElement parent, @NotNull String[] names) {
|
||||
this(type, parent, toStringRefs(names));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -50,16 +48,16 @@ public class PsiClassReferenceListStubImpl extends StubBase<PsiReferenceList> im
|
||||
return myNames;
|
||||
}
|
||||
|
||||
public PsiClassReferenceListStubImpl(@NotNull JavaClassReferenceListElementType type, final StubElement parent, @NotNull StringRef[] names, @NotNull PsiReferenceList.Role role) {
|
||||
public PsiClassReferenceListStubImpl(@NotNull JavaClassReferenceListElementType type, StubElement parent, @NotNull StringRef[] names) {
|
||||
super(parent, type);
|
||||
myNames = names;
|
||||
myRole = role;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiClassType[] getReferencedTypes() {
|
||||
if (myTypes != null) return myTypes;
|
||||
|
||||
if (myNames.length == 0) {
|
||||
myTypes = PsiClassType.EMPTY_ARRAY;
|
||||
return myTypes;
|
||||
@@ -117,17 +115,18 @@ public class PsiClassReferenceListStubImpl extends StubBase<PsiReferenceList> im
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiReferenceList.Role getRole() {
|
||||
return myRole;
|
||||
return JavaClassReferenceListElementType.elementTypeToRole(getStubType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("PsiRefListStub[").append(myRole.name()).append(":");
|
||||
builder.append("PsiRefListStub[").append(getRole()).append(':');
|
||||
for (int i = 0; i < myNames.length; i++) {
|
||||
if (i > 0) builder.append(", ");
|
||||
builder.append(myNames[i]);
|
||||
}
|
||||
builder.append("]");
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.psi.impl.java.stubs.impl;
|
||||
|
||||
import com.intellij.psi.PsiProvidesStatement;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiProvidesStatementStub;
|
||||
import com.intellij.psi.stubs.StubBase;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
|
||||
public class PsiProvidesStatementStubImpl extends StubBase<PsiProvidesStatement> implements PsiProvidesStatementStub {
|
||||
private final String myInterface;
|
||||
|
||||
public PsiProvidesStatementStubImpl(StubElement parent, String interfaceName) {
|
||||
super(parent, JavaStubElementTypes.PROVIDES_STATEMENT);
|
||||
myInterface = notNull(interfaceName, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInterface() {
|
||||
return myInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiProvidesStatementStub:" + myInterface;
|
||||
}
|
||||
}
|
||||
+6
-28
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -21,21 +21,14 @@ import com.intellij.psi.impl.java.stubs.PsiRequiresStatementStub;
|
||||
import com.intellij.psi.stubs.StubBase;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
|
||||
public class PsiRequiresStatementStubImpl extends StubBase<PsiRequiresStatement> implements PsiRequiresStatementStub {
|
||||
private static final byte PUBLIC = 0x01;
|
||||
private static final byte STATIC = 0x02;
|
||||
|
||||
private final String myModuleName;
|
||||
private final byte myFlags;
|
||||
|
||||
public PsiRequiresStatementStubImpl(StubElement parent, String refText, boolean isPublic, boolean isStatic) {
|
||||
this(parent, refText, (byte)((isPublic ? PUBLIC : 0) | (isStatic ? STATIC : 0)));
|
||||
}
|
||||
|
||||
public PsiRequiresStatementStubImpl(StubElement parent, String refText, byte flags) {
|
||||
public PsiRequiresStatementStubImpl(StubElement parent, String refText) {
|
||||
super(parent, JavaStubElementTypes.REQUIRES_STATEMENT);
|
||||
myModuleName = refText;
|
||||
myFlags = flags;
|
||||
myModuleName = notNull(refText, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,23 +36,8 @@ public class PsiRequiresStatementStubImpl extends StubBase<PsiRequiresStatement>
|
||||
return myModuleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getFlags() {
|
||||
return myFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPublic() {
|
||||
return (myFlags & PUBLIC) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return (myFlags & STATIC) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiRequiresStatementStub:" + myFlags + ":" + myModuleName;
|
||||
return "PsiRequiresStatementStub:" + myModuleName;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.psi.impl.java.stubs.impl;
|
||||
|
||||
import com.intellij.psi.PsiUsesStatement;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiUsesStatementStub;
|
||||
import com.intellij.psi.stubs.StubBase;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
|
||||
public class PsiUsesStatementStubImpl extends StubBase<PsiUsesStatement> implements PsiUsesStatementStub {
|
||||
private final String myClassName;
|
||||
|
||||
public PsiUsesStatementStubImpl(StubElement parent, String refText) {
|
||||
super(parent, JavaStubElementTypes.USES_STATEMENT);
|
||||
myClassName = notNull(refText, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return myClassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiUsesStatementStub:" + myClassName;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -38,7 +38,7 @@ import java.io.IOException;
|
||||
* @author max
|
||||
*/
|
||||
public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileStub> {
|
||||
public static final int STUB_VERSION = 39;
|
||||
public static final int STUB_VERSION = 40;
|
||||
|
||||
public JavaFileElementType() {
|
||||
super("java.FILE", JavaLanguage.INSTANCE);
|
||||
|
||||
+2
-2
@@ -175,8 +175,8 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
|
||||
PsiJavaCodeReferenceCodeFragment fragment = (PsiJavaCodeReferenceCodeFragment)treeParent.getPsi();
|
||||
return fragment.isClassesAccepted() ? CLASS_FQ_OR_PACKAGE_NAME_KIND : PACKAGE_NAME_KIND;
|
||||
}
|
||||
if (i == JavaElementType.USES_STATEMENT || i == JavaElementType.PROVIDES_STATEMENT) {
|
||||
return CLASS_FQ_NAME_KIND;
|
||||
if (i == JavaElementType.USES_STATEMENT || i == JavaElementType.PROVIDES_STATEMENT || i == JavaElementType.PROVIDES_WITH_LIST) {
|
||||
return CLASS_NAME_KIND;
|
||||
}
|
||||
|
||||
diagnoseUnknownParent();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -39,15 +39,7 @@ public class PsiJavaFileImpl extends PsiJavaFileBaseImpl {
|
||||
@Override
|
||||
public PsiJavaModule getModuleDeclaration() {
|
||||
PsiJavaFileStub stub = (PsiJavaFileStub)getGreenStub();
|
||||
if (stub != null) {
|
||||
return stub.getModule();
|
||||
}
|
||||
|
||||
PsiElement element = getFirstChild();
|
||||
if (element instanceof PsiWhiteSpace || element instanceof PsiComment) {
|
||||
element = PsiTreeUtil.skipSiblingsForward(element, PsiWhiteSpace.class, PsiComment.class);
|
||||
}
|
||||
return element instanceof PsiJavaModule ? (PsiJavaModule)element : null;
|
||||
return stub != null ? stub.getModule() : PsiTreeUtil.getChildOfType(this, PsiJavaModule.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.source;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProviders;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiJavaModuleStub;
|
||||
@@ -33,19 +32,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import static com.intellij.psi.SyntaxTraverser.psiTraverser;
|
||||
|
||||
public class PsiJavaModuleImpl extends JavaStubPsiElement<PsiJavaModuleStub> implements PsiJavaModule {
|
||||
private static final Condition<PsiPackageAccessibilityStatement> EXPORTS_FILTER = new Condition<PsiPackageAccessibilityStatement>() {
|
||||
@Override
|
||||
public boolean value(PsiPackageAccessibilityStatement statement) {
|
||||
return statement.getRole() == PsiPackageAccessibilityStatement.Role.EXPORTS;
|
||||
}
|
||||
};
|
||||
private static final Condition<PsiPackageAccessibilityStatement> OPENS_FILTER = new Condition<PsiPackageAccessibilityStatement>() {
|
||||
@Override
|
||||
public boolean value(PsiPackageAccessibilityStatement statement) {
|
||||
return statement.getRole() == PsiPackageAccessibilityStatement.Role.OPENS;
|
||||
}
|
||||
};
|
||||
|
||||
public PsiJavaModuleImpl(@NotNull PsiJavaModuleStub stub) {
|
||||
super(stub, JavaStubElementTypes.MODULE);
|
||||
}
|
||||
@@ -74,7 +60,9 @@ public class PsiJavaModuleImpl extends JavaStubPsiElement<PsiJavaModuleStub> imp
|
||||
return JBIterable.of(stub.getChildrenByType(JavaElementType.EXPORTS_STATEMENT, PsiPackageAccessibilityStatement.EMPTY_ARRAY));
|
||||
}
|
||||
else {
|
||||
return psiTraverser().children(this).filter(PsiPackageAccessibilityStatement.class).filter(EXPORTS_FILTER);
|
||||
return psiTraverser().children(this)
|
||||
.filter(PsiPackageAccessibilityStatement.class)
|
||||
.filter(statement -> statement.getRole() == PsiPackageAccessibilityStatement.Role.EXPORTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +74,9 @@ public class PsiJavaModuleImpl extends JavaStubPsiElement<PsiJavaModuleStub> imp
|
||||
return JBIterable.of(stub.getChildrenByType(JavaElementType.OPENS_STATEMENT, PsiPackageAccessibilityStatement.EMPTY_ARRAY));
|
||||
}
|
||||
else {
|
||||
return psiTraverser().children(this).filter(PsiPackageAccessibilityStatement.class).filter(OPENS_FILTER);
|
||||
return psiTraverser().children(this)
|
||||
.filter(PsiPackageAccessibilityStatement.class)
|
||||
.filter(statement -> statement.getRole() == PsiPackageAccessibilityStatement.Role.OPENS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-4
@@ -20,7 +20,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaPackageAccessibilityStatementElementType;
|
||||
import com.intellij.psi.impl.java.stubs.PsiPackageAccessibilityStatementStub;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -42,9 +41,7 @@ public class PsiPackageAccessibilityStatementImpl extends JavaStubPsiElement<Psi
|
||||
@NotNull
|
||||
@Override
|
||||
public Role getRole() {
|
||||
PsiPackageAccessibilityStatementStub stub = getGreenStub();
|
||||
IElementType type = stub != null ? stub.getStubType() : getNode().getElementType();
|
||||
return JavaPackageAccessibilityStatementElementType.typeToRole(type);
|
||||
return JavaPackageAccessibilityStatementElementType.typeToRole(getElementType());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -15,37 +15,33 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiProvidesStatementStub;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PsiProvidesStatementImpl extends CompositePsiElement implements PsiProvidesStatement {
|
||||
public PsiProvidesStatementImpl() {
|
||||
super(JavaElementType.PROVIDES_STATEMENT);
|
||||
public class PsiProvidesStatementImpl extends JavaStubPsiElement<PsiProvidesStatementStub> implements PsiProvidesStatement {
|
||||
public PsiProvidesStatementImpl(@NotNull PsiProvidesStatementStub stub) {
|
||||
super(stub, JavaStubElementTypes.PROVIDES_STATEMENT);
|
||||
}
|
||||
|
||||
public PsiProvidesStatementImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiJavaCodeReferenceElement getInterfaceReference() {
|
||||
for (PsiElement child = getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||
if (child instanceof PsiJavaCodeReferenceElement) return (PsiJavaCodeReferenceElement)child;
|
||||
if (PsiUtil.isJavaToken(child, JavaTokenType.WITH_KEYWORD)) break;
|
||||
}
|
||||
return null;
|
||||
return PsiTreeUtil.getChildOfType(this, PsiJavaCodeReferenceElement.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiJavaCodeReferenceElement getImplementationReference() {
|
||||
boolean afterWith = false;
|
||||
for (PsiElement child = getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||
if (afterWith && child instanceof PsiJavaCodeReferenceElement) return (PsiJavaCodeReferenceElement)child;
|
||||
if (PsiUtil.isJavaToken(child, JavaTokenType.WITH_KEYWORD)) afterWith = true;
|
||||
}
|
||||
return null;
|
||||
public PsiReferenceList getImplementationList() {
|
||||
return PsiTreeUtil.getChildOfType(this, PsiReferenceList.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -16,25 +16,21 @@
|
||||
package com.intellij.psi.impl.source;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaClassReferenceListElementType;
|
||||
import com.intellij.psi.impl.java.stubs.PsiClassReferenceListStub;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class PsiReferenceListImpl extends JavaStubPsiElement<PsiClassReferenceListStub> implements PsiReferenceList {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiReferenceListImpl");
|
||||
|
||||
public PsiReferenceListImpl(PsiClassReferenceListStub stub, IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
public PsiReferenceListImpl(@NotNull PsiClassReferenceListStub stub) {
|
||||
super(stub, stub.getStubType());
|
||||
}
|
||||
|
||||
public PsiReferenceListImpl(ASTNode node) {
|
||||
public PsiReferenceListImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@@ -64,22 +60,7 @@ public class PsiReferenceListImpl extends JavaStubPsiElement<PsiClassReferenceLi
|
||||
|
||||
@Override
|
||||
public Role getRole() {
|
||||
IElementType type = getElementType();
|
||||
if (type == JavaElementType.EXTENDS_LIST) {
|
||||
return Role.EXTENDS_LIST;
|
||||
}
|
||||
else if (type == JavaElementType.IMPLEMENTS_LIST) {
|
||||
return Role.IMPLEMENTS_LIST;
|
||||
}
|
||||
else if (type == JavaElementType.THROWS_LIST) {
|
||||
return Role.THROWS_LIST;
|
||||
}
|
||||
else if (type == JavaElementType.EXTENDS_BOUND_LIST) {
|
||||
return Role.EXTENDS_BOUNDS_LIST;
|
||||
}
|
||||
|
||||
LOG.error("Unknown element type:" + type);
|
||||
return null;
|
||||
return JavaClassReferenceListElementType.elementTypeToRole(getElementType());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,4 +77,4 @@ public class PsiReferenceListImpl extends JavaStubPsiElement<PsiClassReferenceLi
|
||||
public String toString() {
|
||||
return "PsiReferenceList";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,9 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiRequiresStatementStub;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.intellij.openapi.util.text.StringUtil.nullize;
|
||||
|
||||
public class PsiRequiresStatementImpl extends JavaStubPsiElement<PsiRequiresStatementStub> implements PsiRequiresStatement {
|
||||
public PsiRequiresStatementImpl(@NotNull PsiRequiresStatementStub stub) {
|
||||
@@ -33,18 +33,16 @@ public class PsiRequiresStatementImpl extends JavaStubPsiElement<PsiRequiresStat
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiJavaModuleReferenceElement getReferenceElement() {
|
||||
return PsiTreeUtil.getChildOfType(this, PsiJavaModuleReferenceElement.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
PsiRequiresStatementStub stub = getGreenStub();
|
||||
if (stub != null) {
|
||||
return stub.getModuleName();
|
||||
return nullize(stub.getModuleName());
|
||||
}
|
||||
else {
|
||||
PsiJavaModuleReferenceElement refElement = getReferenceElement();
|
||||
@@ -52,21 +50,6 @@ public class PsiRequiresStatementImpl extends JavaStubPsiElement<PsiRequiresStat
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPublic() {
|
||||
PsiRequiresStatementStub stub = getGreenStub();
|
||||
if (stub != null) {
|
||||
return stub.isPublic();
|
||||
}
|
||||
else {
|
||||
for (PsiElement child = getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||
if (PsiUtil.isJavaToken(child, JavaTokenType.PUBLIC_KEYWORD)) return true;
|
||||
if (child instanceof PsiJavaModuleReferenceElement) break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiModifierList getModifierList() {
|
||||
return getStubOrPsiChild(JavaStubElementTypes.MODIFIER_LIST);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -15,19 +15,24 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.JavaElementVisitor;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiUsesStatement;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiUsesStatementStub;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PsiUsesStatementImpl extends CompositePsiElement implements PsiUsesStatement {
|
||||
public PsiUsesStatementImpl() {
|
||||
super(JavaElementType.USES_STATEMENT);
|
||||
public class PsiUsesStatementImpl extends JavaStubPsiElement<PsiUsesStatementStub> implements PsiUsesStatement {
|
||||
public PsiUsesStatementImpl(@NotNull PsiUsesStatementStub stub) {
|
||||
super(stub, JavaStubElementTypes.USES_STATEMENT);
|
||||
}
|
||||
|
||||
public PsiUsesStatementImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -89,6 +89,9 @@ public interface JavaElementType {
|
||||
IElementType REQUIRES_STATEMENT = JavaStubElementTypes.REQUIRES_STATEMENT;
|
||||
IElementType EXPORTS_STATEMENT = JavaStubElementTypes.EXPORTS_STATEMENT;
|
||||
IElementType OPENS_STATEMENT = JavaStubElementTypes.OPENS_STATEMENT;
|
||||
IElementType USES_STATEMENT = JavaStubElementTypes.USES_STATEMENT;
|
||||
IElementType PROVIDES_STATEMENT = JavaStubElementTypes.PROVIDES_STATEMENT;
|
||||
IElementType PROVIDES_WITH_LIST = JavaStubElementTypes.PROVIDES_WITH_LIST;
|
||||
|
||||
IElementType IMPORT_STATIC_REFERENCE = new JavaCompositeElementType("IMPORT_STATIC_REFERENCE", PsiImportStaticReferenceElementImpl.class);
|
||||
IElementType TYPE = new JavaCompositeElementType("TYPE", PsiTypeElementImpl.class);
|
||||
@@ -143,8 +146,6 @@ public interface JavaElementType {
|
||||
IElementType ANNOTATION_ARRAY_INITIALIZER = new JavaCompositeElementType("ANNOTATION_ARRAY_INITIALIZER", PsiArrayInitializerMemberValueImpl.class);
|
||||
IElementType RECEIVER_PARAMETER = new JavaCompositeElementType("RECEIVER", PsiReceiverParameterImpl.class);
|
||||
IElementType MODULE_REFERENCE = new JavaCompositeElementType("MODULE_REFERENCE", PsiJavaModuleReferenceElementImpl.class);
|
||||
IElementType USES_STATEMENT = new JavaCompositeElementType("USES_STATEMENT", PsiUsesStatementImpl.class);
|
||||
IElementType PROVIDES_STATEMENT = new JavaCompositeElementType("PROVIDES_STATEMENT", PsiProvidesStatementImpl.class);
|
||||
|
||||
class ICodeBlockElementType extends IErrorCounterReparseableElementType implements ICompositeElementType, ILightLazyParseableElementType {
|
||||
private ICodeBlockElementType() {
|
||||
|
||||
@@ -397,6 +397,7 @@ module.duplicate.requires=Duplicate requires: {0}
|
||||
module.duplicate.export=Duplicate export: {0}
|
||||
module.duplicate.uses=Duplicate uses: {0}
|
||||
module.duplicate.provides=Duplicate provides: {0}
|
||||
module.duplicate.impl=Duplicate implementation: {0}
|
||||
module.file.wrong.location=Module declaration should be located in a module's source root
|
||||
module.open.duplicate.text=Go to duplicate
|
||||
module.not.found=Module not found: {0}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,12 +2,18 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
@java.lang.Deprecated
|
||||
module M.N {
|
||||
requires java.desktop;
|
||||
requires public java.logging;
|
||||
requires static transitive java.logging;
|
||||
|
||||
exports pkg.d1;
|
||||
exports pkg.d2 to java.desktop;
|
||||
|
||||
/* ... */
|
||||
opens pkg.d1;
|
||||
opens pkg.d2 to java.desktop;
|
||||
|
||||
uses pkg.d1.C1;
|
||||
|
||||
provides pkg.d1.C1 with pkg.d2.C2;
|
||||
}
|
||||
Binary file not shown.
@@ -1,6 +1,15 @@
|
||||
PsiJavaFileStub []
|
||||
PsiJavaModuleStub:M.N
|
||||
PsiRequiresStatementStub:0:java.desktop
|
||||
PsiRequiresStatementStub:1:java.logging
|
||||
PsiModifierListStub[mask=0]
|
||||
PsiAnnotationStub[@java.lang.Deprecated]
|
||||
PsiRequiresStatementStub:java.desktop
|
||||
PsiModifierListStub[mask=0]
|
||||
PsiRequiresStatementStub:java.logging
|
||||
PsiModifierListStub[mask=16392]
|
||||
PsiPackageAccessibilityStatementStub[EXPORTS]:pkg.d1
|
||||
PsiPackageAccessibilityStatementStub[EXPORTS]:pkg.d2:java.desktop
|
||||
PsiPackageAccessibilityStatementStub[EXPORTS]:pkg.d2:java.desktop
|
||||
PsiPackageAccessibilityStatementStub[OPENS]:pkg.d1
|
||||
PsiPackageAccessibilityStatementStub[OPENS]:pkg.d2:java.desktop
|
||||
PsiUsesStatementStub:pkg.d1.C1
|
||||
PsiProvidesStatementStub:pkg.d1.C1
|
||||
PsiRefListStub[PROVIDES_WITH_LIST:pkg.d2.C2]
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:BadContent.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:X
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports2.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports3.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports4.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports5.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports6.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports7.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Exports8.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Extras.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:one
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
PsiJavaFile:Incomplete0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Incomplete1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:X
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
PsiJavaFile:Incomplete2.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Module declaration expected
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Incomplete3.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:X
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Incomplete4.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:X
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
PsiJavaFile:ModifierList0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:open
|
||||
PsiKeyword:open('open')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:M('M')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -0,0 +1,22 @@
|
||||
PsiJavaFile:ModifierList1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:@Deprecated
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:Deprecated
|
||||
PsiIdentifier:Deprecated('Deprecated')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:M('M')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Name0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:A.
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Name1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:A..B
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Name2.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:AB
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Name3.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:.A
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
PsiJavaFile:Opens0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:M('M')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiPackageAccessibilityStatement
|
||||
PsiKeyword:opens('opens')
|
||||
PsiErrorElement:Package reference expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -0,0 +1,32 @@
|
||||
PsiJavaFile:Opens1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:M('M')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiPackageAccessibilityStatement
|
||||
PsiKeyword:opens('opens')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:pkg
|
||||
PsiIdentifier:pkg('pkg')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:to('to')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:A('A')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:B('B')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Provides0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Provides1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Provides2.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Provides3.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -15,8 +19,9 @@ PsiJavaFile:Provides3.java
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:with('with')
|
||||
PsiErrorElement:Class reference expected
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
PsiKeyword:with('with')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Provides4.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -15,9 +19,10 @@ PsiJavaFile:Provides4.java
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:with('with')
|
||||
PsiErrorElement:Class reference expected
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
PsiKeyword:with('with')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Provides5.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -15,12 +19,13 @@ PsiJavaFile:Provides5.java
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:with('with')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:Impl
|
||||
PsiIdentifier:Impl('Impl')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
PsiKeyword:with('with')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:Impl
|
||||
PsiIdentifier:Impl('Impl')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:';' expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Provides6.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -15,12 +19,13 @@ PsiJavaFile:Provides6.java
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:with('with')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:Impl
|
||||
PsiIdentifier:Impl('Impl')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
PsiKeyword:with('with')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:Impl
|
||||
PsiIdentifier:Impl('Impl')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Provides7.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
PsiJavaFile:Provides8.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:M('M')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiProvidesStatement
|
||||
PsiKeyword:provides('provides')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:Spi
|
||||
PsiIdentifier:Spi('Spi')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceList
|
||||
PsiKeyword:with('with')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:Impl1
|
||||
PsiIdentifier:Impl1('Impl1')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:Impl2
|
||||
PsiIdentifier:Impl2('Impl2')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Requires0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -9,7 +13,9 @@ PsiJavaFile:Requires0.java
|
||||
PsiWhiteSpace(' ')
|
||||
PsiRequiresStatement
|
||||
PsiKeyword:requires('requires')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Requires1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -10,6 +14,8 @@ PsiJavaFile:Requires1.java
|
||||
PsiRequiresStatement
|
||||
PsiKeyword:requires('requires')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:X('X')
|
||||
PsiErrorElement:';' expected
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Requires2.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -10,7 +14,10 @@ PsiJavaFile:Requires2.java
|
||||
PsiRequiresStatement
|
||||
PsiKeyword:requires('requires')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:public('public')
|
||||
PsiModifierList:transitive static
|
||||
PsiKeyword:transitive('transitive')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:static('static')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:X('X')
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Requires3.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -9,13 +13,12 @@ PsiJavaFile:Requires3.java
|
||||
PsiWhiteSpace(' ')
|
||||
PsiRequiresStatement
|
||||
PsiKeyword:requires('requires')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Module statement expected
|
||||
PsiKeyword:private('private')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:X('X')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiModifierList:private
|
||||
PsiKeyword:private('private')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:X('X')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,5 +1,9 @@
|
||||
PsiJavaFile:Requires4.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiJavaModule:M
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:module('module')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaModuleReference
|
||||
@@ -10,6 +14,8 @@ PsiJavaFile:Requires4.java
|
||||
PsiRequiresStatement
|
||||
PsiKeyword:requires('requires')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiJavaModuleReference
|
||||
PsiIdentifier:A('A')
|
||||
PsiErrorElement:';' expected
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user