private void launch(String pName, String fName, String mode) { try { ILaunchConfiguration found = null; ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType lct = lm.getLaunchConfigurationType(GoLaunchConfigurationDelegate.ID); ILaunchConfiguration[] lcfgs = lm.getLaunchConfigurations(lct); for (ILaunchConfiguration lcf : lcfgs) { String project = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_PROJECT, ""); String mainfile = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_MAIN, ""); String prgArgs = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_ARGS, ""); if (prgArgs.isEmpty()) { // this is an empty run, no params, don't mix with already // definded with params if (project.equalsIgnoreCase(pName) && Path.fromOSString(fName).equals(Path.fromOSString(mainfile))) { found = lcf; break; } } } if (found == null) { // create a new launch configuration String cfgName = lm.generateLaunchConfigurationName(Path.fromOSString(fName).lastSegment()); ILaunchConfigurationWorkingCopy workingCopy = lct.newInstance(null, cfgName); workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_PROJECT, pName); workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_MAIN, fName); workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_ARGS, ""); workingCopy.setAttribute( GoConstants.GO_CONF_ATTRIBUTE_BUILD_CONFIG, BuildConfiguration.RELEASE.toString()); workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true); workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, "UTF-8"); found = workingCopy.doSave(); } if (found != null) { found.launch(mode, null, true, true); } } catch (CoreException ce) { Activator.logError(ce); } }
public static void main(String[] args) { Lexer lexer = new Lexer(); Tokenizer tokenizer = new Tokenizer(lexer); VariableParser fparser = new VariableParser(tokenizer, null, null); try { lexer.scan(new File("test/test_go/import_test.go")); for (Var var : fparser.vars) { Activator.logInfo("================================================="); Activator.logInfo(var.getDocumentation()); Activator.logInfo("-------------------------------------------------"); Activator.logInfo(var.getName()); Activator.logInfo(var.getInsertionText()); Activator.logInfo("-------------------------------------------------"); } } catch (IOException e) { Activator.logError(e); } }