Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vdt-plugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
vdt-plugin
Commits
3968e7c4
Commit
3968e7c4
authored
Jul 25, 2015
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support fo Eclipse string resolution, such as verilog_project_loc
parent
1b718a7b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
9 deletions
+110
-9
build.properties
build.properties
+2
-1
plugin.xml
plugin.xml
+6
-0
VDTLaunchConfigurationDelegate.java
...el/vdt/core/launching/VDTLaunchConfigurationDelegate.java
+0
-1
Context.java
src/com/elphel/vdt/core/tools/contexts/Context.java
+97
-6
VerilogResolver.java
src/com/elphel/vdt/ui/variables/VerilogResolver.java
+5
-1
No files found.
build.properties
View file @
3968e7c4
...
@@ -14,7 +14,8 @@ bin.includes = icons/,\
...
@@ -14,7 +14,8 @@ bin.includes = icons/,\
LICENSE,
\
LICENSE,
\
INSTALL,
\
INSTALL,
\
CONTRIBUTORS_VEDITOR.txt,
\
CONTRIBUTORS_VEDITOR.txt,
\
parsers/
parsers/,
\
bin/
#
#
# Set the following to override the environment
# Set the following to override the environment
...
...
plugin.xml
View file @
3968e7c4
...
@@ -361,6 +361,12 @@
...
@@ -361,6 +361,12 @@
<extension
<extension
point=
"org.eclipse.core.variables.dynamicVariables"
>
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
<variable
name=
"verilog_source_loc"
name=
"verilog_source_loc"
description=
"%verilog_source_loc.description"
description=
"%verilog_source_loc.description"
...
...
src/com/elphel/vdt/core/launching/VDTLaunchConfigurationDelegate.java
View file @
3968e7c4
...
@@ -39,7 +39,6 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
...
@@ -39,7 +39,6 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import
org.eclipse.swt.widgets.Display
;
import
org.eclipse.swt.widgets.Display
;
import
com.elphel.vdt.Txt
;
import
com.elphel.vdt.Txt
;
import
com.elphel.vdt.core.tools.contexts.BuildParamsItem
;
import
com.elphel.vdt.ui.MessageUI
;
import
com.elphel.vdt.ui.MessageUI
;
import
com.elphel.vdt.veditor.VerilogPlugin
;
import
com.elphel.vdt.veditor.VerilogPlugin
;
import
com.elphel.vdt.veditor.preference.PreferenceStrings
;
import
com.elphel.vdt.veditor.preference.PreferenceStrings
;
...
...
src/com/elphel/vdt/core/tools/contexts/Context.java
View file @
3968e7c4
...
@@ -33,8 +33,14 @@ import java.io.OutputStreamWriter;
...
@@ -33,8 +33,14 @@ import java.io.OutputStreamWriter;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
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.ToolsCore
;
import
com.elphel.vdt.core.tools.config.Config
;
import
com.elphel.vdt.core.tools.config.Config
;
import
com.elphel.vdt.core.tools.config.ConfigException
;
import
com.elphel.vdt.core.tools.config.ConfigException
;
...
@@ -327,7 +333,7 @@ public abstract class Context {
...
@@ -327,7 +333,7 @@ public abstract class Context {
for
(
Iterator
<
String
>
lineIter
=
lines
.
iterator
();
lineIter
.
hasNext
();)
{
for
(
Iterator
<
String
>
lineIter
=
lines
.
iterator
();
lineIter
.
hasNext
();)
{
String
line
=
(
String
)
lineIter
.
next
();
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
// 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
// Here - already resolved to empty
...
@@ -467,7 +473,7 @@ public abstract class Context {
...
@@ -467,7 +473,7 @@ public abstract class Context {
// new ContextParamRepeaterRecognizer(this)
// new ContextParamRepeaterRecognizer(this)
},
topProcessor
);
},
topProcessor
);
return
processor
.
process
(
paramStringTemplate
);
return
processor
.
process
(
paramStringTemplate
);
}
}
// recognizes parameter name (just %name), or simple generators
// recognizes parameter name (just %name), or simple generators
...
@@ -492,7 +498,7 @@ public abstract class Context {
...
@@ -492,7 +498,7 @@ public abstract class Context {
List
<
String
>
result
=
processor
.
process
(
stringTemplate
);
List
<
String
>
result
=
processor
.
process
(
stringTemplate
);
if
(
result
.
size
()==
0
)
return
""
;
if
(
result
.
size
()==
0
)
return
""
;
return
result
.
get
(
0
);
return
result
.
get
(
0
);
}
}
protected
void
initControlInterface
()
throws
ConfigException
{
protected
void
initControlInterface
()
throws
ConfigException
{
...
@@ -735,5 +741,90 @@ public abstract class Context {
...
@@ -735,5 +741,90 @@ public abstract class Context {
private
void
checkNotInitialized
()
throws
ConfigException
{
private
void
checkNotInitialized
()
throws
ConfigException
{
if
(
initialized
)
if
(
initialized
)
throw
new
ConfigException
(
"Context cannot be re-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
View file @
3968e7c4
...
@@ -77,7 +77,11 @@ public class VerilogResolver implements IDynamicVariableResolver {
...
@@ -77,7 +77,11 @@ public class VerilogResolver implements IDynamicVariableResolver {
*/
*/
protected
String
translateToValue
(
IResource
resource
,
IDynamicVariable
variable
)
throws
CoreException
{
protected
String
translateToValue
(
IResource
resource
,
IDynamicVariable
variable
)
throws
CoreException
{
String
name
=
variable
.
getName
();
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
();
return
resource
.
getLocation
().
toOSString
();
}
else
if
(
name
.
endsWith
(
"_path"
))
{
//$NON-NLS-1$
}
else
if
(
name
.
endsWith
(
"_path"
))
{
//$NON-NLS-1$
return
resource
.
getFullPath
().
toOSString
();
return
resource
.
getFullPath
().
toOSString
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment