Class EclipseVariables

java.lang.Object
net.neoforged.elc.EclipseVariables

public class EclipseVariables extends Object
Eclipse Variables are special symbols that can be used in the resolution of certain launch config parameters.

Variables have two components: the variable name, and the parameter. The parameter is not required for all variables.

The proper form for a variable is ${var_name:parameter}, or ${var_name} if a parameter is not necessary.

Many methods in this class refer to the concept of an Eclipse resource, which is an object known to Eclipse, such as a project name.

Finally, the javadocs of methods in this class specify that they return a certain value. This value is the value the variable will return when evaluated. The literal return value of these methods is an Eclipse Variable definition.

  • Constructor Details

    • EclipseVariables

      public EclipseVariables()
  • Method Details

    • buildFiles

      public static String buildFiles(@Nullable @Nullable String deltas)
      Returns the set of absolute file system paths whose modification caused the current build. A list of the characters, 'a' (added), 'c' (changed), 'r' (removed), 'f' (files only), 'd' (directories only), can be supplied as an argument to limit the file list to just those types of deltas. Defaults to all deltas.
      Parameters:
      deltas - A string of deltas for limiting the listed files.
    • buildProject

      public static String buildProject(@Nullable @Nullable String resource)
      Returns the absolute file system path of the project currently being built, or the absolute file system path of the resource argument interpreted as a path relative to the project currently being built.
      Parameters:
      resource - A path relative to the project currently being built, specifying a specific resource.
    • buildType

      public static String buildType()
      Returns the type of build being performed. One of "incremental", "full", "auto", or "none".
    • containerLocation

      public static String containerLocation(@Nullable @Nullable String resource)
      Returns the absolute file system path of a resource's container.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • containerName

      public static String containerName(@Nullable @Nullable String resource)
      Returns the name of a resource's container.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • containerPath

      public static String containerPath(@Nullable @Nullable String resource)
      Returns the workspace relative path of a resource's container.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • currentDate

      public static String currentDate(@Nullable @Nullable String dateFormat)
      Returns the current system time formatted as yyyyMMdd_HHmm.
      Parameters:
      dateFormat - An optional SimpleDateFormat pattern.
    • eclipseHome

      public static String eclipseHome()
      Returns the location of the base installation for the running platform.
    • eeHome

      public static String eeHome(String id)
      Returns the absolute file system path of the JRE home directory corresponding to the specified execution environment.
      Parameters:
      id - An execution environment identifier, such as JavaSE-1.8 or JavaSE-17.
    • envVar

      public static String envVar(String name)
      Returns the value of an environment variable.
      Parameters:
      name - The name of the environment variable.
    • filePrompt

      public static String filePrompt(@Nullable @Nullable String hint, @Nullable @Nullable String initialDir)
      Returns the absolute file system path of a file chosen in a file selection dialog.

      If the second argument is provided, the first must be provided.

      Parameters:
      hint - A prompt hint on the dialog title.
      initialDir - The initial path in the selection dialog.
    • folderPrompt

      public static String folderPrompt(@Nullable @Nullable String hint, @Nullable @Nullable String initialDir)
      Returns the absolute file system path of a directory chosen in a directory selection dialog.

      If the second argument is provided, the first must be provided.

      Parameters:
      hint - A prompt hint on the dialog title.
      initialDir - The initial path in the selection dialog.
    • gitBranch

      public static String gitBranch(@Nullable @Nullable String resource)
      Returns the current HEAD in the Git repository that contains the selected or referenced resource

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • gitDir

      public static String gitDir(@Nullable @Nullable String resource)
      Returns the path to the .git directory for the selected or named resource

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • gitRepoRelativePath

      public static String gitRepoRelativePath(@Nullable @Nullable String resource)
      Returns the path of a resource relative to the Git repository

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • gitWorkTree

      public static String gitWorkTree(@Nullable @Nullable String resource)
      Returns the work tree root of the Git repository for a resource.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • javaExtRegex

      public static String javaExtRegex()
      Returns a regular expression matching registered Java-like file extensions
    • javaTypeName

      public static String javaTypeName()
      Returns the fully qualified Java type name of the primary type in the selected resource.
    • passwordPrompt

      public static String passwordPrompt(@Nullable @Nullable String hint, @Nullable @Nullable String initial)
      Returns the text value entered into a password prompt dialog.

      If the second argument is provided, the first must be provided.

      Parameters:
      hint - A prompt hint on the input dialog.
      initial - The initial value in the input dialog.
    • projectLocation

      public static String projectLocation(@Nullable @Nullable String resource)
      Returns the absolute file system path of a resource's project.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • projectName

      public static String projectName(@Nullable @Nullable String resource)
      Returns the name of a resource's project.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • projectPath

      public static String projectPath(@Nullable @Nullable String resource)
      Returns the workspace relative path of a resource's project.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • resourceLocation

      public static String resourceLocation(@Nullable @Nullable String resource)
      Returns the absolute file system path of a resource.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • resourceName

      public static String resourceName(@Nullable @Nullable String resource)
      Returns the name of a resource.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • resourcePath

      public static String resourcePath(@Nullable @Nullable String resource)
      Returns the workspace relative path of a resource.

      The target resource is the selected resource when unspecified, or the resource identified by a workspace relative path.

      Parameters:
      resource - The target resource, or null to use the selected resource.
    • selectedResourceLocation

      public static String selectedResourceLocation()
      Returns the absolute file system path of the selected resource.
    • selectedResourceName

      public static String selectedResourceName()
      Returns the name of the selected resource.
    • selectedResourcePath

      public static String selectedResourcePath()
      Returns the workspace relative path of the selected resource.
    • selectedText

      public static String selectedText()
      Returns the text currently selected in the active editor.
    • prompt

      public static String prompt(@Nullable @Nullable String hint, @Nullable @Nullable String initial)
      Returns the text value entered into a prompt dialog.

      If the second argument is provided, the first must be provided.

      Parameters:
      hint - A prompt hint on the input dialog.
      initial - The initial value in the input dialog.
    • systemVar

      public static String systemVar(String varName)
      Returns the value of an Eclipse system variable.
      Parameters:
      varName - The variable name. One of: ARCH, ECLIPSE_HOME, NL, OS, or WS.
    • systemPath

      public static String systemPath(String tool)
      Returns the absolute file system path of the external tool.

      Resolved by finding the first occurrence of the named tool based on the system path specification

      Parameters:
      tool - The name of the tool.
    • systemProperty

      public static String systemProperty(String property)
      Returns the value of a system property from the Eclipse runtime.
      Parameters:
      property - The property name.
    • workspaceLocation

      public static String workspaceLocation(@Nullable @Nullable String resource)
      Returns the absolute file system path of the workspace root.

      If a resource is specified, the absolute file system path of the resource identified by a workspace relative path is returned.

      Parameters:
      resource - The target resource, or null if one is not being targetted.