blob: a2821dabd86e6e6e6c1d46b92ebc22e842a1ec1f (
plain) (
blame)
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
|
/*******************************************************************************
* Copyright (c) 2010 Boeing.
* 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:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.coverage.vcast;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.osee.coverage.vcast.VcpSourceFile.SourceValue;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Lib;
/**
* Represents the <dir>.wrk/vcast.vcp file which lists all the source files and results files specified in this
* directory.
*
* @author Donald G. Dunne
*/
public class VCastVcp {
List<VcpSourceFile> sourceFiles = new ArrayList<VcpSourceFile>();
List<VcpResultsFile> resultsFiles = new ArrayList<VcpResultsFile>();
private final String vcastDirectory;
public VCastVcp(String vcastDirectory) throws OseeCoreException, IOException {
this.vcastDirectory = vcastDirectory;
File vCastVcpFile = getFile();
if (!vCastVcpFile.exists()) {
throw new OseeArgumentException("VectorCast vcast.vcp file doesn't exist [%s]", vcastDirectory);
}
VcpSourceFile vcpSourceFile = null;
VcpResultsFile vcpResultsFile = null;
for (String line : Lib.fileToString(vCastVcpFile).split("\n")) {
if (line.startsWith("SOURCE_FILE_BEGIN")) {
vcpSourceFile = new VcpSourceFile(vcastDirectory);
} else if (line.startsWith("SOURCE_FILE_END")) {
sourceFiles.add(vcpSourceFile);
vcpSourceFile = null;
} else if (vcpSourceFile != null) {
vcpSourceFile.addLine(line);
} else if (line.startsWith("RESULT_FILE_BEGIN")) {
vcpResultsFile = new VcpResultsFile(vcastDirectory);
} else if (line.startsWith("RESULT_FILE_END")) {
resultsFiles.add(vcpResultsFile);
vcpResultsFile = null;
} else if (vcpResultsFile != null) {
vcpResultsFile.addLine(line);
}
}
}
public File getFile() {
return new File(vcastDirectory + "/vcast.vcp");
}
public VcpSourceFile getSourceFile(int index) {
for (VcpSourceFile vcpSourceFile : sourceFiles) {
if (vcpSourceFile.getValue(SourceValue.UNIT_NUMBER).equals(String.valueOf(index))) {
return vcpSourceFile;
}
}
return null;
}
public List<VcpSourceFile> getSourceFiles() {
return sourceFiles;
}
public List<VcpResultsFile> getResultsFiles() {
return resultsFiles;
}
}
|