/
Visitor.java
117 lines (94 loc) · 3.02 KB
/
Visitor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*******************************************************************************
* Copyright (c) 2013 Remain Software and others http://remainsoftware.com
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Gerd Wuetherich (gerd@gerd-wuetherich.de) - initial implementation
* Wim Jongman - adapted to pom builder
******************************************************************************/
package com.remainsoftware.tycho.pombuilder.core.internal;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.ManifestElement;
import com.remainsoftware.tycho.pombuilder.core.Constants;
import com.remainsoftware.tycho.pombuilder.core.IPom;
import com.remainsoftware.tycho.pombuilder.core.PomBuilderException;
/**
* <p>
* </p>
*
* @author Wim Jongman
*/
public class Visitor implements IResourceVisitor, IResourceDeltaVisitor {
/**
* {@inheritDoc}
*/
@Override
public boolean visit(IResource resource) throws CoreException {
if (resource.getType() != IResource.FILE) {
return true;
}
handle(resource);
return false;
}
/**
* {@inheritDoc}
*/
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
if (delta.getKind() == IResourceDelta.ADDED) {
return visit(delta.getResource());
} else if (delta.getKind() == IResourceDelta.REMOVED) {
} else if (delta.getKind() == IResourceDelta.CHANGED) {
return visit(delta.getResource());
}
return true;
}
/**
* <p>
* </p>
*
* @param resource
* @throws CoreException
*/
private void handle(IResource resource) throws CoreException {
try {
if (resource.getName().equals("MANIFEST.MF")) {
parseManifest(resource);
return;
}
if (resource.getName().endsWith(".product")) {
parseProduct(resource);
return;
}
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Constants.CORE,
e.getMessage(), e));
}
}
private void parseProduct(IResource resource) {
// TODO Auto-generated method stub
}
private void parseFeature(IResource resource) {
// TODO Auto-generated method stub
}
private void parseManifest(IResource resource) throws CoreException {
new ManifestParser().parse(resource);
}
}