mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
[java-intentions] More preview tests; minor fixes
GitOrigin-RevId: 22a46c15d8900d8a31514846755a013f6a67ad42
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e74564a52c
commit
7e1064ea3c
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.ReturnStatementsVisitor;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
@@ -41,8 +42,9 @@ class ConvertReturnStatementsVisitor implements ReturnStatementsVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(final List<PsiReturnStatement> returnStatements) throws IncorrectOperationException {
|
||||
final PsiReturnStatement statement =
|
||||
WriteAction.compute(() -> replaceReturnStatements(returnStatements));
|
||||
final PsiReturnStatement statement = myMethod.isPhysical()
|
||||
? WriteAction.compute(() -> replaceReturnStatements(returnStatements))
|
||||
: replaceReturnStatements(returnStatements);
|
||||
if (statement != null) {
|
||||
myLatestReturn = statement;
|
||||
}
|
||||
@@ -58,14 +60,15 @@ class ConvertReturnStatementsVisitor implements ReturnStatementsVisitor {
|
||||
}
|
||||
|
||||
public PsiReturnStatement createReturnInLastStatement() throws IncorrectOperationException {
|
||||
return WriteAction.compute(() -> {
|
||||
ThrowableComputable<PsiReturnStatement, RuntimeException> action = () -> {
|
||||
PsiCodeBlock body = myMethod.getBody();
|
||||
PsiJavaToken rBrace = body.getRBrace();
|
||||
if (rBrace == null) return null;
|
||||
final String value = generateValue(rBrace);
|
||||
PsiReturnStatement returnStatement = (PsiReturnStatement)myFactory.createStatementFromText("return " + value + ";", myMethod);
|
||||
return (PsiReturnStatement)body.addBefore(returnStatement, rBrace);
|
||||
});
|
||||
};
|
||||
return myMethod.isPhysical() ? WriteAction.compute(action) : action.compute();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.controlFlow.AnalysisCanceledException;
|
||||
import com.intellij.psi.controlFlow.ControlFlow;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
@@ -80,9 +81,7 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
myFixWholeHierarchy = fixWholeHierarchy;
|
||||
mySuggestSuperTypes = suggestSuperTypes;
|
||||
myName = method.getName();
|
||||
if (TypeConversionUtil.isNullType(returnType)) {
|
||||
returnType = PsiType.getJavaLangObject(method.getManager(), method.getResolveScope());
|
||||
}
|
||||
returnType = correctType(method, returnType);
|
||||
if (fixWholeHierarchy) {
|
||||
PsiType type = getHierarchyAdjustedReturnType(method, returnType);
|
||||
myCanonicalText = (type != null ? type : returnType).getCanonicalText();
|
||||
@@ -92,6 +91,13 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
}
|
||||
}
|
||||
|
||||
private static @NotNull PsiType correctType(@NotNull PsiMethod method, @NotNull PsiType returnType) {
|
||||
if (TypeConversionUtil.isNullType(returnType)) {
|
||||
returnType = PsiType.getJavaLangObject(method.getManager(), method.getResolveScope());
|
||||
}
|
||||
return returnType;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -464,10 +470,15 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
return IntentionPreviewInfo.EMPTY;
|
||||
}
|
||||
PsiMethod method = (PsiMethod)getStartElement();
|
||||
type = correctType(method, type);
|
||||
PsiFile containingFile = method.getContainingFile();
|
||||
if (containingFile == file.getOriginalFile()) {
|
||||
PsiMethod methodCopy = PsiTreeUtil.findSameElementInCopy(method, file);
|
||||
updateMethodType(methodCopy, type);
|
||||
if (!PsiType.VOID.equals(type)) {
|
||||
ReturnStatementAdder adder = new ReturnStatementAdder(JavaPsiFacade.getElementFactory(project), type);
|
||||
adder.addReturnForMethod(file, methodCopy);
|
||||
}
|
||||
return IntentionPreviewInfo.DIFF;
|
||||
}
|
||||
PsiModifierList modifiers = method.getModifierList();
|
||||
@@ -486,8 +497,12 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
|
||||
protected void updateMethodType(@NotNull PsiMethod method, @NotNull PsiType type) {
|
||||
PsiTypeElement typeElement = method.getReturnTypeElement();
|
||||
Project project = method.getProject();
|
||||
if (typeElement != null) {
|
||||
typeElement.replace(PsiElementFactory.getInstance(method.getProject()).createTypeElement(type));
|
||||
JavaCodeStyleManager.getInstance(project)
|
||||
.shortenClassReferences(typeElement.replace(PsiElementFactory.getInstance(project).createTypeElement(type)));
|
||||
} else {
|
||||
addReturnType(project, method, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableUtil.RemoveMode;
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
|
||||
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
|
||||
import com.intellij.codeInspection.CommonQuickFixBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -27,10 +29,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.JavaElementKind;
|
||||
import com.intellij.psi.util.PsiExpressionTrimRenderer;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -73,30 +72,35 @@ public class RemoveUnusedVariableFix implements IntentionAction {
|
||||
removeVariableAndReferencingStatements(editor);
|
||||
}
|
||||
|
||||
private void removeVariableAndReferencingStatements(Editor editor) {
|
||||
final List<PsiElement> references = new ArrayList<>();
|
||||
@Override
|
||||
public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
|
||||
PsiVariable variable = PsiTreeUtil.findSameElementInCopy(myVariable, file);
|
||||
List<PsiElement> references = collectReferences(variable);
|
||||
// check for side effects
|
||||
final List<PsiElement> sideEffects = new ArrayList<>();
|
||||
final boolean[] canCopeWithSideEffects = {true};
|
||||
try {
|
||||
PsiElement context = myVariable instanceof PsiField ? ((PsiField)myVariable).getContainingClass() : PsiUtil.getVariableCodeBlock(myVariable, null);
|
||||
if (context != null) {
|
||||
RemoveUnusedVariableUtil.collectReferences(context, myVariable, references);
|
||||
}
|
||||
// do not forget to delete variable declaration
|
||||
references.add(myVariable);
|
||||
// check for side effects
|
||||
for (PsiElement element : references) {
|
||||
Boolean result = RemoveUnusedVariableUtil.processUsage(element, myVariable, sideEffects, RemoveUnusedVariableUtil.RemoveMode.CANCEL);
|
||||
if (result == null) return;
|
||||
canCopeWithSideEffects[0] &= result;
|
||||
}
|
||||
boolean canCopeWithSideEffects = true;
|
||||
for (PsiElement element : references) {
|
||||
Boolean result = RemoveUnusedVariableUtil.processUsage(element, variable, sideEffects, RemoveMode.CANCEL);
|
||||
if (result == null) return IntentionPreviewInfo.EMPTY;
|
||||
canCopeWithSideEffects &= result;
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
RemoveMode mode = canCopeWithSideEffects && !sideEffects.isEmpty() ? RemoveMode.MAKE_STATEMENT : RemoveMode.DELETE_ALL;
|
||||
RemoveUnusedVariableUtil.deleteReferences(variable, references, mode);
|
||||
return IntentionPreviewInfo.DIFF;
|
||||
}
|
||||
|
||||
private void removeVariableAndReferencingStatements(Editor editor) {
|
||||
final List<PsiElement> references = collectReferences(myVariable);
|
||||
final List<PsiElement> sideEffects = new ArrayList<>();
|
||||
boolean canCopeWithSideEffects = true;
|
||||
// check for side effects
|
||||
for (PsiElement element : references) {
|
||||
Boolean result = RemoveUnusedVariableUtil.processUsage(element, myVariable, sideEffects, RemoveMode.CANCEL);
|
||||
if (result == null) return;
|
||||
canCopeWithSideEffects &= result;
|
||||
}
|
||||
|
||||
final RemoveUnusedVariableUtil.RemoveMode
|
||||
deleteMode = showSideEffectsWarning(sideEffects, myVariable, editor, canCopeWithSideEffects[0]);
|
||||
final RemoveMode deleteMode = showSideEffectsWarning(sideEffects, myVariable, editor, canCopeWithSideEffects);
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
try {
|
||||
@@ -108,17 +112,26 @@ public class RemoveUnusedVariableFix implements IntentionAction {
|
||||
});
|
||||
}
|
||||
|
||||
public static RemoveUnusedVariableUtil.RemoveMode showSideEffectsWarning(List<? extends PsiElement> sideEffects,
|
||||
private static List<PsiElement> collectReferences(@NotNull PsiVariable variable) {
|
||||
List<PsiElement> references = new ArrayList<>();
|
||||
PsiElement context = variable instanceof PsiField ? ((PsiField)variable).getContainingClass() : PsiUtil.getVariableCodeBlock(variable, null);
|
||||
if (context != null) {
|
||||
RemoveUnusedVariableUtil.collectReferences(context, variable, references);
|
||||
}
|
||||
// do not forget to delete variable declaration
|
||||
references.add(variable);
|
||||
return references;
|
||||
}
|
||||
|
||||
public static RemoveMode showSideEffectsWarning(List<? extends PsiElement> sideEffects,
|
||||
PsiVariable variable,
|
||||
Editor editor,
|
||||
boolean canCopeWithSideEffects,
|
||||
@NonNls String beforeText,
|
||||
@NonNls String afterText) {
|
||||
if (sideEffects.isEmpty()) return RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL;
|
||||
if (sideEffects.isEmpty()) return RemoveMode.DELETE_ALL;
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return canCopeWithSideEffects
|
||||
? RemoveUnusedVariableUtil.RemoveMode.MAKE_STATEMENT
|
||||
: RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL;
|
||||
return canCopeWithSideEffects ? RemoveMode.MAKE_STATEMENT : RemoveMode.DELETE_ALL;
|
||||
}
|
||||
Project project = editor.getProject();
|
||||
HighlightManager highlightManager = HighlightManager.getInstance(project);
|
||||
@@ -128,10 +141,10 @@ public class RemoveUnusedVariableFix implements IntentionAction {
|
||||
SideEffectWarningDialog dialog = new SideEffectWarningDialog(project, false, variable, beforeText, afterText, canCopeWithSideEffects);
|
||||
dialog.show();
|
||||
int code = dialog.getExitCode();
|
||||
return RemoveUnusedVariableUtil.RemoveMode.values()[code];
|
||||
return RemoveMode.values()[code];
|
||||
}
|
||||
|
||||
private static RemoveUnusedVariableUtil.RemoveMode showSideEffectsWarning(List<? extends PsiElement> sideEffects,
|
||||
private static RemoveMode showSideEffectsWarning(List<? extends PsiElement> sideEffects,
|
||||
PsiVariable variable,
|
||||
Editor editor,
|
||||
boolean canCopeWithSideEffects) {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
// Copyright 2000-2021 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.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil;
|
||||
import com.intellij.codeInsight.intention.FileModifier;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -27,6 +26,7 @@ import com.intellij.util.CommonJavaRefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -49,6 +49,18 @@ public class VariableAccessFromInnerClassFix implements IntentionAction {
|
||||
getVariablesToFix().add(variable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FileModifier getFileModifierForPreview(@NotNull PsiFile target) {
|
||||
PsiElement context = PsiTreeUtil.findSameElementInCopy(myContext, target);
|
||||
VariableAccessFromInnerClassFix fix = new VariableAccessFromInnerClassFix(
|
||||
PsiTreeUtil.findSameElementInCopy(myVariable, target), context);
|
||||
Collection<PsiVariable> targetVars = fix.getVariablesToFix();
|
||||
for (PsiVariable sourceVar : getVariablesToFix()) {
|
||||
targetVars.add(PsiTreeUtil.findSameElementInCopy(sourceVar, target));
|
||||
}
|
||||
return fix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
@@ -90,28 +102,25 @@ public class VariableAccessFromInnerClassFix implements IntentionAction {
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(myContext, myVariable)) return;
|
||||
WriteAction.run(() -> {
|
||||
try {
|
||||
switch (myFixType) {
|
||||
case MAKE_FINAL:
|
||||
makeFinal();
|
||||
break;
|
||||
case MAKE_ARRAY:
|
||||
makeArray();
|
||||
break;
|
||||
case COPY_TO_FINAL:
|
||||
copyToFinal(myVariable, myContext);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
switch (myFixType) {
|
||||
case MAKE_FINAL:
|
||||
makeFinal();
|
||||
break;
|
||||
case MAKE_ARRAY:
|
||||
makeArray();
|
||||
break;
|
||||
case COPY_TO_FINAL:
|
||||
copyToFinal(myVariable, myContext);
|
||||
break;
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
finally {
|
||||
getVariablesToFix().clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
finally {
|
||||
getVariablesToFix().clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void makeArray() {
|
||||
@@ -163,20 +172,20 @@ public class VariableAccessFromInnerClassFix implements IntentionAction {
|
||||
|
||||
PsiDeclarationStatement variableDeclarationStatement;
|
||||
PsiExpression initializer = variable.getInitializer();
|
||||
PsiExpression init;
|
||||
if (initializer == null) {
|
||||
String expression = "[1]";
|
||||
StringBuilder expression = new StringBuilder("[1]");
|
||||
while (type instanceof PsiArrayType) {
|
||||
expression += "[1]";
|
||||
expression.append("[1]");
|
||||
type = ((PsiArrayType) type).getComponentType();
|
||||
}
|
||||
PsiExpression init = factory.createExpressionFromText("new " + type.getCanonicalText() + expression, variable);
|
||||
variableDeclarationStatement = factory.createVariableDeclarationStatement(variable.getName(), newType, init);
|
||||
init = factory.createExpressionFromText("new " + type.getCanonicalText() + expression, variable);
|
||||
}
|
||||
else {
|
||||
String explicitArrayDeclaration = JavaGenericsUtil.isReifiableType(type) ? "" : "new " + TypeConversionUtil.erasure(type).getCanonicalText() + "[]";
|
||||
PsiExpression init = factory.createExpressionFromText(explicitArrayDeclaration + "{ " + initializer.getText() + " }", variable);
|
||||
variableDeclarationStatement = factory.createVariableDeclarationStatement(variable.getName(), newType, init);
|
||||
init = factory.createExpressionFromText(explicitArrayDeclaration + "{ " + initializer.getText() + " }", variable);
|
||||
}
|
||||
variableDeclarationStatement = factory.createVariableDeclarationStatement(variable.getName(), newType, init);
|
||||
PsiVariable newVariable = (PsiVariable)variableDeclarationStatement.getDeclaredElements()[0];
|
||||
PsiUtil.setModifierProperty(newVariable, PsiModifier.FINAL, true);
|
||||
PsiElement newExpression = factory.createExpressionFromText(variable.getName() + "[0]", variable);
|
||||
@@ -347,7 +356,7 @@ public class VariableAccessFromInnerClassFix implements IntentionAction {
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void fixAccess(@NotNull PsiVariable variable, @NotNull PsiElement context) {
|
||||
|
||||
@@ -116,7 +116,7 @@ public class JavadocBlankLinesInspection extends LocalInspectionTool {
|
||||
@Nullable Editor editor,
|
||||
@NotNull PsiElement startElement,
|
||||
@NotNull PsiElement endElement) {
|
||||
Document document = PsiDocumentManager.getInstance(project).getDocument(file);
|
||||
Document document = file.getViewProvider().getDocument();
|
||||
if (document == null) return;
|
||||
TextRange range = startElement.getTextRange();
|
||||
document.replaceString(range.getStartOffset(), range.getEndOffset(), "* <p>");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newOutputStream()'" "true"
|
||||
// "Replace with 'Files.newOutputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newOutputStream()'" "true"
|
||||
// "Replace with 'Files.newOutputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newInputStream()'" "true"
|
||||
// "Replace with 'Files.newInputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newOutputStream()'" "true"
|
||||
// "Replace with 'Files.newOutputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'Files.newOutputStream()'" "true"
|
||||
// "Replace with 'Files.newOutputStream()'" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Call 'toArray(new String[0])'" "true"
|
||||
// "Call 'toArray(new String[0])'" "true-preview"
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Call 'toArray(new String[0])'" "true"
|
||||
// "Call 'toArray(new String[0])'" "true-preview"
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Call 'toArray(new X[0])'" "true"
|
||||
// "Call 'toArray(new X[0])'" "true-preview"
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Call 'toArray(new String[0])'" "true"
|
||||
// "Call 'toArray(new String[0])'" "true-preview"
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Call 'toArray(new String[0])'" "true"
|
||||
// "Call 'toArray(new String[0])'" "true-preview"
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Call 'toArray(new X[0])'" "true"
|
||||
// "Call 'toArray(new X[0])'" "true-preview"
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
// "Iterate over Annotation[]" "true"
|
||||
// "Iterate over Annotation[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
for (Annotation annotation : getClass().getAnnotations()) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
// "Iterate over Annotation[]" "true"
|
||||
// "Iterate over Annotation[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
for (Annotation annotation : getClass().getAnnotations()) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Iterate over String[]" "true"
|
||||
// "Iterate over String[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
for (String s : new String[]{"a", "b", "c"}) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Iterate over Annotation[]" "true"
|
||||
// "Iterate over Annotation[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
getClass().getAnnotatio<caret>ns();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Iterate over Annotation[]" "true"
|
||||
// "Iterate over Annotation[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
getClass().getAnnotations()<caret>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Iterate over String[]" "true"
|
||||
// "Iterate over String[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
new String<caret>[] {"a", "b", "c"};
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
// "Iterate over Annotation[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
for (Annotation annotation : getClass().getAnnotations()) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
// "Iterate over Annotation[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
for (Annotation annotation : getClass().getAnnotations()) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Iterate over String[]" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
for (String s : new String[]{"a", "b", "c"}) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Insert <p>" "true"
|
||||
// "Insert <p>" "true-preview"
|
||||
class Test {
|
||||
/**
|
||||
* Doesn't do anything.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Insert <p>" "true"
|
||||
// "Insert <p>" "true-preview"
|
||||
class Test {
|
||||
/**
|
||||
* Doesn't do anything.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace URL with HTML link" "true"
|
||||
// "Replace URL with HTML link" "true-preview"
|
||||
|
||||
/**
|
||||
* abc <a href="https://en.wikipedia.org/"><caret><selection>...</selection></a> def
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace URL with HTML link" "true"
|
||||
// "Replace URL with HTML link" "true-preview"
|
||||
|
||||
/**
|
||||
* abc https://en.wikipedia.org/<caret> def
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add tag @throws java.lang.Exception" "true"
|
||||
// "Add tag @throws java.lang.Exception" "true-preview"
|
||||
public class a {
|
||||
/**
|
||||
* @throws Exception
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add tag @param for parameter 'a'" "true"
|
||||
// "Add tag @param for parameter 'a'" "true-preview"
|
||||
public class a {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add tag @param <T>" "true"
|
||||
// "Add tag @param <T>" "true-preview"
|
||||
/**
|
||||
* @param <T>
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace '@Override' with '{@code @Override}'" "true"
|
||||
// "Replace '@Override' with '{@code @Override}'" "true-preview"
|
||||
|
||||
class Foo {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace '@Override' with '@Override'" "true"
|
||||
// "Replace '@Override' with '@Override'" "true-preview"
|
||||
|
||||
class Foo {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace URL with HTML link" "true"
|
||||
// "Replace URL with HTML link" "true-preview"
|
||||
|
||||
/**
|
||||
* @see <a href="https://www.nowhere.net"><caret><selection>here you go</selection></a>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace URL with HTML link" "true"
|
||||
// "Replace URL with HTML link" "true-preview"
|
||||
|
||||
/**
|
||||
* @see <a href="https://www.nowhere.net"><caret><selection>...</selection></a>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add tag @param <T>" "true"
|
||||
// "Add tag @param <T>" "true-preview"
|
||||
public class a {
|
||||
/**
|
||||
* @param <T>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add tag @throws java.lang.Exception" "true"
|
||||
// "Add tag @throws java.lang.Exception" "true-preview"
|
||||
public class a {
|
||||
/**<caret>
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add tag @param for parameter 'a'" "true"
|
||||
// "Add tag @param for parameter 'a'" "true-preview"
|
||||
public class a {
|
||||
|
||||
/**<caret>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add tag @param <T>" "true"
|
||||
// "Add tag @param <T>" "true-preview"
|
||||
/**<caret>
|
||||
*/
|
||||
public class a<T> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace '@Override' with '{@code @Override}'" "true"
|
||||
// "Replace '@Override' with '{@code @Override}'" "true-preview"
|
||||
|
||||
class Foo {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace '@Override' with '@Override'" "true"
|
||||
// "Replace '@Override' with '@Override'" "true-preview"
|
||||
|
||||
class Foo {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace URL with HTML link" "true"
|
||||
// "Replace URL with HTML link" "true-preview"
|
||||
|
||||
/**
|
||||
* @see <caret>https://www.nowhere.net here you go
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace URL with HTML link" "true"
|
||||
// "Replace URL with HTML link" "true-preview"
|
||||
|
||||
/**
|
||||
* @see <caret>https://www.nowhere.net
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add tag @param <T>" "true"
|
||||
// "Add tag @param <T>" "true-preview"
|
||||
public class a {
|
||||
/**<caret>
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Predicate.isEqual()'" "true"
|
||||
// "Replace lambda expression with 'Predicate.isEqual()'" "true-preview"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "true"
|
||||
// "Replace lambda expression with 'Function.identity()'" "true-preview"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "true"
|
||||
// "Replace lambda expression with 'Function.identity()'" "true-preview"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Scratch {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "true"
|
||||
// "Replace lambda expression with 'Function.identity()'" "true-preview"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Scratch {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Pattern.negate()'" "true"
|
||||
// "Replace lambda expression with 'Pattern.negate()'" "true-preview"
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Main {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Pattern.negate()'" "true"
|
||||
// "Replace lambda expression with 'Pattern.negate()'" "true-preview"
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Main {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Pattern.asPredicate()'" "true"
|
||||
// "Replace lambda expression with 'Pattern.asPredicate()'" "true-preview"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Pattern.asMatchPredicate()'" "true"
|
||||
// "Replace lambda expression with 'Pattern.asMatchPredicate()'" "true-preview"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Predicate.isEqual()'" "true"
|
||||
// "Replace lambda expression with 'Predicate.isEqual()'" "true-preview"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "true"
|
||||
// "Replace lambda expression with 'Function.identity()'" "true-preview"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "true"
|
||||
// "Replace lambda expression with 'Function.identity()'" "true-preview"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Scratch {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Function.identity()'" "true"
|
||||
// "Replace lambda expression with 'Function.identity()'" "true-preview"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Scratch {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Pattern.negate()'" "true"
|
||||
// "Replace lambda expression with 'Pattern.negate()'" "true-preview"
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Main {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Pattern.negate()'" "true"
|
||||
// "Replace lambda expression with 'Pattern.negate()'" "true-preview"
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Main {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Pattern.asPredicate()'" "true"
|
||||
// "Replace lambda expression with 'Pattern.asPredicate()'" "true-preview"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda expression with 'Pattern.asMatchPredicate()'" "true"
|
||||
// "Replace lambda expression with 'Pattern.asMatchPredicate()'" "true-preview"
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
class Bar extends Random {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
class Bar extends Random {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
interface I {
|
||||
String foo(Foo i);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
interface I {
|
||||
String foo(Foo i);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
interface I {
|
||||
String foo(Foo i);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
import java.io.PrintStream;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
class Example {
|
||||
interface I {
|
||||
String foo(Integer i);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
class Example {
|
||||
static void foo() {
|
||||
Ar<String> a = String[]::new;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
class Example {
|
||||
{
|
||||
long[][] avg = collect(long[][]::new);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
class Example {
|
||||
static void foo() {
|
||||
Ar<String> a = String[]::clone;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Bar extends Random {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Bar extends Random {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
class Example {
|
||||
public void m() {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
class StaticInner {
|
||||
|
||||
static class Inner {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
class MyTest2<X> {
|
||||
MyTest2(X x) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "true-preview"
|
||||
class NonStaticInner3 {
|
||||
class Foo {
|
||||
Foo(Integer i) {}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user