Skip to content

Commit fe32dc6

Browse files
committed
use libraries from target instead of using own bundle with those dependencies
1 parent a52d800 commit fe32dc6

File tree

8 files changed

+40
-50
lines changed

8 files changed

+40
-50
lines changed

com.googlecode.cppcheclipse.core/META-INF/MANIFEST.MF

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0",
88
org.eclipse.ui;bundle-version="3.5.0",
99
org.eclipse.core.resources;bundle-version="3.5.0",
1010
org.eclipse.core.net;bundle-version="1.2.0",
11-
com.googlecode.cppcheclipse.lib;bundle-version="0.9.8"
11+
com.google.guava;bundle-version="12.0.0",
12+
org.apache.commons.codec;bundle-version="1.4.0",
13+
org.apache.commons.io;bundle-version="2.0.1",
14+
org.apache.commons.exec;bundle-version="1.1.0"
1215
Bundle-ActivationPolicy: lazy
1316
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
1417
Export-Package: com.googlecode.cppcheclipse.core,

com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Appendages.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import java.util.LinkedList;
77
import java.util.List;
88

9-
import org.apache.commons.lang.StringUtils;
109
import org.eclipse.jface.preference.IPreferenceStore;
1110

11+
import com.google.common.base.Joiner;
12+
import com.google.common.base.Splitter;
1213
import com.googlecode.cppcheclipse.core.utils.SerializeHelper;
1314

1415
public class Appendages implements TableModel<File> {
@@ -25,8 +26,8 @@ public Appendages(IPreferenceStore preferenceStore) {
2526
}
2627

2728
private void load() {
28-
String[] values = StringUtils.split(preferenceStore
29-
.getString(IPreferenceConstants.P_APPENDAGES), DELIMITER);
29+
Iterable<String> values = Splitter.on(DELIMITER).split(preferenceStore
30+
.getString(IPreferenceConstants.P_APPENDAGES));
3031
for (String file : values) {
3132
try {
3233
files.add((File) SerializeHelper.fromString(file));
@@ -42,8 +43,7 @@ public void save() throws IOException {
4243
for (File file : files) {
4344
values.add(SerializeHelper.toString(file));
4445
}
45-
preferenceStore.setValue(IPreferenceConstants.P_APPENDAGES, StringUtils
46-
.join(values, DELIMITER));
46+
preferenceStore.setValue(IPreferenceConstants.P_APPENDAGES, Joiner.on(DELIMITER).join(values));
4747
}
4848

4949
public void removeAll() {

com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/SuppressionProfile.java

+13-25
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@
44
import java.io.IOException;
55
import java.util.Collection;
66
import java.util.Iterator;
7+
import java.util.List;
78
import java.util.StringTokenizer;
89

9-
import org.apache.commons.collections.MultiMap;
10-
import org.apache.commons.collections.map.MultiValueMap;
1110
import org.eclipse.core.resources.IProject;
1211
import org.eclipse.jface.preference.IPersistentPreferenceStore;
1312
import org.eclipse.jface.preference.IPreferenceStore;
1413

14+
import com.google.common.collect.LinkedListMultimap;
15+
import com.google.common.collect.ListMultimap;
16+
1517
public class SuppressionProfile implements TableModel<Suppression> {
1618
private static final String DELIMITER = "!";
17-
private final MultiMap suppressionList; // this does not allow generics so
18-
// far,
19-
// contains File as key and Suppression
20-
// as value
19+
20+
// contains the suppressions per file
21+
private final ListMultimap<File, Suppression> suppressionList;
2122
private final IPreferenceStore projectPreferences;
2223
private final IProject project;
2324

2425
public SuppressionProfile(IPreferenceStore projectPreferences,
2526
IProject project) {
2627
this.projectPreferences = projectPreferences;
27-
this.suppressionList = new MultiValueMap();
28+
this.suppressionList = LinkedListMultimap.create();
2829
this.project = project;
2930
load();
3031
}
@@ -95,14 +96,9 @@ private File makeAbsoluteFile(File file) {
9596
}
9697

9798
public boolean isFileSuppressed(File file) {
98-
Collection<?> collection = (Collection<?>) suppressionList
99+
List<Suppression> suppressions = suppressionList
99100
.get(makeAbsoluteFile(file));
100-
if (collection == null || collection.isEmpty())
101-
return false;
102-
103-
Iterator<?> iterator = collection.iterator();
104-
while (collection == null || iterator.hasNext()) {
105-
Suppression suppression = (Suppression) iterator.next();
101+
for (Suppression suppression : suppressions) {
106102
if (suppression.isFileSuppression())
107103
return true;
108104
}
@@ -115,15 +111,9 @@ public boolean isProblemInLineSuppressed(File file, String problemId,
115111
if (file == null) {
116112
return false;
117113
}
118-
Collection<?> collection = (Collection<?>) suppressionList
114+
List<Suppression> suppressions = suppressionList
119115
.get(makeAbsoluteFile(file));
120-
if (collection == null || collection.isEmpty()) {
121-
return false;
122-
}
123-
124-
Iterator<?> iterator = collection.iterator();
125-
while (iterator.hasNext()) {
126-
Suppression suppression = (Suppression) iterator.next();
116+
for (Suppression suppression : suppressions) {
127117
if (suppression.isFileSuppression()) {
128118
return true;
129119
}
@@ -134,16 +124,14 @@ public boolean isProblemInLineSuppressed(File file, String problemId,
134124
return false;
135125
}
136126

137-
public Collection<?> getSuppressions() {
127+
public Collection<Suppression> getSuppressions() {
138128
return suppressionList.values();
139129
}
140130

141-
@SuppressWarnings("unchecked")
142131
public Iterator<Suppression> iterator() {
143132
return suppressionList.values().iterator();
144133
}
145134

146-
@SuppressWarnings("unchecked")
147135
public Suppression[] toArray() {
148136
return (Suppression[]) suppressionList.values().toArray(new Suppression[0]);
149137
}

com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/CppcheckCommand.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
import javax.xml.parsers.ParserConfigurationException;
1414
import javax.xml.xpath.XPathExpressionException;
1515

16-
import org.apache.commons.lang.StringUtils;
1716
import org.eclipse.core.resources.IFile;
1817
import org.eclipse.core.resources.IProject;
1918
import org.eclipse.core.runtime.CoreException;
2019
import org.eclipse.core.runtime.IProgressMonitor;
2120
import org.eclipse.jface.preference.IPreferenceStore;
2221
import org.xml.sax.SAXException;
2322

23+
import com.google.common.base.Joiner;
24+
import com.google.common.base.Strings;
2425
import com.googlecode.cppcheclipse.core.Appendages;
2526
import com.googlecode.cppcheclipse.core.Checker;
2627
import com.googlecode.cppcheclipse.core.CppcheclipsePlugin;
@@ -118,7 +119,7 @@ public CppcheckCommand(IConsole console, String binaryPath,
118119
}
119120

120121
if (!enableFlags.isEmpty()) {
121-
arguments.add("--enable=" + StringUtils.join(enableFlags, ","));
122+
arguments.add("--enable=" + Joiner.on(",").join(enableFlags));
122123
}
123124
}
124125

@@ -146,21 +147,21 @@ public CppcheckCommand(IConsole console, String binaryPath,
146147
// which target platform is used?
147148
String targetPlatform = settingsStore
148149
.getString(IPreferenceConstants.P_TARGET_PLATFORM);
149-
if (!StringUtils.isBlank(targetPlatform)) {
150+
if (!targetPlatform.isEmpty()) {
150151
arguments.add("--platform=" + targetPlatform);
151152
}
152153

153154
// which C language standard is used?
154155
String languageStandardC = settingsStore
155156
.getString(IPreferenceConstants.P_LANGUAGE_STANDARD_C);
156-
if (!StringUtils.isBlank(languageStandardC)) {
157+
if (!languageStandardC.isEmpty()) {
157158
arguments.add("--std=" + languageStandardC);
158159
}
159160

160161
// which C++ language standard is used?
161162
String languageStandardCpp = settingsStore
162163
.getString(IPreferenceConstants.P_LANGUAGE_STANDARD_CPP);
163-
if (!StringUtils.isBlank(languageStandardCpp)) {
164+
if (!languageStandardCpp.isEmpty()) {
164165
arguments.add("--std=" + languageStandardCpp);
165166
}
166167

@@ -287,14 +288,14 @@ public static Problem parseResult(String line, IProject project) {
287288
try {
288289

289290
File filename;
290-
if (StringUtils.isBlank(lineParts[0])) {
291+
if (Strings.isNullOrEmpty(lineParts[0])) {
291292
filename = null;
292293
} else {
293294
filename = new File(lineParts[0]);
294295
}
295296
// if line is empty set it to -1
296297
int lineNumber;
297-
if (StringUtils.isBlank(lineParts[1])) {
298+
if (Strings.isNullOrEmpty(lineParts[1])) {
298299
lineNumber = -1;
299300
} else {
300301
lineNumber = Integer.parseInt(lineParts[1]);

com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/HttpClientService.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
import java.net.URL;
1515
import java.net.UnknownHostException;
1616

17-
import org.apache.commons.lang.StringUtils;
1817
import org.eclipse.core.net.proxy.IProxyData;
1918
import org.eclipse.core.net.proxy.IProxyService;
2019

20+
import com.google.common.base.Strings;
21+
2122
public class HttpClientService implements IHttpClientService {
2223

2324
private IProxyService proxyService;
@@ -65,7 +66,7 @@ private Proxy getProxyFromProxyData(IProxyData proxyData) throws UnknownHostExce
6566

6667
InetSocketAddress sockAddr = new InetSocketAddress(InetAddress.getByName(proxyData.getHost()), proxyData.getPort());
6768
Proxy proxy = new Proxy(proxyType, sockAddr);
68-
if (!StringUtils.isEmpty(proxyData.getUserId())) {
69+
if (!Strings.isNullOrEmpty(proxyData.getUserId())) {
6970
Authenticator.setDefault(new ProxyAuthenticator(proxyData.getUserId(), proxyData.getPassword()));
7071
}
7172
return proxy;

com.googlecode.cppcheclipse.lib/readme.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
== Included JARs ==
2-
Apache Commons IO 2.0.1
3-
Apache Commons Collections 3.2.1
4-
Apache Commons Lang 2.5
5-
Apache Commons Exec 1.1
6-
Apache Commons Codec 1.4
2+
Apache Commons IO 2.0.1 (bug in TeeOutputStream, http://stackoverflow.com/questions/9290774/chunkwise-copy-data-from-inputstream-to-outputstream-getting-byte-at-the-end, no Guava solution)
3+
Apache Commons Collections 3.2.1 (should use Guava as collections is dead)
4+
Apache Commons Lang 2.5 (only StringUtils used, could use Guava Strings.isEmptyOrNull)
5+
Apache Commons Exec 1.1, (available in Orbit, http://download.eclipse.org/tools/orbit/downloads/drops/I20120928145848/)
6+
Apache Commons Codec 1.4, (for Base64 in SerializeHelper, available in Orbit, not available in Guava)
77

88
== TODO ==
9-
- check if changing to Google-Collections might improve quality: http://code.google.com/p/google-collections/
10-
- use POM first approach to download those dependencies from maven (only if the limitation in [1] are solved or
119
- use a P2 repository which does already provide those libraries as OSGi bundles
10+
- remove this library
11+
-> use existing bundles from Eclipse Orbit!
1212

1313
== Links ==
1414
http://wiki.eclipse.org/Eclipse_Plug-in_Development_FAQ#I.27m_using_third_party_jar_files_and_my_plug-in_is_not_working...

com.googlecode.cppcheclipse.ui.tests/src/com/googlecode/cppcheclipse/ui/ToolchainSettingsTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.io.IOException;
99
import java.util.Collection;
1010

11-
import org.apache.commons.io.FileUtils;
1211
import org.eclipse.cdt.core.CCorePlugin;
1312
import org.eclipse.cdt.core.CProjectNature;
1413
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
@@ -30,7 +29,6 @@
3029
import org.eclipse.core.resources.IProject;
3130
import org.eclipse.core.resources.IProjectDescription;
3231
import org.eclipse.core.resources.IResource;
33-
import org.eclipse.core.resources.IWorkspace;
3432
import org.eclipse.core.resources.IWorkspaceRoot;
3533
import org.eclipse.core.resources.IWorkspaceRunnable;
3634
import org.eclipse.core.resources.ResourcesPlugin;

com.googlecode.cppcheclipse.ui/META-INF/MANIFEST.MF

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.4.0",
1111
org.eclipse.core.resources;bundle-version="3.4.0",
1212
org.eclipse.cdt.core;bundle-version="5.0.0",
1313
org.eclipse.ui.editors;bundle-version="3.4.0",
14-
com.googlecode.cppcheclipse.lib;bundle-version="0.9.8",
1514
org.eclipse.jface.text;bundle-version="3.4.0",
1615
org.eclipse.cdt.make.core;bundle-version="5.0.0"
1716
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

0 commit comments

Comments
 (0)