本文整理汇总了Java中org.netbeans.spi.editor.bracesmatching.MatcherContext.isTaskCanceled方法的典型用法代码示例。如果您正苦于以下问题:Java MatcherContext.isTaskCanceled方法的具体用法?Java MatcherContext.isTaskCanceled怎么用?Java MatcherContext.isTaskCanceled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.spi.editor.bracesmatching.MatcherContext
的用法示例。
在下文中一共展示了MatcherContext.isTaskCanceled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: block
import org.netbeans.spi.editor.bracesmatching.MatcherContext; //导入方法依赖的package包/类
private void block() throws InterruptedException {
blocking = true;
System.out.println(matcherId + ": blocking");
try {
//System.out.println("!!! Blocking: " + this + ", offset = " + context.getCaretOffset());
for( ; !breakOutFromTheLoop; ) {
if (MatcherContext.isTaskCanceled()) {
System.out.println(matcherId + ": cancelled");
return;
}
}
} finally {
//System.out.println("!!! Not Blocking: " + this + ", offset = " + context.getCaretOffset());
System.out.println(matcherId + ": block terminated");
blocking = false;
}
}
示例2: findOrigin
import org.netbeans.spi.editor.bracesmatching.MatcherContext; //导入方法依赖的package包/类
@Override
public int[] findOrigin() throws InterruptedException, BadLocationException {
if(MatcherContext.isTaskCanceled()) {
return null;
}
int offset = context.getSearchOffset();
TokenHierarchy th = TokenHierarchy.get(context.getDocument());
TokenSequence<SilverstripeTokenId> ts = th.tokenSequence(SilverstripeTokenId.getLanguage());
if(ts == null) {
return null;
}
ts.move(offset);
if(ts.moveNext() && SilverstripeTokenId.hasMatches(ts.token().id())) {
return new int[] {ts.token().offset(th), ts.token().offset(th) + ts.token().length()};
}
return null;
}
示例3: findOrigin
import org.netbeans.spi.editor.bracesmatching.MatcherContext; //导入方法依赖的package包/类
public int[] findOrigin() throws InterruptedException, BadLocationException {
if (MatcherContext.isTaskCanceled()) {
return null;
}
//so that we could use this from unit tests
int[] origin = doFindOrigin();
if(origin != null)
return origin;
defaultMatcher = BracesMatcherSupport.defaultMatcher(context, -1, -1);
return defaultMatcher.findOrigin();
}
示例4: findMatches
import org.netbeans.spi.editor.bracesmatching.MatcherContext; //导入方法依赖的package包/类
public int[] findMatches() throws InterruptedException, BadLocationException {
if (MatcherContext.isTaskCanceled()) {
return null;
}
if(defaultMatcher != null) {
return defaultMatcher.findMatches();
}
return doFindMatches();
}
示例5: matchEqualChar
import org.netbeans.spi.editor.bracesmatching.MatcherContext; //导入方法依赖的package包/类
public static int matchEqualChar(Document document, int offsetBackward, int limitBackward, int offsetForward, int limitForward, char origin, char matching) throws BadLocationException {
int lookaheadBackward = offsetBackward - limitBackward;
int lookaheadForward = limitForward - offsetForward;
// check the character at the left from the caret
Segment textBackward = new Segment();
document.getText(offsetBackward - lookaheadBackward, lookaheadBackward, textBackward);
int countBackward = 0;
int offsetMatchBackward = -1;
for (int i = 0; i < lookaheadBackward; i++) {
if (MatcherContext.isTaskCanceled()) {
return -1;
}
if (origin == textBackward.array[textBackward.offset + i]) {
countBackward++;
if (countBackward > 0 && (countBackward % 2) != 0) {
offsetMatchBackward = offsetBackward - (lookaheadBackward - i);
} else {
offsetMatchBackward = -1;
}
}
}
if (offsetMatchBackward == -1) {
// check the character at the right from the caret
Segment textForward = new Segment();
document.getText(offsetForward, lookaheadForward, textForward);
for (int i = 0; i < lookaheadForward; i++) {
if (MatcherContext.isTaskCanceled()) {
return -1;
}
if (origin == textForward.array[textForward.offset + i]) {
return offsetForward + i;
}
}
}
return offsetMatchBackward;
}
示例6: findOrigin
import org.netbeans.spi.editor.bracesmatching.MatcherContext; //导入方法依赖的package包/类
@Override
public int[] findOrigin() throws InterruptedException, BadLocationException {
int searchOffset = context.getSearchOffset();
((AbstractDocument) context.getDocument()).readLock();
try {
if (!testMode && MatcherContext.isTaskCanceled()) {
return null;
}
TokenSequence<HTMLTokenId> ts = Utils.getJoinedHtmlSequence(context.getDocument(), searchOffset);
TokenHierarchy<Document> th = TokenHierarchy.get(context.getDocument());
if (ts.language() == HTMLTokenId.language()) {
while (searchOffset != context.getLimitOffset()) {
int diff = ts.move(searchOffset);
searchOffset = searchOffset + (context.isSearchingBackward() ? -1 : +1);
if (diff == 0 && context.isSearchingBackward()) {
//we are searching backward and the offset is at the token boundary
if (!ts.movePrevious()) {
continue;
}
} else {
if (!ts.moveNext()) {
continue;
}
}
Token<HTMLTokenId> t = ts.token();
int toffs = ts.offset();
if (tokenInTag(t)) {
//find the tag beginning
do {
Token<HTMLTokenId> t2 = ts.token();
int t2offs = ts.offset();
if (!tokenInTag(t2)) {
return null;
} else if (t2.id() == HTMLTokenId.TAG_OPEN_SYMBOL) {
//find end
int tagNameEnd = -1;
while (ts.moveNext()) {
Token<HTMLTokenId> t3 = ts.token();
int t3offs = ts.offset();
if (!tokenInTag(t3) || t3.id() == HTMLTokenId.TAG_OPEN_SYMBOL) {
return null;
} else if (t3.id() == HTMLTokenId.TAG_CLOSE_SYMBOL) {
if ("/>".equals(t3.text().toString())) {
//do no match empty tags
return null;
} else {
int from = t2offs;
int to = t3offs + t3.length();
if (tagNameEnd != -1) {
return new int[]{from, to,
from, tagNameEnd,
to - 1, to};
} else {
return new int[]{from, to};
}
}
} else if (t3.id() == HTMLTokenId.TAG_OPEN || t3.id() == HTMLTokenId.TAG_CLOSE) {
tagNameEnd = t3offs + t3.length();
}
}
break;
}
} while (ts.movePrevious());
} else if (t.id() == HTMLTokenId.BLOCK_COMMENT) {
String tokenImage = t.text().toString();
if (tokenImage.startsWith(BLOCK_COMMENT_START) && context.getSearchOffset() < toffs + BLOCK_COMMENT_START.length()) {
return new int[]{toffs, toffs + BLOCK_COMMENT_START.length()};
} else if (tokenImage.endsWith(BLOCK_COMMENT_END) && (context.getSearchOffset() >= toffs + tokenImage.length() - BLOCK_COMMENT_END.length())) {
return new int[]{toffs + t.length() - BLOCK_COMMENT_END.length(), toffs + t.length()};
}
}
}
}
return null;
} finally {
((AbstractDocument) context.getDocument()).readUnlock();
}
}
示例7: findMatches
import org.netbeans.spi.editor.bracesmatching.MatcherContext; //导入方法依赖的package包/类
@Override
public int[] findMatches() throws InterruptedException, BadLocationException {
Document doc = context.getDocument();
if(MatcherContext.isTaskCanceled()) {
return null;
}
final Source source = Source.create(doc);
if(source == null) {
return null;
}
final int[][] ret = new int[1][];
try {
ParserManager.parse(Collections.singleton(source), new UserTask() {
@Override
public void run(ResultIterator resultIterator) throws Exception {
if(MatcherContext.isTaskCanceled()) {
return;
}
int searchOffset = context.getSearchOffset();
if(resultIterator == null) {
ret[0] = new int[]{searchOffset, searchOffset};
return;
}
SilverstripeParserResult parserResult = (SilverstripeParserResult)resultIterator.getParserResult();
if(!parserResult.getParserExceptions().isEmpty()) {
return;
}
BraceMatchingVisitor visitor = new BraceMatchingVisitor(searchOffset);
visitor.visit(parserResult.getTemplateContext());
if(visitor.getMatchedRegions().isEmpty()) {
ret[0] = new int[]{searchOffset, searchOffset};
} else {
ret[0] = ArrayUtils.toPrimitive(visitor.getMatchedRegions().toArray(new Integer[visitor.getMatchedRegions().size()]));
}
}
});
} catch (ParseException ex) {
Exceptions.printStackTrace(ex);
}
return ret[0];
}