void checkFile(IResource resource) { if (resource instanceof IFile) { IFile file = (IFile) resource; if (file.getName().endsWith("xfm.xmi")) { String thisUri = resource.getFullPath().toString(); featureModelUri = getFeatureModelUri(file.getProject()); if (thisUri.equals(featureModelUri)) refreshFeatureModel(file.getProject()); } if (file.getName().endsWith(".v")) { builder.deleteMarkers(file); checkFilenameDepenency(file); checkFileContents(file); } if (file.getName().endsWith(".java")) { try { builder.deleteMarkers(file); List<CommentStructure> comments = buildCommentsStructure(loadFile(file)); if (comments.size() > 0) { for (CommentStructure c : comments) { IParseResult result = injector .getInstance(FeaturesParser.class) .parse("FeatureClause", new ByteArrayInputStream(c.clause.getBytes())); if (result.getParseErrors().size() > 0) { String message = ""; for (SyntaxError err : result.getParseErrors()) message += err.getMessage() + "\n"; Exception e = new RuntimeException("parse error: " + message); log.error("error while parsing feature clause", e); } EObject clause = result.getRootASTElement(); if (clause instanceof Feature) { String feature = clause.eGet(clause.eClass().getEStructuralFeature("feature")).toString(); if (!isFeatureDefined(file, feature)) addMarkerIfNotDefined(feature, file, c.line); } else for (EObject e : EcoreUtil2.eAllContentsAsList(clause)) { if (e instanceof Feature || e instanceof Atom) { String feature = e.eGet(e.eClass().getEStructuralFeature("feature")).toString(); if (!isFeatureDefined(file, feature)) addMarkerIfNotDefined(feature, file, c.line); } } } } } catch (ResourceException e) { log.error("error loading file", e); } catch (Throwable e) { log.error("error loading file", e); } } } }
private String getFeatureModelUri(IProject p) { String uri = DotVBuilder.getValue(p, PreferenceConstants.FEATURE_MODEL_URI); if (uri.toLowerCase().startsWith(PLATFORM_RESOURCE)) { uri = uri.substring(PLATFORM_RESOURCE.length()); } return uri; }
private void checkFilenameDepenency(IFile file) { String fileFeatureToken = builder.getValue(file, PreferenceConstants.FEATURE_IN_FILENAME); String fileName = file.getName(); int p = fileName.indexOf(fileFeatureToken); if (p >= 0) { String featureName = fileName.substring(p + 1, fileName.indexOf('.', p)); if (!isFeatureDefined(file, featureName)) { builder.addMarker( file, "Feature '" + featureName + "' referenced in file name does not exist in in feature model.", 0, IMarker.SEVERITY_ERROR); } } }
private String extractFeatureName_Joinpoint(IFile file, String line) { String tag = DotVBuilder.getValue(file, PreferenceConstants.JOINPOINT_SECTION_BEGIN); String s = tryToFindAndExtract(line, tag); // if ( s != null ) return s; // tag = DotVBuilder.getValue(file, PreferenceConstants.JOINPOINT_SECTION_END); // s = tryToFindAndExtract( line, tag ); return s; }
private String extractFeatureName_FeatureDependency(IFile file, String line) { String tag = DotVBuilder.getValue(file, PreferenceConstants.FEATURE_BEGIN); String s = tryToFindAndExtract(line, tag); // if ( s != null ) return s; // tag = builder.getValue(file, PreferenceConstants.FEATURE_END); // s = tryToFindAndExtract( line, tag ); return s; }
private String extractAdvice(IFile file, int lineNo, String s) { String[] pair = s.split(":"); if (pair.length != 2) { builder.addMarker(file, "Invalid Advice Syntax", lineNo, IMarker.SEVERITY_ERROR); return null; } if (pair[0].equals("before") || pair[0].equals("after") || pair[0].equals("instead")) return pair[1]; return null; }
private String extractFeatureName_Advice(IFile file, String line, int lineNo) { String tag = DotVBuilder.getValue(file, PreferenceConstants.ADVICE_SECTION_BEGIN); String s = tryToFindAndExtract(line, tag); if (s != null) return extractAdvice(file, lineNo, s); // tag = DotVBuilder.getValue(file, PreferenceConstants.ADVICE_SECTION_END); // s = tryToFindAndExtract( line, tag ); // if ( s != null ) { // return extractAdvice(file, lineNo, s); // } return null; }
private void addMarkerIfNotDefined(String featureName, IFile file, int line) { if (featureName != null) { if (!isFeatureDefined(file, featureName)) { builder.addMarker( file, "Feature '" + featureName + "' referenced in file does not exist in feature model.", line, IMarker.SEVERITY_ERROR); } } }