refactor: move javapoet to separate module

This commit is contained in:
Akash Yadav
2023-03-05 23:29:39 +05:30
parent 0876524273
commit d4db2635bd
26 changed files with 67 additions and 32 deletions
+1
View File
@@ -123,6 +123,7 @@ dependencies {
implementation(projects.eventbusEvents)
implementation(projects.subprojects.aaptcompiler)
implementation(projects.subprojects.javacServices)
implementation(projects.subprojects.javapoet)
implementation(projects.subprojects.xmlUtils)
implementation(projects.subprojects.projects)
implementation(projects.subprojects.toolingApi)
Binary file not shown.
@@ -1,3 +1,20 @@
/*
* 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.androidide.utils
import android.os.Bundle
+1
View File
@@ -53,6 +53,7 @@ dependencies {
implementation(projects.lsp.api)
implementation(projects.subprojects.javac)
implementation(projects.subprojects.javacServices)
implementation(projects.subprojects.javapoet)
implementation(projects.subprojects.googleJavaFormat)
implementation(libs.androidx.ktx)
@@ -20,13 +20,10 @@ package com.itsaky.androidide.lsp.java.providers.completion
import com.itsaky.androidide.lsp.api.IServerSettings
import com.itsaky.androidide.lsp.api.describeSnippet
import com.itsaky.androidide.lsp.java.compiler.CompileTask
import com.itsaky.androidide.lsp.java.compiler.CompilerProvider
import com.itsaky.androidide.lsp.java.compiler.JavaCompilerService
import com.itsaky.androidide.lsp.java.edits.MultipleClassImportEditHandler
import com.itsaky.androidide.lsp.java.parser.ParseTask
import com.itsaky.androidide.lsp.java.utils.EditHelper
import com.itsaky.androidide.lsp.java.utils.EditHelper.repeatSpaces
import com.itsaky.androidide.lsp.java.utils.FindHelper
import com.itsaky.androidide.lsp.java.utils.JavaPoetUtils.Companion.buildMethod
import com.itsaky.androidide.lsp.java.utils.JavaPoetUtils.Companion.print
import com.itsaky.androidide.lsp.java.utils.ScopeHelper
@@ -38,22 +35,18 @@ import com.itsaky.androidide.lsp.models.MatchLevel.NO_MATCH
import com.itsaky.androidide.progress.ProgressManager.Companion.abortIfCancelled
import com.itsaky.androidide.projects.FileManager
import com.squareup.javapoet.MethodSpec.Builder
import openjdk.source.tree.ClassTree
import openjdk.source.tree.MethodTree
import openjdk.source.tree.Tree.Kind.CLASS
import openjdk.source.util.TreePath
import openjdk.source.util.Trees
import java.nio.file.Path
import java.util.*
import java.util.function.*
import java.util.function.Predicate
import jdkx.lang.model.element.ElementKind.METHOD
import jdkx.lang.model.element.ExecutableElement
import jdkx.lang.model.element.Modifier.FINAL
import jdkx.lang.model.element.Modifier.PRIVATE
import jdkx.lang.model.element.Modifier.STATIC
import jdkx.lang.model.element.TypeElement
import jdkx.lang.model.type.DeclaredType
import jdkx.tools.JavaFileObject
import openjdk.source.tree.ClassTree
import openjdk.source.tree.Tree.Kind.CLASS
import openjdk.source.util.TreePath
import openjdk.source.util.Trees
/**
* Provides completions using [openjdk.source.tree.Scope].
@@ -162,8 +155,7 @@ class ScopeCompletionProvider(
// Print the method details and the annotations
// Print the method details and the annotations
val indent =
EditHelper.indent(FileManager.getDocumentContents(file), cursor.toInt())
val indent = EditHelper.indent(FileManager.getDocumentContents(file), cursor.toInt())
val builder: Builder
try {
builder = buildMethod(method, types, type)
@@ -195,8 +187,7 @@ class ScopeCompletionProvider(
}
imports.removeIf { "java.lang." == it || fileImports.contains(it) || filePackage == it }
item.additionalEditHandler =
MultipleClassImportEditHandler(imports, fileImports, file)
item.additionalEditHandler = MultipleClassImportEditHandler(imports, fileImports, file)
return item
}
}
+4 -3
View File
@@ -73,12 +73,13 @@ include(
":subprojects:framework-stubs",
":subprojects:fuzzysearch",
":subprojects:google-java-format",
":subprojects:jdk-compiler",
":subprojects:jdk-jdeps",
":subprojects:java-compiler",
":subprojects:javac",
":subprojects:javac-services",
":subprojects:java-compiler",
":subprojects:javapoet",
":subprojects:jaxp",
":subprojects:jdk-compiler",
":subprojects:jdk-jdeps",
":subprojects:jdt",
":subprojects:layoutlib-api",
":subprojects:projects",
+1
View File
@@ -0,0 +1 @@
/build
+24
View File
@@ -0,0 +1,24 @@
/*
* 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/>.
*/
plugins {
kotlin("jvm")
}
dependencies {
implementation(projects.subprojects.javaCompiler)
}
@@ -17,13 +17,12 @@
package com.squareup.javapoet;
import androidx.annotation.NonNull;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.jetbrains.annotations.NotNull;
/**
* A code writer implementation which is used by {@link TypeName} to provide list of classes that
@@ -65,7 +64,7 @@ public class ImportCollectingCodeWriter extends CodeWriter {
this.importClasses.add(qualifiedName);
}
@NonNull
@NotNull
public Set<String> getImportClasses() {
return importClasses;
}
@@ -74,43 +73,43 @@ public class ImportCollectingCodeWriter extends CodeWriter {
emit("$L", annotationSpec);
}
public void emit(@NonNull ArrayTypeName arrayTypeName) throws IOException {
public void emit(@NotNull ArrayTypeName arrayTypeName) throws IOException {
arrayTypeName.emit(this);
}
public void emit(@NonNull ClassName className) throws IOException {
public void emit(@NotNull ClassName className) throws IOException {
className.emit(this);
}
public void emit(@NonNull FieldSpec field) throws IOException {
public void emit(@NotNull FieldSpec field) throws IOException {
field.emit(this, Collections.emptySet());
}
public void emit(@NonNull MethodSpec methodSpec) throws IOException {
public void emit(@NotNull MethodSpec methodSpec) throws IOException {
methodSpec.emit(this, "Constructor", Collections.emptySet());
}
public void emit(@NonNull ParameterizedTypeName parameterizedTypeName) throws IOException {
public void emit(@NotNull ParameterizedTypeName parameterizedTypeName) throws IOException {
parameterizedTypeName.emit(this);
}
public void emit(@NonNull ParameterSpec parameterSpec) throws IOException {
public void emit(@NotNull ParameterSpec parameterSpec) throws IOException {
parameterSpec.emit(this, false);
}
public void emit(@NonNull TypeName typeName) throws IOException {
public void emit(@NotNull TypeName typeName) throws IOException {
typeName.emit(this);
}
public void emit(@NonNull TypeSpec typeSpec) throws IOException {
public void emit(@NotNull TypeSpec typeSpec) throws IOException {
typeSpec.emit(this, null, Collections.emptySet());
}
public void emit(@NonNull TypeVariableName typeVariableName) throws IOException {
public void emit(@NotNull TypeVariableName typeVariableName) throws IOException {
typeVariableName.emit(this);
}
public void emit(@NonNull WildcardTypeName wildcardTypeName) throws IOException {
public void emit(@NotNull WildcardTypeName wildcardTypeName) throws IOException {
wildcardTypeName.emit(this);
}
}