Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package consulo.ironPython.psi.impl;

import com.jetbrains.python.impl.psi.impl.ResolveResultList;
import com.jetbrains.python.psi.AccessDirection;
import com.jetbrains.python.psi.PyCallSiteExpression;
import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.impl.psi.impl.ResolveResultList;
import com.jetbrains.python.psi.resolve.PyResolveContext;
import com.jetbrains.python.psi.resolve.RatedResolveResult;
import com.jetbrains.python.psi.types.PyCallableParameter;
import com.jetbrains.python.psi.types.PyClassLikeType;
import com.jetbrains.python.psi.types.PyType;
import com.jetbrains.python.psi.types.TypeEvalContext;
import consulo.annotation.access.RequiredReadAction;
import consulo.application.util.function.Processor;
import consulo.dotnet.psi.DotNetNamedElement;
import consulo.dotnet.psi.DotNetTypeDeclaration;
import consulo.dotnet.psi.resolve.DotNetTypeRef;
Expand All @@ -37,9 +35,10 @@
import consulo.language.psi.PsiNamedElement;
import consulo.language.util.ProcessingContext;
import consulo.util.collection.ArrayUtil;

import org.jspecify.annotations.Nullable;

import java.util.*;
import java.util.function.Predicate;

/**
* @author yole
Expand All @@ -57,6 +56,7 @@ public PyDotNetClassType(DotNetTypeDeclaration aClass, boolean definition)

@Override
@Nullable
@RequiredReadAction
public List<? extends RatedResolveResult> resolveMember(String name, PyExpression location, AccessDirection direction,
PyResolveContext resolveContext)
{
Expand All @@ -65,6 +65,7 @@ public List<? extends RatedResolveResult> resolveMember(String name, PyExpressio

@Nullable
@Override
@RequiredReadAction
public List<? extends RatedResolveResult> resolveMember(String name, @Nullable PyExpression location,
AccessDirection direction, PyResolveContext resolveContext, boolean inherited)
{
Expand All @@ -82,15 +83,17 @@ public List<? extends RatedResolveResult> resolveMember(String name, @Nullable P
}

@Override
public void visitMembers(Processor<PsiElement> processor, boolean inherited, TypeEvalContext context)
@RequiredReadAction
public void visitMembers(Predicate<PsiElement> processor, boolean inherited, TypeEvalContext context)
{
for(DotNetNamedElement dotNetNamedElement : myClass.getMembers())
{
processor.process(dotNetNamedElement);
processor.test(dotNetNamedElement);
}
}

@Override
@RequiredReadAction
public Set<String> getMemberNames(boolean inherited, TypeEvalContext context)
{
Set<String> names = new HashSet<>();
Expand All @@ -102,9 +105,10 @@ public Set<String> getMemberNames(boolean inherited, TypeEvalContext context)
}

@Override
@RequiredReadAction
public Object[] getCompletionVariants(String completionPrefix, PsiElement location, ProcessingContext context)
{
List<Object> variants = new ArrayList<Object>();
List<Object> variants = new ArrayList<>();
for(PsiElement child : myClass.getMembers())
{
if(child instanceof PsiNamedElement)
Expand All @@ -116,6 +120,7 @@ public Object[] getCompletionVariants(String completionPrefix, PsiElement locati
}

@Override
@RequiredReadAction
public String getName()
{
if(myClass != null)
Expand Down Expand Up @@ -184,6 +189,7 @@ public PyClassLikeType toInstance()

@Nullable
@Override
@RequiredReadAction
public String getClassQName()
{
return myClass.getPresentableQName();
Expand All @@ -193,7 +199,7 @@ public String getClassQName()
@RequiredReadAction
public List<PyClassLikeType> getSuperClassTypes(TypeEvalContext context)
{
List<PyClassLikeType> result = new ArrayList<PyClassLikeType>();
List<PyClassLikeType> result = new ArrayList<>();
for(DotNetTypeRef typeRef : myClass.getExtendTypeRefs())
{
PsiElement resolve = typeRef.resolve().getElement();
Expand All @@ -206,6 +212,7 @@ public List<PyClassLikeType> getSuperClassTypes(TypeEvalContext context)
}

@Override
@RequiredReadAction
public boolean isValid()
{
return myClass.isValid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package consulo.ironPython.sdk.flavors;

import com.jetbrains.python.impl.PythonIcons;
Expand All @@ -36,7 +35,7 @@ public class IronPythonSdkFlavor extends PythonSdkFlavor
@Override
public Collection<String> suggestHomePaths()
{
Set<String> result = new TreeSet<String>();
Set<String> result = new TreeSet<>();
String root = System.getenv("ProgramFiles(x86)");
if(root == null)
{
Expand Down Expand Up @@ -72,7 +71,8 @@ public boolean isValidSdkPath(File file)
return name.equals("ipy.exe") || name.equals("ipy64.exe");
}

public String getVersionStringFromOutput(String version)
@Override
public String getVersionStringFromOutput(String version)
{
return getName() + " " + version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@
import com.intellij.java.language.psi.PsiField;
import com.intellij.java.language.psi.PsiMethod;
import com.jetbrains.python.impl.psi.impl.ResolveResultList;
import com.jetbrains.python.impl.psi.resolve.CompletionVariantsProcessor;
import com.jetbrains.python.psi.AccessDirection;
import com.jetbrains.python.psi.PyCallSiteExpression;
import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.impl.psi.resolve.CompletionVariantsProcessor;
import com.jetbrains.python.psi.resolve.PyResolveContext;
import com.jetbrains.python.psi.resolve.RatedResolveResult;
import com.jetbrains.python.psi.types.PyCallableParameter;
import com.jetbrains.python.psi.types.PyClassLikeType;
import com.jetbrains.python.psi.types.PyType;
import com.jetbrains.python.psi.types.TypeEvalContext;
import consulo.application.util.function.Processor;
import consulo.annotation.access.RequiredReadAction;
import consulo.language.psi.PsiElement;
import consulo.language.psi.resolve.ResolveState;
import consulo.language.util.ProcessingContext;

import org.jspecify.annotations.Nullable;

import java.util.*;
import java.util.function.Predicate;

/**
* @author yole
Expand All @@ -50,6 +51,7 @@ public PyJavaClassType(PsiClass aClass, boolean definition) {
}

@Nullable
@Override
public List<? extends RatedResolveResult> resolveMember(String name,
@Nullable PyExpression location,
AccessDirection direction,
Expand Down Expand Up @@ -79,19 +81,17 @@ public List<? extends RatedResolveResult> resolveMember(String name,
return null;
}

@Override
public Object[] getCompletionVariants(String completionPrefix, PsiElement location, ProcessingContext context) {
CompletionVariantsProcessor processor = new CompletionVariantsProcessor(location);
myClass.processDeclarations(processor, ResolveState.initial(), null, location);
return processor.getResult();
}

@Override
@RequiredReadAction
public String getName() {
if (myClass != null) {
return myClass.getName();
}
else {
return null;
}
return myClass != null ? myClass.getName() : null;
}

@Override
Expand Down Expand Up @@ -155,13 +155,13 @@ public List<PyClassLikeType> getSuperClassTypes(TypeEvalContext context) {
}

@Override
public void visitMembers(Processor<PsiElement> processor, boolean inherited, TypeEvalContext context) {
public void visitMembers(Predicate<PsiElement> processor, boolean inherited, TypeEvalContext context) {
for (PsiMethod method : myClass.getAllMethods()) {
processor.process(method);
processor.test(method);
}

for (PsiField field : myClass.getAllFields()) {
processor.process(field);
processor.test(field);
}

if (!inherited) {
Expand All @@ -176,6 +176,7 @@ public void visitMembers(Processor<PsiElement> processor, boolean inherited, Typ
}

@Override
@RequiredReadAction
public Set<String> getMemberNames(boolean inherited, TypeEvalContext context) {
Set<String> result = new LinkedHashSet<>();

Expand Down Expand Up @@ -223,6 +224,7 @@ public List<PyClassLikeType> getAncestorTypes(TypeEvalContext context) {
}

@Override
@RequiredReadAction
public boolean isValid() {
return myClass.isValid();
}
Expand All @@ -238,24 +240,13 @@ public PsiClass getPsiClass() {
}

@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PyJavaClassType)) {
return false;
}

PyJavaClassType type = (PyJavaClassType)o;

if (myDefinition != type.myDefinition) {
return false;
}
if (myClass != null ? !myClass.equals(type.myClass) : type.myClass != null) {
return false;
}

return true;
return o instanceof PyJavaClassType type
&& myDefinition == type.myDefinition
&& Objects.equals(myClass, type.myClass);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.jetbrains.python.jython.sdk.flavors;

import com.jetbrains.python.impl.sdk.flavors.PythonSdkFlavor;
Expand Down Expand Up @@ -45,13 +44,13 @@ public class JythonSdkFlavor extends PythonSdkFlavor
private static final String JYTHONPATH = "JYTHONPATH";
private static final String PYTHON_PATH_PREFIX = "-Dpython.path=";


public static String getPythonPathCmdLineArgument(Collection<String> path)
{
return PYTHON_PATH_PREFIX + StringUtil.join(appendSystemEnvPaths(path, JYTHONPATH), File.pathSeparator);
}

public boolean isValidSdkPath(File file)
@Override
public boolean isValidSdkPath(File file)
{
return FileUtil.getNameWithoutExtension(file).toLowerCase().startsWith("jython");
}
Expand Down Expand Up @@ -101,7 +100,7 @@ public ProcessHandler createProcessHandler(GeneralCommandLine commandLine, boole
@Override
public Collection<String> collectDebugPythonPath()
{
List<String> list = new ArrayList<String>(2);
List<String> list = new ArrayList<>(2);
//that fixes Jython problem changing sys.argv on execfile, see PY-8164
list.add(PythonHelpersLocator.getHelperPath("pycharm"));
list.add(PythonHelpersLocator.getHelperPath("pydev"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,7 @@ public char lastChar() {
return this.value[this.count-1];
}


public final static class BackwardCharIterator implements Iterable<Character>{

private int i;
private FastStringBuffer fastStringBuffer;

Expand All @@ -363,17 +361,20 @@ public BackwardCharIterator(FastStringBuffer fastStringBuffer) {
i = fastStringBuffer.length();
}

@Override
public Iterator<Character> iterator() {
return new Iterator<Character>(){

return new Iterator<>(){
@Override
public boolean hasNext() {
return i > 0;
}

@Override
public Character next() {
return fastStringBuffer.value[--i];
}

@Override
public void remove() {
throw new RuntimeException("Not implemented");
}
Expand Down Expand Up @@ -460,5 +461,4 @@ public void setCharAt(int i, char c) {
public void setLength(int i) {
this.count = i;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protected LoadSourceCommand(RemoteDebugger debugger, String path) {
myPath = path;
}

@Override
public boolean isResponseExpected() {
return true;
}
Expand Down
Loading
Loading