mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
Removed the 'Generate setters/getters' rewrite
This commit is contained in:
@@ -36,8 +36,6 @@ package com.itsaky.lsp.java.actions;
|
||||
|
||||
import static com.itsaky.androidide.utils.Logger.newInstance;
|
||||
import static com.itsaky.lsp.java.utils.CodeActionUtils.createQuickFix;
|
||||
import static com.itsaky.lsp.java.utils.CodeActionUtils.isBlankLine;
|
||||
import static com.itsaky.lsp.java.utils.CodeActionUtils.isInMethod;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -45,22 +43,17 @@ import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.lsp.java.compiler.CompileTask;
|
||||
import com.itsaky.lsp.java.compiler.CompilerProvider;
|
||||
import com.itsaky.lsp.java.compiler.SynchronizedTask;
|
||||
import com.itsaky.lsp.java.rewrite.GenerateSettersAndGetters;
|
||||
import com.itsaky.lsp.java.rewrite.OverrideInheritedMethod;
|
||||
import com.itsaky.lsp.java.rewrite.Rewrite;
|
||||
import com.itsaky.lsp.java.utils.MethodPtr;
|
||||
import com.itsaky.lsp.java.visitors.FindTypeDeclarationAt;
|
||||
import com.itsaky.lsp.java.visitors.FindVariablesBetween;
|
||||
import com.itsaky.lsp.models.CodeActionItem;
|
||||
import com.itsaky.lsp.models.DiagnosticItem;
|
||||
import com.itsaky.lsp.models.Range;
|
||||
import com.sun.source.tree.ClassTree;
|
||||
import com.sun.source.tree.LineMap;
|
||||
import com.sun.source.util.TreePath;
|
||||
import com.sun.source.util.Trees;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
@@ -88,10 +81,8 @@ public class CursorCodeActionProvider {
|
||||
private static final Logger LOG = newInstance("JavaCursorCodeActionProvider");
|
||||
|
||||
@NonNull
|
||||
public List<CodeActionItem> provideActions (
|
||||
@NonNull CompilerProvider compiler,
|
||||
@NonNull Path file,
|
||||
@NonNull Range range) {
|
||||
public List<CodeActionItem> provideActions(
|
||||
@NonNull CompilerProvider compiler, @NonNull Path file, @NonNull Range range) {
|
||||
logStarted(file, range);
|
||||
|
||||
Instant started = Instant.now();
|
||||
@@ -131,14 +122,6 @@ public class CursorCodeActionProvider {
|
||||
return actions;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Contract(pure = true)
|
||||
private Map<String, ? extends Rewrite> createSettersAndGetters(
|
||||
@NonNull Path file, CompileTask task, List<TreePath> variables) {
|
||||
return Collections.singletonMap(
|
||||
"Create setters/getters", new GenerateSettersAndGetters(file, variables));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private List<TreePath> findVariables(@NonNull CompileTask task, long start, long end) {
|
||||
final FindVariablesBetween scanner = new FindVariablesBetween(task.task, start, end);
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* This file is part of AndroidIDE.
|
||||
*
|
||||
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* AndroidIDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.itsaky.lsp.java.rewrite;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.lsp.java.compiler.CompileTask;
|
||||
import com.itsaky.lsp.java.compiler.CompilerProvider;
|
||||
import com.itsaky.lsp.java.utils.EditHelper;
|
||||
import com.itsaky.lsp.java.utils.JavaPoetUtils;
|
||||
import com.itsaky.lsp.models.CodeActionItem;
|
||||
import com.itsaky.lsp.models.Command;
|
||||
import com.itsaky.lsp.models.Position;
|
||||
import com.itsaky.lsp.models.Range;
|
||||
import com.itsaky.lsp.models.TextEdit;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.TypeName;
|
||||
import com.sun.source.tree.Tree;
|
||||
import com.sun.source.util.TreePath;
|
||||
import com.sun.source.util.Trees;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
|
||||
/**
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class GenerateSettersAndGetters extends Rewrite {
|
||||
|
||||
private final Path file;
|
||||
private final List<TreePath> variables;
|
||||
|
||||
public GenerateSettersAndGetters(Path file, List<TreePath> variables) {
|
||||
Objects.requireNonNull(variables);
|
||||
|
||||
this.file = file;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Path, TextEdit[]> rewrite(CompilerProvider compiler) {
|
||||
final List<TextEdit> edits = new ArrayList<>();
|
||||
return compiler.compile(file)
|
||||
.get(
|
||||
task -> {
|
||||
final Trees trees = Trees.instance(task.task);
|
||||
|
||||
|
||||
return Collections.singletonMap(file, edits.toArray(new TextEdit[0]));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommands(@NonNull CodeActionItem action) {
|
||||
action.setCommand(new Command("Format code", Command.FORMAT_CODE));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user