LOGGER.log(Level.WARNING, "Not found wp-config.php");
return;
}
try {
Lookup lookup = config.getLookup();
EditorCookie ec = lookup.lookup(EditorCookie.class);
if (ec == null) {
return;
}
final StyledDocument docment = ec.openDocument();
if (docment == null) {
return;
}
List<String> lines = config.asLines(Charset.UTF8);
Pattern pattern = Pattern.compile(DEBUG_REGEX);
int lineNumber = 0;
for (String line : lines) {
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
// change
final int startOffset = NbDocument.findLineOffset(docment, lineNumber);
final int removeLength = line.length();
NbDocument.runAtomic(docment, new Runnable() {
@Override
public void run() {
try {
docment.remove(startOffset, removeLength);
docment.insertString(startOffset, String.format(WP_DEBUG_FORMAT, debugLv), null);
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
});
}
lineNumber++;
}
ec.saveDocument();
} catch (IOException ex) {
LOGGER.log(Level.WARNING, null, ex);
}
}