Skip to content

Commit

Permalink
fix check style
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangtianyu committed Jun 21, 2024
1 parent 57eda28 commit d3e2d42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
import com.zhongan.devpilot.completions.autoimport.importer.DevpilotReferenceImporter;
import com.zhongan.devpilot.completions.autoimport.importer.java.DevpilotJavaReferenceImporter;


public class AutoImportHandler {

private int startOffset;
private int startOffset;

private int endOffset;
private int endOffset;

private Editor myEditor;

private PsiFile myFile;


public AutoImportHandler(int startOffset, int endOffset, Editor editor, PsiFile file) {
this.startOffset = startOffset;
this.endOffset = endOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
public class DevpilotReferenceImporter {

protected Editor myEditor;

protected PsiFile myFile;

protected int startOffset;

protected int endOffset;

protected DevpilotReferenceImporter(Editor editor, PsiFile file, int startOffset, int endOffset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;


public class DevpilotJavaReferenceImporter extends DevpilotReferenceImporter {
public DevpilotJavaReferenceImporter(Editor editor, PsiFile file, int startOffset, int endOffset) {
super(editor, file, startOffset, endOffset);
Expand Down Expand Up @@ -44,8 +43,7 @@ protected void manualImportReference() {
if (!alreadyImported) {
importLineNumber++;
}
}
else {
} else {
importLineNumber++;
}
}
Expand All @@ -70,20 +68,20 @@ protected ImportClassFixBase.Result loopManualImportReference(ImportClassFix fix
}

private List<ImportClassFix> computeImportFix(PsiFile file, int startOffset, int endOffset) {
FutureTask<List<PsiElement>> readElementTask = new FutureTask<>(() ->CollectHighlightsUtil.getElementsInRange(file, startOffset, endOffset) );
FutureTask<List<PsiElement>> readElementTask = new FutureTask<>(() -> CollectHighlightsUtil.getElementsInRange(file, startOffset, endOffset));
ApplicationManager.getApplication().runReadAction(readElementTask);
List<PsiElement> elements;
try {
elements = readElementTask.get();
} catch (Exception e){
} catch (Exception e) {
return null;
}
List<PsiElement> finalElements = elements;
FutureTask<List<ImportClassFix>> readFixTask = new FutureTask<>(() -> {
List<ImportClassFix> importFixes = new ArrayList<>();
for (PsiElement element : finalElements) {
if (element instanceof PsiJavaCodeReferenceElement) {
PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)element;
PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement) element;
ImportClassFix fix = new ImportClassFix(ref);
if (fix.isAvailable(file.getProject(), null, file)) {
importFixes.add(fix);
Expand All @@ -95,7 +93,7 @@ private List<ImportClassFix> computeImportFix(PsiFile file, int startOffset, int
ApplicationManager.getApplication().runReadAction(readFixTask);
try {
return readFixTask.get();
} catch (Exception e){
} catch (Exception e) {
return null;
}
}
Expand Down

0 comments on commit d3e2d42

Please sign in to comment.