Skip to content

Commit 738ef06

Browse files
committed
feat: add variables workspace_loc and workspace_loc_name
Signed-off-by: Andre Bossert <anb0s@anbos.de>
1 parent 0be1e88 commit 738ef06

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

plugin/src/de/anbos/eclipse/easyshell/plugin/types/Resource.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class Resource {
3636
private ISelection textSelection = null;
3737

3838
// resolved
39-
private String projectName = Activator.getResourceString("easyshell.plugin.name");
39+
private String defaultName = Activator.getResourceString("easyshell.plugin.name");
4040

4141
public Resource(Resource myRes) {
4242
this.file = myRes.getFile();
@@ -219,7 +219,7 @@ public String getProjectName() {
219219
if (resource != null) {
220220
return resource.getProject().getName();
221221
}
222-
return projectName;
222+
return defaultName;
223223
}
224224

225225
public String getProjectPath() {
@@ -229,6 +229,29 @@ public String getProjectPath() {
229229
return "";
230230
}
231231

232+
public String getWorkspaceLocation() {
233+
if (resource != null) {
234+
return resource.getWorkspace().getRoot().getLocation().toFile().toString();
235+
}
236+
return "";
237+
}
238+
239+
/*
240+
public String getWorkspaceName() {
241+
if (resource != null) {
242+
return resource.getWorkspace().getRoot().
243+
}
244+
return defaultName;
245+
}
246+
*/
247+
248+
public String getWorkspaceLocName() {
249+
if (resource != null) {
250+
return resource.getWorkspace().getRoot().getLocation().toFile().getName();
251+
}
252+
return defaultName;
253+
}
254+
232255
public String getLineSeparator(OS os) {
233256
switch(os) {
234257
case osUnix:

plugin/src/de/anbos/eclipse/easyshell/plugin/types/Variable.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public String resolve(Object object, Object parameter) {
7171
};
7272
}),
7373
// ${easyshell:resource_path}
74-
varResourcePath(true, false, "resource_path", "relative path to workspace of file or directory", new IVariableResolver() {
74+
varResourcePath(true, false, "resource_path", "relative path of file or directory (to workspace)", new IVariableResolver() {
7575
public String resolve(Object object, Object parameter) {
7676
if(!(object instanceof Resource)) {
7777
return "";
@@ -152,7 +152,7 @@ public String resolve(Object object, Object parameter) {
152152
};
153153
}),
154154
// ${easyshell:container_path}
155-
varContainerPath(true, false, "container_path", "relative path to workspace of file directory or directory itself", new IVariableResolver() {
155+
varContainerPath(true, false, "container_path", "relative path of file's parent directory or directory itself (to workspace)", new IVariableResolver() {
156156
public String resolve(Object object, Object parameter) {
157157
if(!(object instanceof Resource)) {
158158
return "";
@@ -179,7 +179,7 @@ public String resolve(Object object, Object parameter) {
179179
};
180180
}),
181181
// ${easyshell:parent_path} for file it's equal to ${easyshell:container_path}
182-
varParentPath(true, false, "parent_path", "relative path to workspace of parent directory\n\nfor files it's equal to ${easyshell:container_path}", new IVariableResolver() {
182+
varParentPath(true, false, "parent_path", "relative path of parent directory (to workspace)\n\nfor files it's equal to ${easyshell:container_path}", new IVariableResolver() {
183183
public String resolve(Object object, Object parameter) {
184184
if(!(object instanceof Resource)) {
185185
return "";
@@ -203,14 +203,37 @@ public String resolve(Object object, Object parameter) {
203203
};
204204
}),
205205
// ${easyshell:project_path}
206-
varProjectPath(true, false, "project_path", "relative path to workspace of project", new IVariableResolver() {
206+
varProjectPath(true, false, "project_path", "relative path of project (to workspace)", new IVariableResolver() {
207207
public String resolve(Object object, Object parameter) {
208208
if(!(object instanceof Resource)) {
209209
return "";
210210
}
211211
return ((Resource)object).getProjectPath();
212212
};
213213
}),
214+
// ${easyshell:workspace_loc}
215+
varWorkspaceLoc(true, false, "workspace_loc", "absolute path of workspace", new IVariableResolver() {
216+
public String resolve(Object object, Object parameter) {
217+
if(!(object instanceof Resource)) {
218+
return "";
219+
}
220+
return ((Resource)object).getWorkspaceLocation();
221+
};
222+
}),
223+
/*
224+
// ${easyshell:workspace_name}
225+
varWorkspaceName(true, false, "workspace_name", "name of workspace (same as workspace_foldername if not configured)", new IVariableResolver() {
226+
public String resolve(Object object, Object parameter) {
227+
return ((Resource)object).getWorkspaceName();
228+
};
229+
}),
230+
*/
231+
// ${easyshell:workspace_loc_name}
232+
varWorkspaceLocName(true, false, "workspace_loc_name", "name of workspace's folder", new IVariableResolver() {
233+
public String resolve(Object object, Object parameter) {
234+
return ((Resource)object).getWorkspaceLocName();
235+
};
236+
}),
214237
// ${easyshell:windows_drive} == {0}
215238
varWindowsDrive(true, false, "windows_drive", "drive letter of file or directory on Windows", new IVariableResolver() {
216239
public String resolve(Object object, Object parameter) {

0 commit comments

Comments
 (0)