Loading build.properties +2 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,8 @@ bin.includes = icons/,\ LICENSE,\ INSTALL,\ CONTRIBUTORS_VEDITOR.txt,\ parsers/ parsers/,\ bin/ # # Set the following to override the environment Loading plugin.xml +6 −0 Original line number Diff line number Diff line Loading @@ -361,6 +361,12 @@ <extension point="org.eclipse.core.variables.dynamicVariables"> <variable name="verilog_project_loc" description="Returns the absolute file system path of the project." resolver="com.elphel.vdt.ui.variables.VerilogResolver" supportsArgument="true"> </variable> <variable name="verilog_source_loc" description="%verilog_source_loc.description" Loading src/com/elphel/vdt/core/launching/VDTLaunchConfigurationDelegate.java +0 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.swt.widgets.Display; import com.elphel.vdt.Txt; import com.elphel.vdt.core.tools.contexts.BuildParamsItem; import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.preference.PreferenceStrings; Loading src/com/elphel/vdt/core/tools/contexts/Context.java +97 −6 Original line number Diff line number Diff line Loading @@ -35,6 +35,12 @@ import java.util.Iterator; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.variables.IDynamicVariable; import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.IValueVariable; import org.eclipse.core.variables.VariablesPlugin; import com.elphel.vdt.core.tools.ToolsCore; import com.elphel.vdt.core.tools.config.Config; import com.elphel.vdt.core.tools.config.ConfigException; Loading Loading @@ -327,7 +333,7 @@ public abstract class Context { for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) { String line = (String)lineIter.next(); // the result will not be used as some other parameter value, so topProcessor is null in the next line /Andrey commandSequence.add(buildCommandString(line,null)); // TODO: parses them here? VERIFY commandSequence.add(resolveStrings(buildCommandString(line,null))); // TODO: parses them here? VERIFY } // Here - already resolved to empty Loading Loading @@ -736,4 +742,89 @@ public abstract class Context { if(initialized) throw new ConfigException("Context cannot be re-initialized"); } //Substitute Eclipse and VDT ("verilog_") strings ${} here, after all VDT parameter processing // recursively resolve variables private List<String> resolveStrings(List<String> preResolved){ List<String> resolved = new ArrayList<String>(); for (String s:preResolved){ resolved.add(resolveStrings(s)); } return resolved; } private String resolveStrings(String s){ int start = s.indexOf("${"); if (start < 0) return s; if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) System.out.println("Before substitution\""+s+"\""); int end = s.indexOf("}", start); if (end < 0) return s; String dynVar = s.substring(start+2,end).trim(); String dynValue = resolveEclipseVariables(dynVar); if (dynValue == null) { System.out.println("getEclipseSubstitutedString("+s+") - undefined variable: "+dynVar); dynValue = s.substring(start,end+1); // just no substitution } String result = s.substring(0,start)+dynValue; if (end < s.length()) result += resolveStrings(s.substring(end+1)); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) System.out.println("After substitution\""+result+"\""); return result; } // from http://www.programcreek.com/java-api-examples/index.php?api=org.eclipse.core.variables.IDynamicVariable private String resolveEclipseVariables(String key){ if (key == null) return null; IStringVariableManager variableManager=VariablesPlugin.getDefault().getStringVariableManager(); //debug /* IValueVariable [] variables = variableManager.getValueVariables(); IDynamicVariable [] dVariables = variableManager.getDynamicVariables(); System.out.println("resolveEclipseVariables: key=" + key); for (IValueVariable v : variables){ System.out.println("resolveEclipseVariables: variables=" + v.getValue()); } for (IDynamicVariable dv : dVariables){ if (!dv.getName().contains("prompt")) { try { System.out.print("resolveEclipseVariables: dVariables=" + dv.getName()); System.out.println(" -- "+dv.getValue(null)); } catch (CoreException e) { // TODO Auto-generated catch block System.out.println(" -- null?"); } } } */ int index=key.indexOf(':'); if (index > 1) { String varName=key.substring(0,index); IDynamicVariable variable=variableManager.getDynamicVariable(varName); if (variable == null) return null; try { if (key.length() > index + 1) return variable.getValue(key.substring(index + 1)); return variable.getValue(null); } catch ( CoreException e) { return null; } } IValueVariable variable=variableManager.getValueVariable(key); if (variable == null) { IDynamicVariable dynamicVariable=variableManager.getDynamicVariable(key); if (dynamicVariable == null) return null; try { return dynamicVariable.getValue(null); } catch ( CoreException e) { return null; } } return variable.getValue(); } } src/com/elphel/vdt/ui/variables/VerilogResolver.java +5 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,11 @@ public class VerilogResolver implements IDynamicVariableResolver { */ protected String translateToValue(IResource resource, IDynamicVariable variable) throws CoreException { String name = variable.getName(); if (name.endsWith("_loc")) { //$NON-NLS-1$ if (name.endsWith("project_loc")) { //$NON-NLS-1$ resource = SelectedResourceManager.getDefault().getChosenVerilogFile(); return resource.getProject().getLocation().toOSString(); } else if (name.endsWith("_loc")) { //$NON-NLS-1$ return resource.getLocation().toOSString(); } else if (name.endsWith("_path")) { //$NON-NLS-1$ return resource.getFullPath().toOSString(); Loading Loading
build.properties +2 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,8 @@ bin.includes = icons/,\ LICENSE,\ INSTALL,\ CONTRIBUTORS_VEDITOR.txt,\ parsers/ parsers/,\ bin/ # # Set the following to override the environment Loading
plugin.xml +6 −0 Original line number Diff line number Diff line Loading @@ -361,6 +361,12 @@ <extension point="org.eclipse.core.variables.dynamicVariables"> <variable name="verilog_project_loc" description="Returns the absolute file system path of the project." resolver="com.elphel.vdt.ui.variables.VerilogResolver" supportsArgument="true"> </variable> <variable name="verilog_source_loc" description="%verilog_source_loc.description" Loading
src/com/elphel/vdt/core/launching/VDTLaunchConfigurationDelegate.java +0 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.swt.widgets.Display; import com.elphel.vdt.Txt; import com.elphel.vdt.core.tools.contexts.BuildParamsItem; import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.preference.PreferenceStrings; Loading
src/com/elphel/vdt/core/tools/contexts/Context.java +97 −6 Original line number Diff line number Diff line Loading @@ -35,6 +35,12 @@ import java.util.Iterator; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.variables.IDynamicVariable; import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.IValueVariable; import org.eclipse.core.variables.VariablesPlugin; import com.elphel.vdt.core.tools.ToolsCore; import com.elphel.vdt.core.tools.config.Config; import com.elphel.vdt.core.tools.config.ConfigException; Loading Loading @@ -327,7 +333,7 @@ public abstract class Context { for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) { String line = (String)lineIter.next(); // the result will not be used as some other parameter value, so topProcessor is null in the next line /Andrey commandSequence.add(buildCommandString(line,null)); // TODO: parses them here? VERIFY commandSequence.add(resolveStrings(buildCommandString(line,null))); // TODO: parses them here? VERIFY } // Here - already resolved to empty Loading Loading @@ -736,4 +742,89 @@ public abstract class Context { if(initialized) throw new ConfigException("Context cannot be re-initialized"); } //Substitute Eclipse and VDT ("verilog_") strings ${} here, after all VDT parameter processing // recursively resolve variables private List<String> resolveStrings(List<String> preResolved){ List<String> resolved = new ArrayList<String>(); for (String s:preResolved){ resolved.add(resolveStrings(s)); } return resolved; } private String resolveStrings(String s){ int start = s.indexOf("${"); if (start < 0) return s; if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) System.out.println("Before substitution\""+s+"\""); int end = s.indexOf("}", start); if (end < 0) return s; String dynVar = s.substring(start+2,end).trim(); String dynValue = resolveEclipseVariables(dynVar); if (dynValue == null) { System.out.println("getEclipseSubstitutedString("+s+") - undefined variable: "+dynVar); dynValue = s.substring(start,end+1); // just no substitution } String result = s.substring(0,start)+dynValue; if (end < s.length()) result += resolveStrings(s.substring(end+1)); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) System.out.println("After substitution\""+result+"\""); return result; } // from http://www.programcreek.com/java-api-examples/index.php?api=org.eclipse.core.variables.IDynamicVariable private String resolveEclipseVariables(String key){ if (key == null) return null; IStringVariableManager variableManager=VariablesPlugin.getDefault().getStringVariableManager(); //debug /* IValueVariable [] variables = variableManager.getValueVariables(); IDynamicVariable [] dVariables = variableManager.getDynamicVariables(); System.out.println("resolveEclipseVariables: key=" + key); for (IValueVariable v : variables){ System.out.println("resolveEclipseVariables: variables=" + v.getValue()); } for (IDynamicVariable dv : dVariables){ if (!dv.getName().contains("prompt")) { try { System.out.print("resolveEclipseVariables: dVariables=" + dv.getName()); System.out.println(" -- "+dv.getValue(null)); } catch (CoreException e) { // TODO Auto-generated catch block System.out.println(" -- null?"); } } } */ int index=key.indexOf(':'); if (index > 1) { String varName=key.substring(0,index); IDynamicVariable variable=variableManager.getDynamicVariable(varName); if (variable == null) return null; try { if (key.length() > index + 1) return variable.getValue(key.substring(index + 1)); return variable.getValue(null); } catch ( CoreException e) { return null; } } IValueVariable variable=variableManager.getValueVariable(key); if (variable == null) { IDynamicVariable dynamicVariable=variableManager.getDynamicVariable(key); if (dynamicVariable == null) return null; try { return dynamicVariable.getValue(null); } catch ( CoreException e) { return null; } } return variable.getValue(); } }
src/com/elphel/vdt/ui/variables/VerilogResolver.java +5 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,11 @@ public class VerilogResolver implements IDynamicVariableResolver { */ protected String translateToValue(IResource resource, IDynamicVariable variable) throws CoreException { String name = variable.getName(); if (name.endsWith("_loc")) { //$NON-NLS-1$ if (name.endsWith("project_loc")) { //$NON-NLS-1$ resource = SelectedResourceManager.getDefault().getChosenVerilogFile(); return resource.getProject().getLocation().toOSString(); } else if (name.endsWith("_loc")) { //$NON-NLS-1$ return resource.getLocation().toOSString(); } else if (name.endsWith("_path")) { //$NON-NLS-1$ return resource.getFullPath().toOSString(); Loading