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


Java TaskFactory类代码示例

本文整理汇总了Java中org.netbeans.modules.parsing.spi.TaskFactory的典型用法代码示例。如果您正苦于以下问题:Java TaskFactory类的具体用法?Java TaskFactory怎么用?Java TaskFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TaskFactory类属于org.netbeans.modules.parsing.spi包,在下文中一共展示了TaskFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleProcess

import org.netbeans.modules.parsing.spi.TaskFactory; //导入依赖的package包/类
@Override
protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
    for (Element e :  roundEnv.getElementsAnnotatedWith(EmbeddingProvider.Registration.class)) {
        if (!e.getKind().isClass()) {
            throw new LayerGenerationException("Annotated Element has to be a class.", e);  //NOI18N
        }
        final EmbeddingProvider.Registration reg = e.getAnnotation(EmbeddingProvider.Registration.class);
        String mimeType = reg.mimeType();
        if (mimeType == null) {
            throw new LayerGenerationException("Mime type has to be given.", e);  //NOI18N
        } else if (!mimeType.isEmpty()) {
            mimeType =  '/' + mimeType; //NOI18N
        }
        String targetMimeType = reg.targetMimeType();
        if (targetMimeType == null || targetMimeType.isEmpty()) {
            throw new LayerGenerationException("Target mime type has to be given.", e);  //NOI18N
        }
        layer(e).
            instanceFile("Editors" + mimeType, null, null).    //NOI18N
            stringvalue("instanceOf", TaskFactory.class.getName()).         ///NOI18N
            methodvalue("instanceCreate", EmbeddingProviderFactory.class.getName(), "create").         //NOI18N
            stringvalue(EmbeddingProviderFactory.ATTR_TARGET_MIME_TYPE, targetMimeType).
            instanceAttribute(EmbeddingProviderFactory.ATTR_PROVIDER, EmbeddingProvider.class).
            write();
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:EmbeddingProviderRegistrationProcessor.java

示例2: create

import org.netbeans.modules.parsing.spi.TaskFactory; //导入依赖的package包/类
public static TaskFactory create(@NonNull final Map<String,Object> params) {
    return new EmbeddingProviderFactory(params);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:EmbeddingProviderFactory.java

示例3: createTasks

import org.netbeans.modules.parsing.spi.TaskFactory; //导入依赖的package包/类
private Collection<SchedulerTask> createTasks () {
    List<SchedulerTask> tasks1 = null;
    Set<SchedulerTask> pendingTasks1 = null;
    if (tasks == null) {
        tasks1 = new ArrayList<SchedulerTask> ();
        pendingTasks1 = new HashSet<SchedulerTask> ();
        Lookup lookup = MimeLookup.getLookup (mimeType);
        Collection<? extends TaskFactory> factories = lookup.lookupAll (TaskFactory.class);
        Snapshot fakeSnapshot = null;
        for (TaskFactory factory : factories) {
            // #185586 - this is here in order not to create snapshots (a copy of file/doc text)
            // if there is no task that would really need it (eg. in C/C++ projects there is no parser
            // registered and no tasks will ever run on these files, even though there may be tasks
            // registered for all mime types
            Collection<? extends SchedulerTask> newTasks = factory.create(getParser() != null ? 
                getSnapshot() :
                fakeSnapshot == null ?
                    fakeSnapshot = SourceAccessor.getINSTANCE().createSnapshot(
                        "", //NOI18N
                        new int [] { 0 },
                        source,
                        MimePath.get (mimeType),
                        new int[][] {new int[] {0, 0}},
                        new int[][] {new int[] {0, 0}}) :
                    fakeSnapshot
            );
            if (newTasks != null) {
                tasks1.addAll (newTasks);
                pendingTasks1.addAll (newTasks);
            }
        }
        Collections.sort(tasks1, PRIORITY_ORDER);
    }
    synchronized (TaskProcessor.INTERNAL_LOCK) {
        if ((tasks == null) && (tasks1 != null)) {
            tasks = tasks1;
            pendingTasks = pendingTasks1;
        }
        if (tasks != null) {
            // this should be normal return in most cases
            return tasks;
        }
    }
    // recurse and hope
    return createTasks();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:SourceCache.java

示例4: testParseDoesNotScheduleTasks

import org.netbeans.modules.parsing.spi.TaskFactory; //导入依赖的package包/类
public void testParseDoesNotScheduleTasks () throws Exception {
    final CountDownLatch l = new CountDownLatch(1);
    MockServices.setServices (MockMimeLookup.class, TestEnvironmentFactory.class, MyScheduler.class);
    MockMimeLookup.setInstances (
        MimePath.get ("text/foo"), new FooParserFactory(),
                    new TaskFactory () {
            public Collection<SchedulerTask> create (Snapshot snapshot) {
                return Arrays.asList (new SchedulerTask[] {
                    new ParserResultTask() {
                        @Override
                        public void run(Result result, SchedulerEvent event) {
                            l.countDown();
                        }
                        @Override
                        public int getPriority() {
                            return 100;
                        }
                        @Override
                        public Class<? extends Scheduler> getSchedulerClass() {
                            return Scheduler.EDITOR_SENSITIVE_TASK_SCHEDULER;
                        }
                        @Override
                        public void cancel() {}
                    }
                });
            }
    });

    clearWorkDir ();
    //Collection c = MimeLookup.getLookup("text/boo").lookupAll (ParserFactory.class);
    FileObject workDir = FileUtil.toFileObject (getWorkDir ());
    FileObject testFile = FileUtil.createData (workDir, "bla.foo");
    FileUtil.setMIMEType ("foo", "text/foo");
    OutputStream outputStream = testFile.getOutputStream ();
    OutputStreamWriter writer = new OutputStreamWriter (outputStream);
    writer.append ("Toto je testovaci file, na kterem se budou delat hnusne pokusy!!!");
    writer.close ();
    Source source = Source.create (testFile);

    ParserManager.parse (Collections.singleton(source), new UserTask () {
        @Override
        public void run(ResultIterator resultIterator) throws Exception {
        }
    });

    DataObject.find(testFile).getLookup().lookup(EditorCookie.class).openDocument();

    assertFalse("Should not schedule the task", l.await(2, TimeUnit.SECONDS));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:ParserManagerTest.java


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