com.cflint.tools.PrecedingCommentReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of CFLint Show documentation
Show all versions of CFLint Show documentation
A static code analysis tool for ColdFusion (in the spirit of FindBugs and Lint). With CFLint, you are able to analyze your ColdFusion code base for code violations.
package com.cflint.tools;
import org.antlr.v4.runtime.Token;
import com.cflint.plugins.Context;
import cfml.CFSCRIPTLexer;
public class PrecedingCommentReader {
public static final String CFC_DEFAULT_EXTENSION = ".cfc";
public static final String CFM_DEFAULT_EXTENSION = ".cfm";
public static String getMultiLine(Context context, final Token token) {
Iterable tokens = context.beforeTokens(token);
for (Token currentTok : tokens) {
if (currentTok.getChannel() == Token.HIDDEN_CHANNEL && currentTok.getType() == CFSCRIPTLexer.ML_COMMENT) {
String mlText = currentTok.getText();
return mlText == null ? null : mlText.trim();
} else if (currentTok.getChannel() == Token.HIDDEN_CHANNEL && currentTok.getType() == CFSCRIPTLexer.NEWLINE){
} else if (currentTok.getLine() < token.getLine()) {
break;
}
}
return null;
}
}