当前位置: 首页>>代码示例>>Java>>正文


Java MatcherContext.isTaskCanceled方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MasterMatcherTest.java

示例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;
}
 
开发者ID:jdemeschew,项目名称:stpnb,代码行数:19,代码来源:SilverstripeBracesMatching.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:XMLBraceMatcher.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:XMLBraceMatcher.java

示例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;
}
 
开发者ID:golo-lang,项目名称:golo-netbeans,代码行数:39,代码来源:BracesMatcherGoloSupport.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:82,代码来源:HtmlBracesMatching.java

示例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];
}
 
开发者ID:jdemeschew,项目名称:stpnb,代码行数:43,代码来源:SilverstripeBracesMatching.java


注:本文中的org.netbeans.spi.editor.bracesmatching.MatcherContext.isTaskCanceled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。