Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ekaterina Tuzova
2017-05-19 18:22:02 +03:00
8 changed files with 36 additions and 43 deletions
@@ -91,10 +91,13 @@ public class PluginClassLoader extends UrlClassLoader {
}
private static boolean mustBeLoadedByPlatform(String className) {
//FunctionX interfaces from kotlin-runtime must be loaded by the platform classloader. Otherwise if a plugin bundles its own version
// of kotlin-runtime.jar it won't be possible to call platform's methods with Kotlin functional types in signatures from such a plugin.
//We assume that FunctionX interfaces don't change between Kotlin versions so it's safe to always load them from platform's kotlin-runtime.
return className.startsWith("kotlin.jvm.functions.");
//some commonly used classes from kotlin-runtime must be loaded by the platform classloader. Otherwise if a plugin bundles its own version
// of kotlin-runtime.jar it won't be possible to call platform's methods with these types in signatures from such a plugin.
//We assume that these classes don't change between Kotlin versions so it's safe to always load them from platform's kotlin-runtime.
return className.startsWith("kotlin.") && (className.startsWith("kotlin.jvm.functions.")
|| className.equals("kotlin.sequences.Sequence")
|| className.equals("kotlin.Pair")
|| className.equals("kotlin.Triple"));
}
@Nullable
@@ -83,19 +83,13 @@ abstract class DirectBufferWrapper extends ByteBufferWrapper {
throw new RuntimeException(e);
}
}
return AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
@Nullable
public Object run() {
try {
Cleaner cleaner = ((DirectBuffer)buffer).cleaner();
if (cleaner != null) cleaner.clean(); // Already cleaned otherwise
return null;
}
catch (Throwable e) {
return buffer;
}
}
}) == null;
try {
Cleaner cleaner = ((DirectBuffer)buffer).cleaner();
if (cleaner != null) cleaner.clean(); // Already cleaned otherwise
return true;
}
catch (Throwable e) {
return 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.
@@ -112,17 +112,17 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
final PsiIdentifier nameIdentifier = checkedClass.getNameIdentifier();
if (CHECK_JAVA_CODE &&
nameIdentifier != null &&
checkedClass.getQualifiedName() != null &&
checkedClass.getContainingFile().getVirtualFile() != null)
{
nameIdentifier != null &&
checkedClass.getQualifiedName() != null &&
checkedClass.getContainingFile().getVirtualFile() != null) {
final Set<PsiClass> componentClasses = RegistrationCheckerUtil.getRegistrationTypes(checkedClass, CHECK_ACTIONS);
if (componentClasses != null && !componentClasses.isEmpty()) {
List<ProblemDescriptor> problems = null;
List<ProblemDescriptor> problems = new SmartList<>();
for (PsiClass compClass : componentClasses) {
if (!checkedClass.isInheritor(compClass, true)) {
problems = addProblem(problems, manager.createProblemDescriptor(nameIdentifier,
if (ActionType.ACTION.myClassName.equals(compClass.getQualifiedName()) &&
!checkedClass.isInheritor(compClass, true)) {
problems.add(manager.createProblemDescriptor(nameIdentifier,
DevKitBundle.message("inspections.registration.problems.incompatible.message",
compClass.isInterface() ?
DevKitBundle.message("keyword.implement") :
@@ -133,28 +133,23 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
}
if (ActionType.ACTION.isOfType(checkedClass)) {
if (ConstructorType.getNoArgCtor(checkedClass) == null) {
problems = addProblem(problems, manager.createProblemDescriptor(nameIdentifier,
DevKitBundle.message("inspections.registration.problems.missing.noarg.ctor"),
new CreateConstructorFix(checkedClass, isOnTheFly),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly));
problems.add(manager.createProblemDescriptor(nameIdentifier,
DevKitBundle.message("inspections.registration.problems.missing.noarg.ctor"),
new CreateConstructorFix(checkedClass, isOnTheFly),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly));
}
}
if (isAbstract(checkedClass)) {
problems = addProblem(problems, manager.createProblemDescriptor(nameIdentifier,
DevKitBundle.message("inspections.registration.problems.abstract"), isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
problems.add(manager.createProblemDescriptor(nameIdentifier,
DevKitBundle.message("inspections.registration.problems.abstract"), isOnTheFly,
LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
}
return problems != null ? problems.toArray(new ProblemDescriptor[problems.size()]) : null;
return ArrayUtil.toObjectArray(problems, ProblemDescriptor.class);
}
}
return null;
}
private static List<ProblemDescriptor> addProblem(List<ProblemDescriptor> problems, ProblemDescriptor problemDescriptor) {
if (problems == null) problems = new SmartList<>();
problems.add(problemDescriptor);
return problems;
}
@Nullable
private static ProblemDescriptor[] checkPluginXml(XmlFile xmlFile, InspectionManager manager, boolean isOnTheFly) {
final XmlDocument document = xmlFile.getDocument();
@@ -0,0 +1 @@
public class MyApplicationComponentMustNotInherit {}
@@ -1 +0,0 @@
public class <error descr="According to its registration in plugin.xml, the class should implement 'com.intellij.openapi.components.ApplicationComponent'">MyApplicationComponentWrongClass</error> {}
@@ -42,9 +42,9 @@ public class RegistrationProblemsInspectionCodeTest extends PluginModuleTestCase
myFixture.testHighlighting("AbstractApplicationComponent.java");
}
public void testComponentWrongClass() {
setPluginXml("ApplicationComponentWrongClass.xml");
myFixture.testHighlighting("MyApplicationComponentWrongClass.java");
public void testApplicationComponentMustNotInherit() {
setPluginXml("ApplicationComponentMustNotInherit.xml");
myFixture.testHighlighting("MyApplicationComponentMustNotInherit.java");
}
public void testActionAbstractClass() {
@@ -613,6 +613,7 @@ object PyTestsConfigurationProducer : com.jetbrains.python.testing.AbstractPytho
configuration.workingDirectory = targetForConfig.second
}
}
configuration.module = context?.module
configuration.setGeneratedName()
return true
}