private void processInterest(String interest, int lineStart, String decoratorPrefix, SourceType sourceType) { int sourcePosition = lineStart; String sourceString = interest; if (!StringUtils.contains(sourceString, ".")) { if (classNameToFullyQualified.containsKey(sourceString)) { sourceString = classNameToFullyQualified.get(sourceString); } } if (lineContainsClassBlacklist(sourceString)) { JavaLine dr = new JavaLine(); dr.setDescription(decoratorPrefix + " '" + sourceString + "' at line " + sourcePosition); dr.setLineNumber(sourcePosition); dr.setSourceType(sourceType); dr.setPattern(sourceString); this.results.add(dr); } }
@Override public boolean process(AbstractDecoration result) { if (result == null || !(result instanceof JavaLine)) { return false; } JavaLine javaLine = (JavaLine) result; // if the source type is not provided, apply to all source types. if (sourceType != null) { if (javaLine.getSourceType() != sourceType) { // not of interest. return false; } } return super.process(result); } }
@Override public void process(AbstractDecoration result) { if (result == null || !(result instanceof JavaLine)) { // not of interest. return; } JavaLine javaLine = (JavaLine) result; // if the source type is not provided, apply to all source types. if (sourceType != null) { if (javaLine.getSourceType() != sourceType) { // not of interest. return; } } super.process(result); } }
private void processName(Name name, String decoratorPrefix, int position) { if (name == null) return; int sourcePosition = position; String sourceString = name.toString(); if (!StringUtils.contains(sourceString, ".")) { if (classNameToFullyQualified.containsKey(sourceString)) { sourceString = classNameToFullyQualified.get(sourceString); } } if (lineContainsClassBlacklist(sourceString)) { JavaLine dr = new JavaLine(); dr.setDescription(decoratorPrefix + " '" + sourceString + "' at line " + sourcePosition); dr.setLineNumber(sourcePosition); dr.setSourceType(SourceType.TYPE); dr.setPattern(sourceString); // dr.setAstNode(name); results.add(dr); } }
@Override protected List<AbstractDecoration> matchResults(FileMetadata meta) { List<AbstractDecoration> results = new LinkedList<AbstractDecoration>(); for (AbstractDecoration dr : meta.getDecorations()) { if (dr instanceof JavaLine) { JavaLine result = (JavaLine) dr; if (sourceType != null) { if (result.getSourceType() != sourceType) { // not of interest. continue; } } if (regexPattern.matcher(dr.getPattern()).find()) { results.add(dr); } } } return results; } }
private void processType(Type type, String decoratorPrefix, SourceType sourceType) { if (type == null) return; int sourcePosition = cu.getLineNumber(type.getStartPosition()); String sourceString = type.toString(); if (!StringUtils.contains(sourceString, ".")) { if (classNameToFullyQualified.containsKey(sourceString)) { sourceString = classNameToFullyQualified.get(sourceString); } } if (lineContainsClassBlacklist(sourceString)) { JavaLine dr = new JavaLine(); dr.setDescription(decoratorPrefix + " '" + sourceString + "' at line " + sourcePosition); dr.setLineNumber(sourcePosition); dr.setSourceType(sourceType); dr.setPattern(sourceString); // dr.setAstNode(type); results.add(dr); } }