Java Code Examples for org.netbeans.api.java.source.JavaSource.Phase#RESOLVED
The following examples show how to use
org.netbeans.api.java.source.JavaSource.Phase#RESOLVED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LazyHintComputationFactory.java From netbeans with Apache License 2.0 | 4 votes |
/** Creates a new instance of LazyHintComputationFactory */ public LazyHintComputationFactory() { super(Phase.RESOLVED, Priority.LOW); }
Example 2
Source File: RestConfigurationEditorAwareTaskFactory.java From netbeans with Apache License 2.0 | 4 votes |
public RestConfigurationEditorAwareTaskFactory( ) { super(Phase.RESOLVED, Priority.LOW, TaskIndexingMode.DISALLOWED_DURING_SCAN , "text/x-java"); // NOI18N }
Example 3
Source File: AsyncConverterTaskFactory.java From netbeans with Apache License 2.0 | 4 votes |
public AsyncConverterTaskFactory(){ super(Phase.RESOLVED, Priority.LOW, TaskIndexingMode.DISALLOWED_DURING_SCAN , "text/x-java"); // NOI18N }
Example 4
Source File: JPAProblemFinderFactory.java From netbeans with Apache License 2.0 | 4 votes |
public JPAProblemFinderFactory(){ super(Phase.RESOLVED, Priority.BELOW_NORMAL); }
Example 5
Source File: HintTest.java From netbeans with Apache License 2.0 | 4 votes |
private CompilationInfo parse(FileObject file) throws DataObjectNotFoundException, IllegalArgumentException, IOException { DataObject od = DataObject.find(file); EditorCookie ec = od.getLookup().lookup(EditorCookie.class); assertNotNull(ec); Document doc = ec.openDocument(); doc.putProperty(Language.class, JavaTokenId.language()); doc.putProperty("mimeType", "text/x-java"); JavaSource js = JavaSource.create(ClasspathInfo.create(file), file); assertNotNull("found JavaSource for " + file, js); final DeadlockTask bt = new DeadlockTask(Phase.RESOLVED); js.runUserActionTask(bt, true); return bt.info; }
Example 6
Source File: JavaOperationsImpl.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void fixImports( final int[][] ranges) throws QueryException { if (!(control instanceof WorkingCopy)) { throw new IllegalStateException(); } Arrays.sort(ranges, new Comparator<int[]>(){ @Override public int compare(int[] o1, int[] o2) { return o1[0] - o2[0]; } }); final WorkingCopy wcopy = (WorkingCopy) control; try { if (control.toPhase(Phase.RESOLVED) != Phase.RESOLVED) { throw new QueryException("Cannot resolve file: " + //NOI18N Optional.ofNullable(control.getFileObject()) .map((fo) -> FileUtil.getFileDisplayName(fo)) .orElse("<unkown>")); //NOI18N } } catch (IOException ioe) { throw new QueryException(ioe); } final CompilationUnitTree cu = wcopy.getCompilationUnit(); final Trees trees = wcopy.getTrees(); final GeneratorUtilities utils = GeneratorUtilities.get(wcopy); final List<Tree> toImport = new ArrayList<Tree>(); final ErrorAwareTreePathScanner<Void,Void> scanner = new ErrorAwareTreePathScanner<Void, Void>(){ @Override public Void scan(Tree node, Void p) { final int start = (int) trees.getSourcePositions().getStartPosition(cu, node); final int end = (int) trees.getSourcePositions().getEndPosition(cu, node); final int status = contains(ranges,start,end); switch (status) { case -1: super.scan(node, p); break; case 0: break; case 1: toImport.add(node); break; } return null; } }; scanner.scan(cu, null); for (Tree tree : toImport) { wcopy.rewrite(tree, utils.importFQNs(tree)); } }
Example 7
Source File: WhiteListCheckTask.java From netbeans with Apache License 2.0 | 4 votes |
private WhiteListCheckTask() { super(Phase.RESOLVED); }
Example 8
Source File: ComputeAnnotations.java From netbeans with Apache License 2.0 | 4 votes |
public ComputeAnnotations() { super(Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN); }
Example 9
Source File: IntroduceHintFactory.java From netbeans with Apache License 2.0 | 4 votes |
public IntroduceHintFactory() { super(Phase.RESOLVED, Priority.BELOW_NORMAL, TaskIndexingMode.ALLOWED_DURING_SCAN); }
Example 10
Source File: WebSocketMethodsTaskFactory.java From netbeans with Apache License 2.0 | 4 votes |
public WebSocketMethodsTaskFactory(){ super(Phase.RESOLVED, Priority.LOW, TaskIndexingMode.DISALLOWED_DURING_SCAN , "text/x-java"); // NOI18N }
Example 11
Source File: EvaluationSpanTask.java From netbeans with Apache License 2.0 | 4 votes |
public EvaluationSpanTask() { super(Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN); }
Example 12
Source File: WebServicesHintsFactory.java From netbeans with Apache License 2.0 | 4 votes |
public WebServicesHintsFactory(){ super(Phase.RESOLVED, Priority.BELOW_NORMAL); }
Example 13
Source File: HintTestBase.java From netbeans with Apache License 2.0 | 4 votes |
private CompilationInfo parse(FileObject file) throws DataObjectNotFoundException, IllegalArgumentException, IOException { DataObject od = DataObject.find(file); EditorCookie ec = od.getLookup().lookup(EditorCookie.class); assertNotNull(ec); Document doc = ec.openDocument(); doc.putProperty(Language.class, JavaTokenId.language()); doc.putProperty("mimeType", "text/x-java"); JavaSource js = JavaSource.create(ClasspathInfo.create(file), file); assertNotNull("found JavaSource for " + file, js); final DeadlockTask bt = new DeadlockTask(Phase.RESOLVED); js.runUserActionTask(bt, true); return bt.info; }
Example 14
Source File: CaretListeningFactory.java From netbeans with Apache License 2.0 | 4 votes |
public CaretListeningFactory() { super(Phase.RESOLVED, Priority.LOW, TaskIndexingMode.ALLOWED_DURING_SCAN); INSTANCE = this; EditorRegistry.addPropertyChangeListener(WeakListeners.propertyChange(this, EditorRegistry.class)); }
Example 15
Source File: HintsTask.java From netbeans with Apache License 2.0 | 4 votes |
public CaretFactoryImpl() { super(Phase.RESOLVED, Priority.LOW); FileHintPreferences.addChangeListener(WeakListeners.change(this, HintsSettings.class)); }
Example 16
Source File: HintsTask.java From netbeans with Apache License 2.0 | 4 votes |
public FactoryImpl() { super(Phase.RESOLVED, Priority.LOW, TaskIndexingMode.ALLOWED_DURING_SCAN); FileHintPreferences.addChangeListener(WeakListeners.change(this, HintsSettings.class)); }
Example 17
Source File: MarkOccurrencesHighlighterBase.java From netbeans with Apache License 2.0 | 4 votes |
protected MarkOccurrencesHighlighterBase() { super(Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN); }
Example 18
Source File: SemanticHighlighterBase.java From netbeans with Apache License 2.0 | 4 votes |
protected SemanticHighlighterBase() { super(Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN); }
Example 19
Source File: JavaSourceTest.java From netbeans with Apache License 2.0 | 4 votes |
public void testInterference () throws MalformedURLException, IOException, InterruptedException { FileObject testFile1 = createTestFile ("Test1"); FileObject testFile2 = createTestFile ("Test2"); ClassPath bootPath = createBootPath (); ClassPath compilePath = createCompilePath (); ClassPath srcPath = createSourcePath(); JavaSource js1 = JavaSource.create(ClasspathInfo.create(bootPath, compilePath, srcPath), testFile1); JavaSource js2 = JavaSource.create(ClasspathInfo.create(bootPath, compilePath, srcPath), testFile2); DataObject dobj = DataObject.find(testFile1); EditorCookie ec = (EditorCookie) dobj.getCookie(EditorCookie.class); final StyledDocument doc = ec.openDocument(); doc.putProperty(Language.class, JavaTokenId.language()); TokenHierarchy h = TokenHierarchy.get(doc); TokenSequence ts = h.tokenSequence(JavaTokenId.language()); Thread.sleep(500); CountDownLatch[] latches1 = new CountDownLatch[] { new CountDownLatch (1), new CountDownLatch (1), }; CountDownLatch[] latches2 = new CountDownLatch[] { new CountDownLatch (1), }; CountDownLatch latch3 = new CountDownLatch (1); AtomicInteger counter = new AtomicInteger (0); DiagnosticTask task1 = new DiagnosticTask(latches1, counter, Phase.RESOLVED); CancellableTask<CompilationInfo> task2 = new DiagnosticTask(latches2, counter, Phase.RESOLVED); JavaSourceAccessor.getINSTANCE().addPhaseCompletionTask(js1,task1,Phase.RESOLVED,Priority.HIGH, TaskIndexingMode.ALLOWED_DURING_SCAN); Thread.sleep(500); //Making test a more deterministic, when the task is cancelled by DocListener, it's hard for test to recover from it js2.runUserActionTask(new CompileControlJob(latch3),true); JavaSourceAccessor.getINSTANCE().addPhaseCompletionTask(js2,task2,Phase.RESOLVED,Priority.MAX, TaskIndexingMode.ALLOWED_DURING_SCAN); boolean result = waitForMultipleObjects (new CountDownLatch[] {latches1[0], latches2[0], latch3}, 15000); if (!result) { assertTrue (String.format("Time out, latches1[0]: %d latches2[0]: %d latches3: %d",latches1[0].getCount(), latches2[0].getCount(), latch3.getCount()), false); } assertEquals ("Called more times than expected",2,counter.getAndSet(0)); Thread.sleep(500); //Making test a more deterministic, when the task is cancelled by DocListener, it's hard for test to recover from it NbDocument.runAtomic (doc, new Runnable () { public void run () { try { String text = doc.getText(0,doc.getLength()); int index = text.indexOf(REPLACE_PATTERN); assertTrue (index != -1); doc.remove(index,REPLACE_PATTERN.length()); doc.insertString(index,"System.out.println();",null); } catch (BadLocationException ble) { ble.printStackTrace(System.out); } } }); assertTrue ("Time out",waitForMultipleObjects(new CountDownLatch[] {latches1[1]}, 15000)); assertEquals ("Called more times than expected",1,counter.getAndSet(0)); JavaSourceAccessor.getINSTANCE().removePhaseCompletionTask(js1,task1); JavaSourceAccessor.getINSTANCE().removePhaseCompletionTask(js2,task2); }
Example 20
Source File: JavaSourceTest.java From netbeans with Apache License 2.0 | 4 votes |
public void testPhaseCompletionTask () throws MalformedURLException, InterruptedException, IOException { FileObject test = createTestFile ("Test1"); ClassPath bootPath = createBootPath (); ClassPath compilePath = createCompilePath (); ClassPath srcPath = createSourcePath (); JavaSource js = JavaSource.create(ClasspathInfo.create(bootPath, compilePath, srcPath), test); DataObject dobj = DataObject.find(test); EditorCookie ec = (EditorCookie) dobj.getCookie(EditorCookie.class); final StyledDocument doc = ec.openDocument(); doc.putProperty(Language.class, JavaTokenId.language()); TokenHierarchy h = TokenHierarchy.get(doc); TokenSequence ts = h.tokenSequence(JavaTokenId.language()); Thread.sleep(500); CountDownLatch[] latches1 = new CountDownLatch[] { new CountDownLatch (1), new CountDownLatch (1) }; CountDownLatch[] latches2 = new CountDownLatch[] { new CountDownLatch (1), new CountDownLatch (1) }; AtomicInteger counter = new AtomicInteger (0); CancellableTask<CompilationInfo> task1 = new DiagnosticTask(latches1, counter, Phase.RESOLVED); CancellableTask<CompilationInfo> task2 = new DiagnosticTask(latches2, counter, Phase.PARSED); JavaSourceAccessor.getINSTANCE().addPhaseCompletionTask(js,task1,Phase.RESOLVED,Priority.HIGH, TaskIndexingMode.ALLOWED_DURING_SCAN); JavaSourceAccessor.getINSTANCE().addPhaseCompletionTask(js,task2,Phase.PARSED,Priority.LOW, TaskIndexingMode.ALLOWED_DURING_SCAN); assertTrue ("Time out",waitForMultipleObjects(new CountDownLatch[] {latches1[0], latches2[0]}, 150000)); assertEquals ("Called more times than expected",2,counter.getAndSet(0)); Thread.sleep(1000); //Making test a more deterministic, when the task is cancelled by DocListener, it's hard for test to recover from it NbDocument.runAtomic (doc, new Runnable () { public void run () { try { String text = doc.getText(0,doc.getLength()); int index = text.indexOf(REPLACE_PATTERN); assertTrue (index != -1); doc.remove(index,REPLACE_PATTERN.length()); doc.insertString(index,"System.out.println();",null); } catch (BadLocationException ble) { ble.printStackTrace(System.out); } } }); assertTrue ("Time out",waitForMultipleObjects(new CountDownLatch[] {latches1[1], latches2[1]}, 15000)); assertEquals ("Called more times than expected",2,counter.getAndSet(0)); JavaSourceAccessor.getINSTANCE().removePhaseCompletionTask (js,task1); JavaSourceAccessor.getINSTANCE().removePhaseCompletionTask (js,task2); }