Skip to content

Commit

Permalink
Easily generate all-quarkus-properties.json
Browse files Browse the repository at this point in the history
Fixes redhat-developer#182

Signed-off-by: azerr <azerr@redhat.com>
  • Loading branch information
angelozerr committed Jan 21, 2020
1 parent 63364fa commit f8752dd
Show file tree
Hide file tree
Showing 12 changed files with 15,516 additions and 12,569 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ public MicroProfileProjectInfo getMicroProfileProjectInfo(IJavaProject javaProje
* the search.
* @throws JavaModelException
*/
private IJavaProject configureSearchClasspath(IJavaProject javaProject, boolean excludeTestCode,
SubMonitor mainMonitor) throws JavaModelException {
public IJavaProject configureSearchClasspath(IJavaProject javaProject, boolean excludeTestCode,
IProgressMonitor monitor) throws JavaModelException {
SubMonitor mainMonitor = SubMonitor.convert(monitor);
// Get the java project used for the search
mainMonitor.subTask("Configuring search classpath");
int length = getPropertiesProviders().size();
Expand Down Expand Up @@ -276,6 +277,10 @@ private IJavaSearchScope createSearchScope(IJavaProject project, List<MicroProfi
*/
private IJavaProject getJavaProject(IJavaProject javaProject, boolean excludeTestCode, SubMonitor monitor)
throws JavaModelException {
if (javaProject instanceof FakeJavaProject) {
// The java project is already resolved
return javaProject;
}
int length = getPropertiesProviders().size();
SubMonitor mainMonitor = monitor;
IClasspathEntry[] resolvedClasspath = ((JavaProject) javaProject).getResolvedClasspath();
Expand Down Expand Up @@ -382,13 +387,15 @@ public Location findPropertyLocation(MicroProfilePropertyDefinitionParams params
if (file == null) {
throw new UnsupportedOperationException(String.format("Cannot find IFile for '%s'", params.getUri()));
}
return findPropertyLocation(file, params.getSourceType(), params.getSourceField(), params.getSourceMethod(),
utils, progress);
String projectName = file.getProject().getName();
IJavaProject javaProject = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(projectName);
return findPropertyLocation(javaProject, params.getSourceType(), params.getSourceField(),
params.getSourceMethod(), utils, progress);
}

public Location findPropertyLocation(IFile file, String sourceType, String sourceField, String sourceMethod,
IJDTUtils utils, IProgressMonitor progress) throws JavaModelException, CoreException {
IMember fieldOrMethod = findDeclaredProperty(file, sourceType, sourceField, sourceMethod, progress);
public Location findPropertyLocation(IJavaProject javaProject, String sourceType, String sourceField,
String sourceMethod, IJDTUtils utils, IProgressMonitor progress) throws JavaModelException, CoreException {
IMember fieldOrMethod = findDeclaredProperty(javaProject, sourceType, sourceField, sourceMethod, progress);
if (fieldOrMethod != null) {
IClassFile classFile = fieldOrMethod.getClassFile();
if (classFile != null) {
Expand All @@ -402,25 +409,6 @@ public Location findPropertyLocation(IFile file, String sourceType, String sourc
return null;
}

/**
* Returns the Java field from the given property source
*
* @param file the application.properties file
* @param sourceType the source type (class or interface)
* @param sourceField the source field and null otherwise.
* @param sourceMethod the source method and null otherwise.
* @param progress the progress monitor.
* @return the Java field from the given property source
* @throws JavaModelException
* @throws CoreException
*/
public IMember findDeclaredProperty(IFile file, String sourceType, String sourceField, String sourceMethod,
IProgressMonitor progress) throws JavaModelException, CoreException {
String projectName = file.getProject().getName();
IJavaProject javaProject = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(projectName);
return findDeclaredProperty(javaProject, sourceType, sourceField, sourceMethod, progress);
}

/**
* Returns the Java field from the given property source
*
Expand All @@ -440,6 +428,11 @@ public IMember findDeclaredProperty(IJavaProject javaProject, String sourceType,
if (sourceType == null) {
return null;
}
IJavaProject fakeProject = null;
if (javaProject instanceof FakeJavaProject) {
fakeProject = javaProject;
javaProject = ((FakeJavaProject) fakeProject).getRootProject();
}
// Step1 (20%) : try to find type with the standard classpath
mainMonitor.subTask("Finding type with the standard classpath");
SubMonitor subMonitor = mainMonitor.split(20).setWorkRemaining(100);
Expand All @@ -457,7 +450,9 @@ public IMember findDeclaredProperty(IJavaProject javaProject, String sourceType,
if (type == null) {
// Not found, type could be included in deployment JAR which is not in classpath
// Try to find type from deployment JAR
IJavaProject fakeProject = configureSearchClasspath(javaProject, false, subMonitor);
if (fakeProject == null) {
fakeProject = configureSearchClasspath(javaProject, false, subMonitor);
}
if (mainMonitor.isCanceled()) {
throw new OperationCanceledException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Require-Bundle: org.junit,
com.google.guava,
com.redhat.microprofile.jdt.quarkus,
org.eclipse.lsp4j
Import-Package: com.google.gson
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
<artifactId>all-quarkus-extensions</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire-plugin.version>2.22.0</surefire-plugin.version>
<quarkus.version>0.21.1</quarkus.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.1.1.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.1.1.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>${quarkus.version}</version>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Loading

0 comments on commit f8752dd

Please sign in to comment.