if (isExcluded(javaFile)) {
return;
}
try {
final IDocumentProvider provider = new TextFileDocumentProvider();
provider.connect(htmlFile);
final IDocument document = provider.getDocument(htmlFile);
LDL = document.getLineDelimiter(0).length();
int sc = 0;
boolean commented = false;
String wid_const = DocumentHelper.WICKET;
for (int i = 0; i < document.getNumberOfLines(); i++) {
final IRegion li = document.getLineInformation(i);
final String line = document.get(li.getOffset(), li.getLength());
if (line.contains("<!--")) {
commented = true;
continue;
}
if (line.contains("-->")) {
commented = false;
continue;
}
if (line.contains(QWickieActivator.WICKET_DTD)) {
wid_const = DocumentHelper.getWicketNamespace(line);
}
final String wid_const_id = wid_const + ":id=\"";
if (line.contains(wid_const_id) && !commented) {
final String wid = line.split(wid_const_id)[1].split("\"")[0];
int jlc = getJavaLine(javaFile, wid);
if (jlc == -1) { // wicket id was not found in this java file
// get the supertypes for the WebPage (maybe it's added in a BasePage?)
final List<Object> superTypes = TypeHelper.getSupertypes(javaFile);
for (final Object superType : superTypes) {
if (superType instanceof IFile) {
jlc = getJavaLine((IFile) superType, wid);
} else if (superType instanceof IClassFile) {
jlc = getJavaLine((IClassFile) superType, wid);
}
if (jlc == -1) {
// not found, then search in the used types
final List<JavaElement> wcts = TypeHelper.getWicketComponentTypes(javaFile);
for (final JavaElement wct : wcts) {
jlc = getJavaLine(wct, wid);
if (jlc > -1) {
break;
}
}
if (jlc == -1) {
// not found, then search in the used models
final List<IVariableBinding> wmts = TypeHelper.getWicketModelTypes(javaFile);
for (final IVariableBinding wmt : wmts) {
if (wid.equals(wmt.getName())) {
jlc = 0;
break;
}
}
}
}
if (jlc > -1) { // found, so don't go further
break;
}
}
if (jlc == -1) {
final int widPos = sc + line.indexOf("\"" + wid + "\"") + 1;
FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
IRegion tagBegin = frda.find(widPos, "<", false, true, false, false);
IRegion tagEnd = frda.find(tagBegin.getOffset(), " ", true, true, false, false);
String htmlTag = document.get(tagBegin.getOffset() + 1, tagEnd.getOffset() - tagBegin.getOffset() - 1);
String htmlSnippet = htmlTag.toLowerCase();
if (htmlFile != null && "input".equals(htmlSnippet)) {
tagEnd = frda.find(tagBegin.getOffset(), ">", true, true, false, false);
htmlSnippet = document.get(tagBegin.getOffset() + 1, tagEnd.getOffset() - tagBegin.getOffset() - 1).toLowerCase().trim();
if (htmlSnippet.contains("type")) {
final String[] hss = htmlSnippet.split(" ");
if (hss != null) {
for (int j = 0; j < hss.length; j++) {
String hs = hss[j];
if (hs.startsWith("type")) {
htmlSnippet = htmlTag + " " + hs.replace("type=", "").split("\"")[1];
}
}
}
} else {
htmlSnippet = htmlTag.toLowerCase();
}
}
addMarker(htmlFile, getErrorText(wid), wid, htmlSnippet, i, widPos, wid.length());
markJava(javaFile, wid, htmlSnippet);
}
}
}
sc += li.getLength() + LDL;
}
provider.disconnect(htmlFile);
} catch (final Exception e) {
QWickieActivator.getDefault().getLog().log(new Status(Status.ERROR, QWickieActivator.PLUGIN_ID, "Error in builder", e));
}
}