Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into backport_intellij_2020.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	.travis.yml
#	gradle.properties
#	src/main/java/de/plushnikov/intellij/plugin/activity/LombokProjectValidatorActivity.java
#	src/main/java/de/plushnikov/intellij/plugin/jps/LombokBuildProcessParametersProvider.java
#	src/main/java/de/plushnikov/intellij/plugin/problem/LombokProblem.java
#	src/main/java/de/plushnikov/intellij/plugin/processor/SynchronizedProcessor.java
#	src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java
  • Loading branch information
mplushnikov committed Jan 2, 2021
2 parents 53002ca + 1b11c30 commit c2da4ff
Show file tree
Hide file tree
Showing 86 changed files with 835 additions and 747 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "org.jetbrains.intellij" version "0.6.3"
id "org.jetbrains.intellij" version "0.6.5"
id "org.jetbrains.grammarkit" version "2020.2.1"
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
}
Expand Down Expand Up @@ -83,7 +83,7 @@ dependencies {
lombok group: 'org.projectlombok', name: 'lombok', version: '1.18.16', classifier: 'sources', ext: 'jar'

testImplementation("junit:junit:4.13.1")
testImplementation("org.mockito:mockito-core:3.6.0")
testImplementation("org.mockito:mockito-core:3.6.28")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.7.0")
}

Expand Down
3 changes: 2 additions & 1 deletion parts/pluginChanges.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<li>0.33
<ol>
<li>Implemented new intention actions to replace explicit getter and setter by lombok annotation, thanks to
@Lekanich (Aleksandr Zhelezniak)</li>
@Lekanich (Aleksandr Zhelezniak)
</li>
<li>Fixed #799: @SneakyThrows mistakenly swallow checked exception in lambda without "throws", thanks to
@Lekanich (Aleksandr Zhelezniak)
</li>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/plushnikov/intellij/plugin/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public interface Version {
*/
@NonNls String LAST_LOMBOK_VERSION = "1.18.16";

@NonNls String LAST_LOMBOK_VERSION_WITH_JPS_FIX = "1.18.16";

static boolean isLessThan(@Nullable OrderEntry orderEntry, @NotNull String version) {
String lombokVersion = parseLombokVersion(orderEntry);
return lombokVersion != null && compareVersionString(lombokVersion, version) < 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.util.containers.ContainerUtil;
import de.plushnikov.intellij.plugin.activity.LombokProjectValidatorActivity;
import de.plushnikov.intellij.plugin.util.LombokLibraryUtil;
import de.plushnikov.intellij.plugin.util.PsiClassUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -114,7 +114,7 @@ public void update(@NotNull AnActionEvent event) {
final DataContext dataContext = event.getDataContext();

final Project project = event.getProject();
if (project == null || !LombokProjectValidatorActivity.hasLombokLibrary(project)) {
if (project == null || !LombokLibraryUtil.hasLombokLibrary(project)) {
presentation.setEnabled(false);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import de.plushnikov.intellij.plugin.activity.LombokProjectValidatorActivity;
import de.plushnikov.intellij.plugin.util.LombokLibraryUtil;
import org.jetbrains.annotations.NotNull;

public abstract class BaseLombokAction extends BaseGenerateAction {
Expand All @@ -17,6 +17,6 @@ protected BaseLombokAction(CodeInsightActionHandler handler) {
@Override
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return file.isWritable() && super.isValidForFile(project, editor, file) &&
LombokProjectValidatorActivity.hasLombokLibrary(project);
LombokLibraryUtil.hasLombokLibrary(project);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PropertyUtilBase;
import de.plushnikov.intellij.plugin.LombokClassNames;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PropertyUtilBase;
import de.plushnikov.intellij.plugin.LombokClassNames;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.intellij.compiler.server.BuildManagerListener;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.project.Project;
import de.plushnikov.intellij.plugin.util.LombokLibraryUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.java.compiler.AnnotationProcessingConfiguration;

Expand All @@ -16,7 +17,7 @@ public class LombokBuildManagerListener implements BuildManagerListener {
public void beforeBuildProcessStarted(@NotNull Project project,
@NotNull UUID sessionId) {
if (!hasAnnotationProcessorsEnabled(project) &&
ReadAction.compute(() -> LombokProjectValidatorActivity.hasLombokLibrary(project))) {
ReadAction.compute(() -> LombokLibraryUtil.hasLombokLibrary(project))) {
enableAnnotationProcessors(project);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

import com.intellij.compiler.server.BuildManagerListener;
import com.intellij.notification.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.util.concurrency.AppExecutorUtil;
import com.intellij.util.messages.MessageBusConnection;
import de.plushnikov.intellij.plugin.LombokBundle;
import de.plushnikov.intellij.plugin.Version;
import de.plushnikov.intellij.plugin.provider.LombokProcessorProvider;
import de.plushnikov.intellij.plugin.settings.ProjectSettings;
import de.plushnikov.intellij.plugin.util.LombokLibraryUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -43,7 +38,7 @@ public void runActivity(@NotNull Project project) {
ReadAction.nonBlocking(() -> {
if (project.isDisposed()) return null;

final boolean hasLombokLibrary = hasLombokLibrary(project);
final boolean hasLombokLibrary = LombokLibraryUtil.hasLombokLibrary(project);

// If dependency is present and out of date notification setting is enabled (defaults to disabled)
if (hasLombokLibrary && ProjectSettings.isEnabled(project, ProjectSettings.IS_LOMBOK_VERSION_CHECK_ENABLED, false)) {
Expand All @@ -53,9 +48,8 @@ public void runActivity(@NotNull Project project) {

if (null != lombokVersion && Version.compareVersionString(lombokVersion, Version.LAST_LOMBOK_VERSION) < 0) {
return getNotificationGroup().createNotification(LombokBundle.message("config.warn.dependency.outdated.title"),
LombokBundle
.message("config.warn.dependency.outdated.message", project.getName(),
module.getName(), lombokVersion, Version.LAST_LOMBOK_VERSION),
LombokBundle.message("config.warn.dependency.outdated.message", project.getName(),
module.getName(), lombokVersion, Version.LAST_LOMBOK_VERSION),
NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER);
}
}
Expand All @@ -79,14 +73,6 @@ private static NotificationGroup getNotificationGroup() {
return group;
}

public static boolean hasLombokLibrary(Project project) {
ApplicationManager.getApplication().assertReadAccessAllowed();
return CachedValuesManager.getManager(project).getCachedValue(project, () -> {
PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage("lombok.experimental");
return new CachedValueProvider.Result<>(aPackage, ProjectRootManager.getInstance(project));
}) != null;
}

@Nullable
private static OrderEntry findLombokEntry(@NotNull ModuleRootManager moduleRootManager) {
final OrderEntry[] orderEntries = moduleRootManager.getOrderEntries();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import de.plushnikov.intellij.plugin.LombokClassNames;
import de.plushnikov.intellij.plugin.activity.LombokProjectValidatorActivity;
import de.plushnikov.intellij.plugin.handler.*;
import de.plushnikov.intellij.plugin.psi.LombokLightMethodBuilder;
import de.plushnikov.intellij.plugin.util.LombokLibraryUtil;
import de.plushnikov.intellij.plugin.util.PsiAnnotationSearchUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -52,7 +52,7 @@ public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile fi
}

Project project = file.getProject();
if (!LombokProjectValidatorActivity.hasLombokLibrary(project)) {
if (!LombokLibraryUtil.hasLombokLibrary(project)) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void prepareRenaming(@NotNull PsiElement element, @NotNull String newFiel
final PsiAnnotation builderAnnotation = PsiAnnotationSearchUtil.findAnnotation(containingClass, LombokClassNames.BUILDER, LombokClassNames.SUPER_BUILDER);
if (null != builderAnnotation) {
final PsiAnnotation singularAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, LombokClassNames.SINGULAR);
final BuilderElementHandler handler = SingularHandlerFactory.getHandlerFor(psiField, singularAnnotation);
final BuilderElementHandler handler = SingularHandlerFactory.getHandlerFor(psiField, null!=singularAnnotation);
final List<String> currentBuilderMethodNames = handler.getBuilderMethodNames(accessorsInfo.removePrefix(currentFieldName), singularAnnotation);
final List<String> newBuilderMethodNames = handler.getBuilderMethodNames(accessorsInfo.removePrefix(newFieldName), singularAnnotation);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package de.plushnikov.intellij.plugin.hack;

import com.sun.jna.Platform;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;

import com.sun.jna.Platform;

import static java.io.File.*;
import static java.nio.file.StandardOpenOption.*;
import static java.io.File.pathSeparator;
import static java.io.File.separator;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.WRITE;

public class AgentInjector {

static {
if (Platform.isMac()) {
final String key = "jna.library.path", home = System.getProperty("java.home"), lib = home + separator + "lib", server = lib + separator + "server";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package de.plushnikov.intellij.plugin.hack;

import org.jetbrains.annotations.Nullable;

import java.lang.instrument.Instrumentation;
import java.lang.reflect.Field;

import org.jetbrains.annotations.Nullable;

public class Injector {

private static volatile transient @Nullable Instrumentation instrumentation;
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/de/plushnikov/intellij/plugin/hack/JNI.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package de.plushnikov.intellij.plugin.hack;

import java.util.function.Function;

import com.sun.jna.Callback;
import com.sun.jna.LastErrorException;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.*;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;

import org.jetbrains.annotations.Nullable;

import java.util.function.Function;

public interface JNI extends Library {

JNI INSTANCE = Native.load("jvm", JNI.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,17 @@
package de.plushnikov.intellij.plugin.hack.extension;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.google.common.collect.MapMaker;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiArrayType;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiMethodCallExpression;
import com.intellij.psi.PsiMethodReferenceExpression;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiPrimitiveType;
import com.intellij.psi.PsiReferenceExpression;
import com.intellij.psi.PsiResolveHelper;
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypeParameter;
import com.intellij.psi.PsiTypeVisitor;
import com.intellij.psi.PsiWildcardType;
import com.intellij.psi.ResolveState;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.PsiImmediateClassType;
import com.intellij.psi.scope.ElementClassHint;
import com.intellij.psi.scope.NameHint;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.scope.processor.MethodResolverProcessor;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiTypesUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;

import com.google.common.collect.MapMaker;
import com.intellij.psi.util.*;
import de.plushnikov.intellij.plugin.LombokClassNames;
import de.plushnikov.intellij.plugin.psi.LombokLightMethodBuilder;
import de.plushnikov.intellij.plugin.psi.LombokLightParameter;
Expand All @@ -63,6 +21,12 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class ExtensionMethodHandler {

public static boolean isEnabled(@NotNull Project project) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package de.plushnikov.intellij.plugin.hack.extension;

import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.ResolveState;
import com.intellij.psi.impl.PsiClassImplUtil;
import com.intellij.psi.scope.PsiScopeProcessor;
import de.plushnikov.intellij.plugin.hack.Injector;
import org.jetbrains.org.objectweb.asm.ClassReader;
import org.jetbrains.org.objectweb.asm.ClassWriter;
import org.jetbrains.org.objectweb.asm.tree.*;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -16,24 +26,6 @@
import java.util.List;
import java.util.ListIterator;

import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.ResolveState;
import com.intellij.psi.impl.PsiClassImplUtil;
import com.intellij.psi.scope.PsiScopeProcessor;

import de.plushnikov.intellij.plugin.hack.Injector;
import org.jetbrains.org.objectweb.asm.ClassReader;
import org.jetbrains.org.objectweb.asm.ClassWriter;
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode;
import org.jetbrains.org.objectweb.asm.tree.ClassNode;
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode;
import org.jetbrains.org.objectweb.asm.tree.InsnList;
import org.jetbrains.org.objectweb.asm.tree.InsnNode;
import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode;
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
import org.jetbrains.org.objectweb.asm.tree.VarInsnNode;

import static org.jetbrains.org.objectweb.asm.Opcodes.*;

public class ExtensionMethodSupport {
Expand Down
Loading

0 comments on commit c2da4ff

Please sign in to comment.