mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Close custom stub API (PY-29929)
This commit is contained in:
@@ -22,7 +22,6 @@ package com.jetbrains.python.psi.stubs;
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import com.intellij.psi.util.QualifiedName;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.impl.stubs.PyCustomClassStub;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -69,15 +68,12 @@ public interface PyClassStub extends NamedStub<PyClass> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stubClass custom stub class
|
||||
* @param <T> custom stub class
|
||||
* @return saved stub if it is an instance of passed class or null.
|
||||
* @apiNote This method will be marked as abstract in 2019.2.
|
||||
* @see PyCustomClassStub
|
||||
* @see com.jetbrains.python.psi.impl.stubs.PyCustomClassStubType
|
||||
* @deprecated It is our internal API, try to avoid using it.
|
||||
* It is planned to be removed sooner or later, so please don't rely on this method.
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
default <T extends PyCustomClassStub> T getCustomStub(@NotNull Class<T> stubClass) {
|
||||
default <T> T getCustomStub(@NotNull Class<T> stubClass) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package com.jetbrains.python.psi.stubs;
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import com.intellij.psi.util.QualifiedName;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import com.jetbrains.python.psi.impl.stubs.CustomTargetExpressionStub;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -58,8 +57,13 @@ public interface PyTargetExpressionStub extends NamedStub<PyTargetExpression>, P
|
||||
|
||||
boolean isQualified();
|
||||
|
||||
/**
|
||||
* @deprecated It is our internal API, try to avoid using it.
|
||||
* It is planned to be removed sooner or later, so please don't rely on this method.
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
<T extends CustomTargetExpressionStub> T getCustomStub(Class<T> stubClass);
|
||||
<T> T getCustomStub(Class<T> stubClass);
|
||||
|
||||
@Nullable
|
||||
String getDocString();
|
||||
|
||||
+5
@@ -26,6 +26,11 @@ import com.jetbrains.python.psi.stubs.PyTargetExpressionStub;
|
||||
public abstract class CustomTargetExpressionStubType<T extends CustomTargetExpressionStub>
|
||||
implements PyCustomStubType<PyTargetExpression, T> {
|
||||
|
||||
/**
|
||||
* @deprecated It is our internal API, try to avoid using it.
|
||||
* It is planned to be removed sooner or later, so please don't rely on this EP.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ExtensionPointName<CustomTargetExpressionStubType<? extends CustomTargetExpressionStub>> EP_NAME =
|
||||
ExtensionPointName.create("Pythonid.customTargetExpressionStubType");
|
||||
|
||||
@@ -140,7 +140,7 @@ public class PyClassStubImpl extends StubBase<PyClass> implements PyClassStub {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends PyCustomClassStub> T getCustomStub(@NotNull Class<T> stubClass) {
|
||||
public <T> T getCustomStub(@NotNull Class<T> stubClass) {
|
||||
return ObjectUtils.tryCast(myCustomStub, stubClass);
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -6,6 +6,11 @@ import com.jetbrains.python.psi.PyClass;
|
||||
|
||||
public abstract class PyCustomClassStubType<T extends PyCustomClassStub> implements PyCustomStubType<PyClass, T> {
|
||||
|
||||
/**
|
||||
* @deprecated It is our internal API, try to avoid using it.
|
||||
* It is planned to be removed sooner or later, so please don't rely on this EP.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ExtensionPointName<PyCustomClassStubType<? extends PyCustomClassStub>> EP_NAME =
|
||||
ExtensionPointName.create("Pythonid.customClassStubType");
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface PyCustomStub<CustomStubType extends PyCustomStubType> {
|
||||
interface PyCustomStub<CustomStubType extends PyCustomStubType> {
|
||||
|
||||
/**
|
||||
* @return type class to distinguish one custom stub from another.
|
||||
+1
-1
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface PyCustomStubType<Psi extends PyElement, Stub extends PyCustomStub> {
|
||||
interface PyCustomStubType<Psi extends PyElement, Stub extends PyCustomStub> {
|
||||
|
||||
/**
|
||||
* @param psi element to create stub for
|
||||
+3
-4
@@ -1,17 +1,16 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.psi;
|
||||
package com.jetbrains.python.psi.impl.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.jetbrains.python.psi.impl.stubs.PyCustomStub;
|
||||
import com.jetbrains.python.psi.impl.stubs.PyCustomStubType;
|
||||
import com.jetbrains.python.psi.PyElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface PyCustomizableStubElementType<Psi extends PyElement, Stub extends PyCustomStub, StubType extends PyCustomStubType<Psi, ? extends Stub>> {
|
||||
interface PyCustomizableStubElementType<Psi extends PyElement, Stub extends PyCustomStub, StubType extends PyCustomStubType<Psi, ? extends Stub>> {
|
||||
|
||||
@NotNull
|
||||
List<StubType> getExtensions();
|
||||
@@ -17,9 +17,9 @@ package com.jetbrains.python.psi.impl.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.StubBase;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.util.QualifiedName;
|
||||
import com.jetbrains.python.PyElementTypes;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import com.intellij.psi.util.QualifiedName;
|
||||
import com.jetbrains.python.psi.stubs.PyTargetExpressionStub;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PyTargetExpressionStubImpl extends StubBase<PyTargetExpression> imp
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends CustomTargetExpressionStub> T getCustomStub(Class<T> stubClass) {
|
||||
public <T> T getCustomStub(Class<T> stubClass) {
|
||||
if (stubClass.isInstance(myCustomStub)) {
|
||||
return stubClass.cast(myCustomStub);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user