Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2019-03-29 08:51:17 -0400
committerJan Belle2019-04-02 10:44:14 -0400
commit8cfabe4a58f5fe3853e30f094a9346af6e10741f (patch)
treec9bbe83242b61336298626fdb0c04f629ff8a598 /plugins
parentd941d5a98db578e4bff2c284b06a498f1aab1c23 (diff)
downloadorg.eclipse.etrice-8cfabe4a58f5fe3853e30f094a9346af6e10741f.tar.gz
org.eclipse.etrice-8cfabe4a58f5fe3853e30f094a9346af6e10741f.tar.xz
org.eclipse.etrice-8cfabe4a58f5fe3853e30f094a9346af6e10741f.zip
[common.ui] Support basic comments in modelpath description file
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathDescription.java72
1 files changed, 52 insertions, 20 deletions
diff --git a/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathDescription.java b/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathDescription.java
index 380365055..e784a61aa 100644
--- a/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathDescription.java
+++ b/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathDescription.java
@@ -41,10 +41,13 @@ public class ModelPathDescription {
private final List<IFolder> sourceDirectories;
private final List<IProject> projectDependencies;
+ private final List<IMarker> problemMarkers;
- private ModelPathDescription(List<IFolder> sourceDirectories, List<IProject> projectDependencies) {
+ private ModelPathDescription(List<IFolder> sourceDirectories, List<IProject> projectDependencies, List<IMarker> problemMarkers) {
this.sourceDirectories = sourceDirectories;
this.projectDependencies = projectDependencies;
+
+ this.problemMarkers = problemMarkers;
}
/**
@@ -62,6 +65,13 @@ public class ModelPathDescription {
}
/**
+ * @return the list of problem markers
+ */
+ public List<IMarker> getProblemMarkers() {
+ return problemMarkers;
+ }
+
+ /**
* Loads the modelpath description from a file.
*
* @param file the file to load from
@@ -93,6 +103,7 @@ public class ModelPathDescription {
private IWorkspaceRoot root;
private List<IFolder> srcDirs;
private List<IProject> projects;
+ private List<IMarker> problemMarkers;
private int lineNumber;
public ModelPathDescriptionLoader(IFile file) {
@@ -101,6 +112,7 @@ public class ModelPathDescription {
root = ResourcesPlugin.getWorkspace().getRoot();
srcDirs = new ArrayList<>();
projects = new ArrayList<>();
+ problemMarkers = new ArrayList<IMarker>();
lineNumber = 0;
}
@@ -109,11 +121,14 @@ public class ModelPathDescription {
try(BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()))) {
for(String line = reader.readLine(); line != null; line = reader.readLine(), lineNumber++) {
+ line = trimComments(line);
parseLine(line);
}
}
- return new ModelPathDescription(Collections.unmodifiableList(srcDirs), Collections.unmodifiableList(projects));
+ return new ModelPathDescription(Collections.unmodifiableList(srcDirs),
+ Collections.unmodifiableList(projects),
+ Collections.unmodifiableList(problemMarkers));
}
private void parseLine(String line) throws CoreException {
@@ -130,42 +145,59 @@ public class ModelPathDescription {
parseProject(str);
break;
default:
- createProblemMarker(IMarker.SEVERITY_ERROR, "unexpected keyword " + keyword);
+ addProblemMarker(IMarker.SEVERITY_ERROR, "unexpected keyword " + keyword);
}
}
}
+ private String trimComments(String line) {
+ int index = line.indexOf("//");
+ if(index != -1) {
+ line = line.substring(0, index);
+ }
+ return line;
+ }
+
private void parseSrcDir(String str) throws CoreException {
- if(Path.EMPTY.isValidPath(str)) {
- IFolder dir = project.getFolder(str);
- if(!dir.exists()) {
- createProblemMarker(IMarker.SEVERITY_WARNING, "directory " + dir.getFullPath() + " doesn't exist");
- }
- srcDirs.add(dir);
+ if(str.isEmpty()) {
+ addProblemMarker(IMarker.SEVERITY_ERROR, "directory path is missing");
+ return;
}
- else {
- createProblemMarker(IMarker.SEVERITY_ERROR, str + " isn't a valid path");
+ if(!Path.EMPTY.isValidPath(str)) {
+ addProblemMarker(IMarker.SEVERITY_ERROR, str + " isn't a valid path");
+ return;
+ }
+
+ IFolder dir = project.getFolder(str);
+ if(!dir.exists()) {
+ addProblemMarker(IMarker.SEVERITY_WARNING, "directory " + dir.getFullPath() + " doesn't exist");
}
+ srcDirs.add(dir);
}
private void parseProject(String str) throws CoreException {
- if(Path.EMPTY.isValidSegment(str)) {
- IProject project = root.getProject(str);
- if(!project.isAccessible()) {
- createProblemMarker(IMarker.SEVERITY_WARNING, "project " + project.getName() + " doesn't exist");
- }
- projects.add(project);
+ if(str.isEmpty()) {
+ addProblemMarker(IMarker.SEVERITY_ERROR, "project name is missing");
+ return;
+ }
+ if(!Path.EMPTY.isValidSegment(str)) {
+ addProblemMarker(IMarker.SEVERITY_ERROR, str + " isn't a valid project name");
+ return;
}
- else {
- createProblemMarker(IMarker.SEVERITY_ERROR, str + " isn't a valid project name");
+
+ IProject project = root.getProject(str);
+ if(!project.isAccessible()) {
+ addProblemMarker(IMarker.SEVERITY_WARNING, "project " + project.getName() + " doesn't exist");
}
+ projects.add(project);
}
- private void createProblemMarker(int severity, String message) throws CoreException {
+ private void addProblemMarker(int severity, String message) throws CoreException {
IMarker marker = file.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.SEVERITY, severity);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber + 1);
marker.setAttribute(IMarker.MESSAGE, message);
+ problemMarkers.add(marker);
}
}
} \ No newline at end of file

Back to the top