Skip to content

Commit

Permalink
Show menu entry "Refresh Gradle Project" for Kotlin DSL scripts
Browse files Browse the repository at this point in the history
As for Groovy DSL scripts show the "Refresh Gradle Project" action when
a .gradle.kts file is selected in the Package/Project Explorer or opened
in an editor.

The common property tests have been refactored out into a separate
expression definition.
  • Loading branch information
oleosterhagen committed Dec 30, 2023
1 parent af0501b commit 577b069
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* <ul>
* <li>a Gradle project</li>
* <li>a .gradle file</li>
* <li>a .gradle.kts file</li>
* <li>a gradle.properties file</li>
* </ul>
* @author Stefan Oehme
Expand All @@ -32,7 +33,7 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
IResource resource = (IResource) receiver;
IProject project = resource.getProject();
if (GradleProjectNature.isPresentOn(project)) {
return resource instanceof IProject || "gradle".equals(resource.getFileExtension()) || "gradle.properties".equals(resource.getName());
return resource instanceof IProject || "gradle".equals(resource.getFileExtension()) || resource.getName().endsWith(".gradle.kts") || "gradle.properties".equals(resource.getName());
}
}
return false;
Expand Down
66 changes: 38 additions & 28 deletions org.eclipse.buildship.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,16 @@
<iterate
operator="or"
ifEmpty="false">
<adapt
type="org.eclipse.core.resources.IResource">
<and>
<test
forcePluginActivation="true"
property="org.eclipse.core.resources.projectNature"
value="org.eclipse.buildship.core.gradleprojectnature">
</test>
<test
forcePluginActivation="true"
property="org.eclipse.buildship.core.isGradleResource">
</test>
</and>
</adapt>
<reference
definitionId="org.eclipse.buildship.ui.GradleResourceInGradleProject">
</reference>
</iterate>
<with
variable="activeEditorInput">
<reference
definitionId="org.eclipse.buildship.ui.GradleResourceInGradleProject">
</reference>
</with>
</or>
</activeWhen>
</handler>
Expand Down Expand Up @@ -455,22 +450,17 @@
<iterate
operator="or"
ifEmpty="false">
<adapt
type="org.eclipse.core.resources.IResource">
<and>
<test
forcePluginActivation="true"
property="org.eclipse.core.resources.projectNature"
value="org.eclipse.buildship.core.gradleprojectnature">
</test>
<test
forcePluginActivation="true"
property="org.eclipse.buildship.core.isGradleResource">
</test>
</and>
</adapt>
<reference
definitionId="org.eclipse.buildship.ui.GradleResourceInGradleProject">
</reference>
</iterate>
</with>
<with
variable="activeEditorInput">
<reference
definitionId="org.eclipse.buildship.ui.GradleResourceInGradleProject">
</reference>
</with>
</or>
</visibleWhen>
</menu>
Expand Down Expand Up @@ -665,4 +655,24 @@
</part>
</actionSetPartAssociation>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
<definition
id="org.eclipse.buildship.ui.GradleResourceInGradleProject">
<adapt
type="org.eclipse.core.resources.IResource">
<and>
<test
forcePluginActivation="true"
property="org.eclipse.core.resources.projectNature"
value="org.eclipse.buildship.core.gradleprojectnature">
</test>
<test
forcePluginActivation="true"
property="org.eclipse.buildship.core.isGradleResource">
</test>
</and>
</adapt>
</definition>
</extension>
</plugin>

0 comments on commit 577b069

Please sign in to comment.