Source:
<code>public void onProjectPathChanged(@NotNull final String projectPath) { if (lastPath.equals(projectPath)) { <START> lastPath = projectPath; <END> return; } else { lastPath = projectPath; } myTargetSpecsBox.clear(); errors.clear(); final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(VfsUtil.pathToUrl(projectPath)); if (file == null || !PantsUtil.isPantsProjectFile(file)) { myTargetSpecsBox.setEnabled(true); errors.add(String.format("Pants project not found given project path: %s", projectPath)); return; } if (file.isDirectory()) { myTargetSpecsBox.setEnabled(false); Optional<String> relativeProjectPath = PantsUtil.getRelativeProjectPath(file.getPath()); if (!relativeProjectPath.isPresent()) { errors.add(String.format("Fail to find relative path from %s to build root.", file.getPath())); return; } String spec = relativeProjectPath.get() + "/::"; myTargetSpecsBox.setEmptyText(spec); myTargetSpecsBox.addItem(spec, spec, true); myLibsWithSourcesCheckBox.setEnabled(true); } else if (PantsUtil.isExecutable(file.getPath())) { myTargetSpecsBox.setEnabled(false); myTargetSpecsBox.setEmptyText(file.getName()); myLibsWithSourcesCheckBox.setSelected(false); myLibsWithSourcesCheckBox.setEnabled(false); } else { myTargetSpecsBox.setEnabled(true); myTargetSpecsBox.setEmptyText(StatusText.DEFAULT_EMPTY_TEXT); myLibsWithSourcesCheckBox.setEnabled(true); ProgressManager.getInstance().run(new Task.Modal(getProject(), PantsBundle.message("pants.getting.target.list"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { loadTargets(projectPath); } }); } }</code><technical_language>assign if equal? This reduced a guard clause</technical_language>

Target:
public void onProjectPathChanged(@NotNull final String projectPath) { if (lastPath.equals(projectPath)) { return; } lastPath = projectPath; myTargetSpecsBox.clear(); errors.clear(); final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(VfsUtil.pathToUrl(projectPath)); if (file == null || !PantsUtil.isPantsProjectFile(file)) { myTargetSpecsBox.setEnabled(true); errors.add(String.format("Pants project not found given project path: %s", projectPath)); return; } if (file.isDirectory()) { myTargetSpecsBox.setEnabled(false); Optional<String> relativeProjectPath = PantsUtil.getRelativeProjectPath(file.getPath()); if (!relativeProjectPath.isPresent()) { errors.add(String.format("Fail to find relative path from %s to build root.", file.getPath())); return; } String spec = relativeProjectPath.get() + "/::"; myTargetSpecsBox.setEmptyText(spec); myTargetSpecsBox.addItem(spec, spec, true); myLibsWithSourcesCheckBox.setEnabled(true); } else if (PantsUtil.isExecutable(file.getPath())) { myTargetSpecsBox.setEnabled(false); myTargetSpecsBox.setEmptyText(file.getName()); myLibsWithSourcesCheckBox.setSelected(false); myLibsWithSourcesCheckBox.setEnabled(false); } else { myTargetSpecsBox.setEnabled(true); myTargetSpecsBox.setEmptyText(StatusText.DEFAULT_EMPTY_TEXT); myLibsWithSourcesCheckBox.setEnabled(true); ProgressManager.getInstance().run(new Task.Modal(getProject(), PantsBundle.message("pants.getting.target.list"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { loadTargets(projectPath); } }); } }