本文整理汇总了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();
}
示例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;
}
示例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;
}