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

Commit

Permalink
Rework icon and label of completion proposals.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed Jun 2, 2016
1 parent e416879 commit 0a95183
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 158 deletions.
1 change: 1 addition & 0 deletions documentation/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## release ChangeLog

### (NextVersion)
* Reworked the icon and label of completion proposals and fixed some related issues. Also, now the icons are consistent with the Outline icons.
* Fixed: Progress dialog never showing up when "Ok" pressed in LANG_NAME project properties page.
* Fixed: Eclipse variables not being substituted in environment-variable values.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.googlecode.goclipse.core.tools.GocodeServerManager;
import com.googlecode.goclipse.tooling.env.GoEnvironment;
import com.googlecode.goclipse.tooling.gocode.GocodeCompletionOperation;
import com.googlecode.goclipse.tooling.gocode.GocodeOutputParser;
import com.googlecode.goclipse.tooling.gocode.GocodeOutputParser2;
import com.googlecode.goclipse.ui.GoUIPlugin;

import melnorme.lang.ide.core.LangCore;
Expand Down Expand Up @@ -46,7 +46,12 @@ protected LangCompletionResult doComputeProposals(SourceOperationContext context
String source = document.get();
ExternalProcessResult processResult = client.execute(fileLoc.toPathString(), source, offset);

return new LangCompletionResult(new GocodeOutputParser(offset, source).parseResult(processResult));
return new LangCompletionResult(new GocodeOutputParser2(offset, source){
@Override
protected void logWarning(String message) {
LangCore.logWarning(message);
}
} .parseResult(processResult));
}

}
4 changes: 2 additions & 2 deletions plugin_ide.ui/src/melnorme/lang/ide/ui/LangImageProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public IManagedImage visitTypeDecl() {
}

@Override
public IManagedImage visitImport() {
return GoPluginImages.SOURCE_IMPORT;
public IManagedImage visitPackage() {
return LangElementImages.PACKAGE;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*******************************************************************************
* Copyright (c) 2016 Bruno Medeiros and other Contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bruno Medeiros - initial API and implementation
*******************************************************************************/
package com.googlecode.goclipse.tooling.gocode;

import static melnorme.lang.tooling.CompletionProposalKind.FUNCTION;
import static melnorme.lang.tooling.CompletionProposalKind.INTERFACE;
import static melnorme.lang.tooling.CompletionProposalKind.PACKAGE;
import static melnorme.lang.tooling.CompletionProposalKind.STRUCT;
import static melnorme.lang.tooling.CompletionProposalKind.TYPE_DECL;
import static melnorme.lang.tooling.CompletionProposalKind.VARIABLE;
import static melnorme.lang.tooling.EProtection.PRIVATE;
import static melnorme.utilbox.core.Assert.AssertNamespace.assertFail;
import static melnorme.utilbox.core.Assert.AssertNamespace.assertTrue;

import org.junit.Test;

import melnorme.lang.tooling.CompletionProposalKind;
import melnorme.lang.tooling.EAttributeFlag;
import melnorme.lang.tooling.EProtection;
import melnorme.lang.tooling.ElementAttributes;
import melnorme.lang.tooling.ToolCompletionProposal;
import melnorme.utilbox.core.CommonException;
import melnorme.utilbox.tests.CommonTestExt;

public class GocodeOutputParser_Test extends CommonTestExt {

protected ElementAttributes attribs(EProtection protection) {
return new ElementAttributes(protection);
}

@Test
public void test() throws Exception { test$(); }
public void test$() throws Exception {
testProposalParse("var,,xxx,,int",
proposal("xxx", "xxx", VARIABLE, attribs(PRIVATE), ": int"));
testProposalParse("var,,Global,,",
proposal("Global", "Global", VARIABLE, attribs(null), null));

testProposalParse("const,,xxx,,int",
proposal("xxx", "xxx", VARIABLE, new ElementAttributes(PRIVATE, EAttributeFlag.CONST), ": int"));


testProposalParse("func,,my_func,,func() int",
proposal("my_func", "my_func()", FUNCTION, attribs(EProtection.PRIVATE), "int"));
testProposalParse("func,,my_func,,func() (int, string)",
proposal("my_func", "my_func()", FUNCTION, attribs(EProtection.PRIVATE), "(int, string)"));
testProposalParse("func,,ApiFunc,,func(w io.Writer, a ...interface{})",
proposal("ApiFunc", "ApiFunc(w io.Writer, a ...interface{})", FUNCTION, attribs(null), ""));
// Incorrectly formated function entry
testProposalParse("func,,xpto,,func",
proposal("xpto", "xpto", FUNCTION, attribs(EProtection.PRIVATE), null));


testProposalParse("type,,Foo,,struct",
proposal("Foo", "Foo", STRUCT, attribs(null), null));
testProposalParse("type,,Foo,,interface",
proposal("Foo", "Foo", INTERFACE, attribs(null), null));

testProposalParse("type,,Type,,map[string][]string",
proposal("Type", "Type", TYPE_DECL, attribs(null), ": map[string][]string"));

testProposalParse("package,,fmt,,",
proposal("fmt", "fmt", PACKAGE, attribs(null), null));


}

protected ToolCompletionProposal proposal(String replaceString, String label, CompletionProposalKind kind,
ElementAttributes attribs, String typeLabel) {
return new ToolCompletionProposal(10-6, 6, replaceString, label, kind, attribs, typeLabel, null, null);
}

protected void testProposalParse(String gocodeResultLine, ToolCompletionProposal expectedProposal)
throws CommonException {
GocodeOutputParser2 outputParser = new GocodeOutputParser2(10, " prefix") {
@Override
protected void logWarning(String message) {
assertFail();
}
};
ToolCompletionProposal completion = outputParser.parseCompletion(gocodeResultLine);

assertTrue(completion.equals(expectedProposal));
}

}

This file was deleted.

Loading

0 comments on commit 0a95183

Please sign in to comment.