Hello everyone,
I’m still working on the detection of pragmas into source
files and i would like to show you my source code, since I face a new problem.
This is the source code :
// If we
haven't already worked on this file
if (!visitedFiles.contains(_expression_.getContainingFilename()))
{
//
Get all the preprocessor statements in the current file
IASTPreprocessorStatement[]
ppps = (IASTPreprocessorStatement[])_expression_.getTranslationUnit().getAllPreprocessorStatements();
for (int i=0;
i<ppps.length; i++) {
IASTPreprocessorStatement
pps = ppps[i];
if (pps instanceof
IASTPreprocessorPragmaStatement) {
//
Now we verify its a hmpp pragma
if (pps.getRawSignature().startsWith(NEW_PREFIXE_PRAGMA)) {
String
artifactName = pps.getRawSignature().substring(NEW_PREFIXE_PRAGMA.length());
//
Generate the Source Info linked with our pragma
SourceInfo
sourceInfo = new SourceInfo();
sourceInfo.setStartingLine(pps.getFileLocation().getStartingLineNumber());
sourceInfo.setStart(pps.getFileLocation().getNodeOffset());
sourceInfo.setEnd(pps.getFileLocation().getNodeOffset()
+ pps.getFileLocation().getNodeLength());
sourceInfo.setConstructType(Artifact.PRAGMA);
//
Creation of this Artifact
Artifact
artifact = new Artifact(filename, pps.getFileLocation().getStartingLineNumber(),
1, artifactName, "NEW ARTIFACT", sourceInfo);
//
Adding our Artifact to scanReturn
scanReturn.addArtifact(artifact);
System.out.println("Artifact
: "+artifact);
nb_pragma++;
}
}
}
visitedFiles.add(_expression_.getContainingFilename());
}
And it works !!
But I have this error when executing this.
I have a java.lang.ArrayIndexOutOfBoundsException and I don’t
know where it’s coming from but I’m quite sure it’s coming
from this function.
I have already faced this ?
Thanks in advance for your help.
Georges Bossert
+33 (0)6.03.57.53.88
gbossert@xxxxxxxxx