Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
Removed gofmt and godoc prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed Feb 23, 2016
1 parent 770bd5d commit bd9f8f1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 42 deletions.
3 changes: 2 additions & 1 deletion documentation/ChangeLog.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* godef #TODO * godef #TODO
* Minor improvement to editor caret position preservation when invoking gofmt. * Minor improvement to editor caret position preservation when invoking gofmt.
* Fixed bug where problem markers for the #build-tests target would not be created for Eclipse projects inside a GOPATH entry. * Fixed bug where problem markers for the #build-tests target would not be created for Eclipse projects inside a GOPATH entry.
* Removed GOOS and GOARCH from preferences, they no longer have an apparent use. * Removed GOOS and GOARCH from preferences, they no longer have an apparent use.
* Removed gofmt and godoc preferences.


### 0.14.0 ### 0.14.0
* Added on-the-fly parser errors in the editor (uses Go `oracle`). * Added on-the-fly parser errors in the editor (uses Go `oracle`).
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public interface GoEnvironmentPrefs {


IProjectPreference<String> GO_ROOT = new StringPreference(LangCore.PLUGIN_ID, IProjectPreference<String> GO_ROOT = new StringPreference(LangCore.PLUGIN_ID,
"com.googlecode.goclipse.goroot", "", USE_PROJECT_SETTINGS).getProjectPreference(); "com.googlecode.goclipse.goroot", "", USE_PROJECT_SETTINGS).getProjectPreference();
IProjectPreference<String> FORMATTER_PATH = new StringPreference(LangCore.PLUGIN_ID,
"com.googlecode.goclipse.formatter.path", "", USE_PROJECT_SETTINGS).getProjectPreference();



IProjectPreference<String> GO_PATH = new OptionalStringPreference(LangCore.PLUGIN_ID, IProjectPreference<String> GO_PATH = new OptionalStringPreference(LangCore.PLUGIN_ID,
"com.googlecode.goclipse.gopath", ToolchainPreferences.USE_PROJECT_SETTINGS).getProjectPreference(); "com.googlecode.goclipse.gopath", ToolchainPreferences.USE_PROJECT_SETTINGS).getProjectPreference();
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditor;


import com.googlecode.goclipse.core.GoEnvironmentPrefs;
import com.googlecode.goclipse.tooling.env.GoEnvironment; import com.googlecode.goclipse.tooling.env.GoEnvironment;


import melnorme.utilbox.collections.Indexable; import melnorme.utilbox.collections.Indexable;
import melnorme.utilbox.core.CommonException; import melnorme.utilbox.core.CommonException;
import melnorme.utilbox.misc.Location;
import melnorme.utilbox.misc.MiscUtil;


public class RunGoFmtOperation extends AbstractEditorGoToolOperation { public class RunGoFmtOperation extends AbstractEditorGoToolOperation {


Expand All @@ -34,7 +35,8 @@ public RunGoFmtOperation(ITextEditor editor) {
@Override @Override
protected ProcessBuilder prepareProcessBuilder(Path goSDKPath, GoEnvironment goEnv) protected ProcessBuilder prepareProcessBuilder(Path goSDKPath, GoEnvironment goEnv)
throws CoreException, CommonException { throws CoreException, CommonException {
Indexable<String> cmd = list(GoEnvironmentPrefs.FORMATTER_PATH.getEffectiveValue(project)); Location gofmt = goEnv.getGoRoot_Location().resolve_fromValid("bin/gofmt" + MiscUtil.getExecutableSuffix());
Indexable<String> cmd = list(gofmt.toString());
return goEnv.createProcessBuilder(cmd, null, true); return goEnv.createProcessBuilder(cmd, null, true);
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
*******************************************************************************/ *******************************************************************************/
package com.googlecode.goclipse.ui.preferences; package com.googlecode.goclipse.ui.preferences;


import static melnorme.lang.tooling.ops.util.PathValidator.LocationKind.FILE_ONLY;

import java.io.File; import java.io.File;


import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
Expand All @@ -29,24 +25,19 @@
import melnorme.lang.ide.ui.preferences.common.AbstractPreferencesBlock2; import melnorme.lang.ide.ui.preferences.common.AbstractPreferencesBlock2;
import melnorme.lang.ide.ui.preferences.common.PreferencesPageContext; import melnorme.lang.ide.ui.preferences.common.PreferencesPageContext;
import melnorme.lang.tooling.data.IValidatableValue.ValidatableField; import melnorme.lang.tooling.data.IValidatableValue.ValidatableField;
import melnorme.lang.tooling.ops.util.LocationValidator;
import melnorme.lang.utils.EnvUtils; import melnorme.lang.utils.EnvUtils;
import melnorme.util.swt.components.fields.CheckBoxField; import melnorme.util.swt.components.fields.CheckBoxField;
import melnorme.util.swt.components.fields.DirectoryTextField; import melnorme.util.swt.components.fields.DirectoryTextField;
import melnorme.util.swt.components.fields.EnablementButtonTextField; import melnorme.util.swt.components.fields.EnablementButtonTextField;
import melnorme.util.swt.components.fields.FileTextField;
import melnorme.utilbox.concurrency.OperationCancellation; import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException; import melnorme.utilbox.core.CommonException;
import melnorme.utilbox.misc.MiscUtil;


public class GoSDKConfigBlock extends AbstractCompositePreferencesBlock { public class GoSDKConfigBlock extends AbstractCompositePreferencesBlock {


public final DirectoryTextField goRootField = new DirectoryTextField("GO&ROOT:"); public final DirectoryTextField goRootField = new DirectoryTextField("Directory:");
protected final GoSDKLocationValidator goSDKLocationValidator = new GoSDKLocationValidator(); protected final GoSDKLocationValidator goSDKLocationValidator = new GoSDKLocationValidator();
public final ValidatableField<String> validatedGoRoot = new ValidatableField<>(goRootField, goSDKLocationValidator); public final ValidatableField<String> validatedGoRoot = new ValidatableField<>(goRootField, goSDKLocationValidator);


protected final FileTextField goFmtPath = new FileTextField("gofmt:");

protected final EnablementButtonTextField goPathField = new GoPathField(); protected final EnablementButtonTextField goPathField = new GoPathField();
protected final CheckBoxField gopathAppendProjectLocField = new CheckBoxField( protected final CheckBoxField gopathAppendProjectLocField = new CheckBoxField(
"Also add project location to GOPATH, if it's not contained there already."); "Also add project location to GOPATH, if it's not contained there already.");
Expand All @@ -55,21 +46,17 @@ public GoSDKConfigBlock(PreferencesPageContext prefContext) {
super(prefContext); super(prefContext);


addSubComponent(goRootField); addSubComponent(goRootField);
addSubComponent(goFmtPath);


addSubComponent(goPathField); addSubComponent(goPathField);
addSubComponent(gopathAppendProjectLocField); addSubComponent(gopathAppendProjectLocField);


prefContext.bindToPreference(goRootField, GoEnvironmentPrefs.GO_ROOT); prefContext.bindToPreference(goRootField, GoEnvironmentPrefs.GO_ROOT);
prefContext.bindToPreference(goFmtPath, GoEnvironmentPrefs.FORMATTER_PATH);


prefContext.bindToPreference(goPathField.asEffectiveValueProperty2(), GoEnvironmentPrefs.GO_PATH); prefContext.bindToPreference(goPathField.asEffectiveValueProperty2(), GoEnvironmentPrefs.GO_PATH);
prefContext.bindToPreference(gopathAppendProjectLocField, GoEnvironmentPrefs.APPEND_PROJECT_LOC_TO_GOPATH); prefContext.bindToPreference(gopathAppendProjectLocField, GoEnvironmentPrefs.APPEND_PROJECT_LOC_TO_GOPATH);




validation.addFieldValidation(true, goRootField, goSDKLocationValidator); validation.addFieldValidation(true, goRootField, goSDKLocationValidator);

validation.addFieldValidation(true, goFmtPath, new LocationValidator(goFmtPath.getLabelText(), FILE_ONLY));
} }


/* ----------------- ----------------- */ /* ----------------- ----------------- */
Expand All @@ -84,42 +71,26 @@ protected void createContents(Composite topControl) {
// Ignore super // Ignore super
//super.createContents(topControl); //super.createContents(topControl);


int numColumns = 3; Group goSDK = AbstractPreferencesBlock2.createOptionsSection(topControl, "Go installation (GOROOT):", 3,
Group goSDK = AbstractPreferencesBlock2.createOptionsSection(topControl, "Go installation:", numColumns, createSubComponentDefaultGridData());
getPreferenceGroupDefaultLayout());


goRootField.createComponentInlined(goSDK); goRootField.createComponentInlined(goSDK);


goFmtPath.createComponentInlined(goSDK);

/* ----------------- ----------------- */ /* ----------------- ----------------- */


Composite goPathFieldTopControl = goPathField.createComponent(topControl, getPreferenceGroupDefaultLayout()); Composite goPathFieldTopControl = goPathField.createComponent(topControl,
createSubComponentDefaultGridData());
gopathAppendProjectLocField.createComponent(goPathFieldTopControl); gopathAppendProjectLocField.createComponent(goPathFieldTopControl);


goRootField.addListener(() -> handleGoRootChange()); goRootField.addListener(() -> handleGoRootChange());
} }


protected GridData getPreferenceGroupDefaultLayout() { @Override
protected GridData createSubComponentDefaultGridData() {
return GridDataFactory.fillDefaults().grab(true, false).minSize(300, SWT.DEFAULT).create(); return GridDataFactory.fillDefaults().grab(true, false).minSize(300, SWT.DEFAULT).create();
} }


protected void handleGoRootChange() { protected void handleGoRootChange() {
IPath gorootPath = new Path(goRootField.getFieldValue());

if(validatedGoRoot.getValidationStatusLevel().isOkStatus()) {

String goFmtName = "gofmt" + MiscUtil.getExecutableSuffix();
setValueIfFileExists(goFmtPath, gorootPath.append("bin").append(goFmtName).toFile());
}
}

protected void setValueIfFileExists(FileTextField fileField, File filePath) {
if (filePath != null && filePath.exists() && filePath.isFile()) {
fileField.setFieldValue(filePath.getAbsolutePath());
} else {
fileField.setFieldValue("");
}
} }


/* ----------------- ----------------- */ /* ----------------- ----------------- */
Expand Down

0 comments on commit bd9f8f1

Please sign in to comment.