blob: b7959dda2c4d4a2337d0d237eb8d2f760e4a2e04 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*******************************************************************************
* Copyright (c) 2007, 2011 David Green and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* David Green - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.wikitext.parser.markup.block;
import java.util.regex.Pattern;
import org.eclipse.mylyn.wikitext.parser.Attributes;
import org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType;
import org.eclipse.mylyn.wikitext.parser.markup.Block;
/**
* A block for detecting bugzilla-generated text such as: *** This bug has been marked as a duplicate of bug 1234 ***
*
* @author David Green
* @since 3.0
*/
public class BugzillaGeneratedCommentBlock extends Block {
private static Pattern pattern = Pattern
.compile("\\s*\\*\\*\\*\\s+((This bug has been)|(Bug \\d+ has been)).*?\\*\\*\\*\\s*"); //$NON-NLS-1$
@Override
public boolean canStart(String line, int lineOffset) {
if (lineOffset == 0 && line.length() > 0 && pattern.matcher(line).matches()) {
return true;
}
return false;
}
@Override
protected int processLineContent(String line, int offset) {
Attributes attributes = new Attributes();
attributes.setCssStyle("color: Blue;");// FIXME: hard-coded color? //$NON-NLS-1$
builder.beginBlock(BlockType.PARAGRAPH, attributes);
getMarkupLanguage().emitMarkupLine(getParser(), state, line, offset);
setClosed(true);
return -1;
}
@Override
public void setClosed(boolean closed) {
if (closed && !isClosed()) {
builder.endBlock(); // para
}
super.setClosed(closed);
}
}
|