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


Java Task.create方法代码示例

本文整理汇总了Java中org.netbeans.spi.tasklist.Task.create方法的典型用法代码示例。如果您正苦于以下问题:Java Task.create方法的具体用法?Java Task.create怎么用?Java Task.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.spi.tasklist.Task的用法示例。


在下文中一共展示了Task.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scan

import org.netbeans.spi.tasklist.Task; //导入方法依赖的package包/类
@Override
public List<? extends Task> scan(FileObject resource) {
    if (Constants.POM_MIME_TYPE.equals(resource.getMIMEType()) //NOI18N
            && "pom.xml".equals(resource.getNameExt())) { //NOI18N
        Project prj = FileOwnerQuery.getOwner(resource);
        if (prj != null && prj.getLookup().lookup(NbMavenProject.class) != null) {
            ModelSource ms = Utilities.createModelSource(resource);
            POMModel model = POMModelFactory.getDefault().getModel(ms);
            model.setAutoSyncActive(false);
            List<ErrorDescription> errs = StatusProvider.StatusProviderImpl.findHints(model, prj, -1, -1, -1);
            List<Task> tasks = new ArrayList<Task>();

            for (ErrorDescription error : errs) {
                try {
                    Task task = Task.create(resource,
                            severityToTaskListString(error.getSeverity()),
                            error.getDescription(),
                            error.getRange().getBegin().getLine() + 1);

                    tasks.add(task);
                } catch (IOException e) {
                    Logger.getLogger(TaskListBridge.class.getName()).
                            log(Level.INFO, "Error while converting errors to tasklist", e);
                }
            }
            return tasks;
        }
    }
    return Collections.<Task>emptyList();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:TaskListBridge.java

示例2: loadErrors

import org.netbeans.spi.tasklist.Task; //导入方法依赖的package包/类
private List<Task> loadErrors(File input, FileObject file) throws IOException {
    List<Task> result = new LinkedList<Task>();
    BufferedReader pw = new BufferedReader(new InputStreamReader(new FileInputStream(input), "UTF-8")); //NOI18N
    String line;

    while ((line = pw.readLine()) != null) {
        String[] parts = line.split(":"); //NOI18N
        if (parts.length != 3) {
            continue;
        }

        ErrorKind kind = null;
        try {
            kind = ErrorKind.valueOf(parts[0]);
        } catch (IllegalArgumentException iae) {
            LOG.log(Level.FINE, "Invalid ErrorKind: {0}", line);    //NOI18N
        }
        
        if (kind == null) {
            continue;
        }

        int lineNumber = Integer.parseInt(parts[1]);
        String message = parts[2];

        message = message.replaceAll("\\\\d", ":"); //NOI18N
        message = message.replaceAll("\\\\n", " "); //NOI18N
        message = message.replaceAll("\\\\\\\\", "\\\\"); //NOI18N

        String severity = getTaskType(kind);

        if (null != severity) {
            Task err = Task.create(file, severity, message, lineNumber);
            result.add(err);
        }
    }

    pw.close();
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:TaskCache.java

示例3: scanAll

import org.netbeans.spi.tasklist.Task; //导入方法依赖的package包/类
private List<? extends Task> scanAll( FileObject resource ) {
    List<Task> tasks = null;

    Collection<String> patterns = Settings.getDefault().getPatterns();

    try {
        String text = getContent( resource );

        int index = 0;
        int lineno = 1;
        int len = text.length();

        Matcher matcher = getScanRegexp().matcher( text );
        while (index < len && matcher.find(index)) {
            int begin = matcher.start();
            int end   = matcher.end();

            // begin should be the beginning of this line (but avoid
            // clash if I have two tokens on the same line...
            char c = 'a'; // NOI18N
            int nonwhite = begin;
            while (begin >= index && (c = text.charAt(begin)) != '\n') { // NOI18N
                if (c != ' ' && c != '\t') { // NOI18N
                    nonwhite = begin;
                }
                --begin;
            }

            begin = nonwhite;

            // end should be the last "nonwhite" character on this line...
            nonwhite = end;
            while (end < len) {
                c = text.charAt(end);
                if (c == '\n' || c == '\r') {// NOI18N
                    break;
                } else if (c != ' ' && c != '\t') {// NOI18N
                        nonwhite = end;
                }
                ++end;
            }

            // calculate current line number
            int idx = index;
            while (idx <= begin) {
                if (text.charAt(idx) == '\n') {// NOI18N
                    ++lineno;
                }
                ++idx;
            }

            index = end;

            String description = new String( text.subSequence(begin, Math.min(nonwhite+1, text.length())).toString().toCharArray() );
            description = trim( description, patterns );

            Task task = Task.create( resource, GROUP_NAME, description, lineno );
            if( null == tasks ) {
                tasks = new LinkedList<Task>();
            }
            tasks.add( task );
        }
    } catch( IOException e ) {
        Logger.getLogger( getClass().getName() ).log( Level.INFO, null, e );
    } catch( OutOfMemoryError oomE ) {
        System.gc();
        Logger.getLogger( getClass().getName() ).log( Level.INFO, null, oomE );
    }
    return null == tasks ? getEmptyList() : tasks;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:71,代码来源:TodoTaskScanner.java


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