org.eclipse.jdt.ui.SharedASTProvider Java Examples
The following examples show how to use
org.eclipse.jdt.ui.SharedASTProvider.
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: SelectionListenerWithASTManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected final IStatus calculateASTandInform(ITypeRoot input, ITextSelection selection, IProgressMonitor monitor) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } // create AST try { CompilationUnit astRoot= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_ACTIVE_ONLY, monitor); if (astRoot != null && !monitor.isCanceled()) { Object[] listeners; synchronized (PartListenerGroup.this) { listeners= fAstListeners.getListeners(); } for (int i= 0; i < listeners.length; i++) { ((ISelectionListenerWithAST) listeners[i]).selectionChanged(fPart, selection, astRoot); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } } return Status.OK_STATUS; } } catch (OperationCanceledException e) { // thrown when canceling the AST creation } return Status.CANCEL_STATUS; }
Example #2
Source File: RenameNodeCorrectionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void addEdits(IDocument doc, TextEdit root) throws CoreException { super.addEdits(doc, root); // build a full AST CompilationUnit unit= SharedASTProvider.getAST(getCompilationUnit(), SharedASTProvider.WAIT_YES, null); ASTNode name= NodeFinder.perform(unit, fOffset, fLength); if (name instanceof SimpleName) { SimpleName[] names= LinkedNodeFinder.findByProblems(unit, (SimpleName) name); if (names != null) { for (int i= 0; i < names.length; i++) { SimpleName curr= names[i]; root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName)); } return; } } root.addChild(new ReplaceEdit(fOffset, fLength, fNewName)); }
Example #3
Source File: NLSRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private NLSRefactoring(ICompilationUnit cu) { Assert.isNotNull(cu); fCu= cu; CompilationUnit astRoot= SharedASTProvider.getAST(fCu, SharedASTProvider.WAIT_YES, null); NLSHint nlsHint= new NLSHint(fCu, astRoot); fSubstitutions= nlsHint.getSubstitutions(); setAccessorClassName(nlsHint.getAccessorClassName()); setAccessorClassPackage(nlsHint.getAccessorClassPackage()); setIsEclipseNLS(detectIsEclipseNLS()); setResourceBundleName(nlsHint.getResourceBundleName()); setResourceBundlePackage(nlsHint.getResourceBundlePackage()); setSubstitutionPattern(DEFAULT_SUBST_PATTERN); String cuName= fCu.getElementName(); if (fIsEclipseNLS) setPrefix(cuName.substring(0, cuName.length() - 5) + "_"); // A.java -> A_ //$NON-NLS-1$ else setPrefix(cuName.substring(0, cuName.length() - 4)); // A.java -> A. }
Example #4
Source File: QuickAssistLightBulbUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected void doPropertyChanged(String property) { if (property.equals(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB)) { if (isSetInPreferences()) { ICompilationUnit cu= getCompilationUnit(); if (cu != null) { installSelectionListener(); Point point= fViewer.getSelectedRange(); CompilationUnit astRoot= SharedASTProvider.getAST(cu, SharedASTProvider.WAIT_ACTIVE_ONLY, null); if (astRoot != null) { doSelectionChanged(point.x, point.y, astRoot); } } } else { uninstallSelectionListener(); } } }
Example #5
Source File: NLSStringHover.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public IRegion getHoverRegion(ITextViewer textViewer, int offset) { if (!(getEditor() instanceof JavaEditor)) return null; ITypeRoot je= getEditorInputJavaElement(); if (je == null) return null; // Never wait for an AST in UI thread. CompilationUnit ast= SharedASTProvider.getAST(je, SharedASTProvider.WAIT_NO, null); if (ast == null) return null; ASTNode node= NodeFinder.perform(ast, offset, 1); if (node instanceof StringLiteral) { StringLiteral stringLiteral= (StringLiteral)node; return new Region(stringLiteral.getStartPosition(), stringLiteral.getLength()); } else if (node instanceof SimpleName) { SimpleName simpleName= (SimpleName)node; return new Region(simpleName.getStartPosition(), simpleName.getLength()); } return null; }
Example #6
Source File: CleanUpPostSaveListener.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private CompilationUnit createAst(ICompilationUnit unit, Map<String, String> cleanUpOptions, IProgressMonitor monitor) { IJavaProject project= unit.getJavaProject(); if (compatibleOptions(project, cleanUpOptions)) { CompilationUnit ast= SharedASTProvider.getAST(unit, SharedASTProvider.WAIT_NO, monitor); if (ast != null) return ast; } ASTParser parser= CleanUpRefactoring.createCleanUpASTParser(); parser.setSource(unit); Map<String, String> compilerOptions= RefactoringASTParser.getCompilerOptions(unit.getJavaProject()); compilerOptions.putAll(cleanUpOptions); parser.setCompilerOptions(compilerOptions); return (CompilationUnit)parser.createAST(monitor); }
Example #7
Source File: OverrideCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private CompilationUnit getRecoveredAST(IDocument document, int offset, Document recoveredDocument) { CompilationUnit ast= SharedASTProvider.getAST(fCompilationUnit, SharedASTProvider.WAIT_ACTIVE_ONLY, null); if (ast != null) { recoveredDocument.set(document.get()); return ast; } char[] content= document.get().toCharArray(); // clear prefix to avoid compile errors int index= offset - 1; while (index >= 0 && Character.isJavaIdentifierPart(content[index])) { content[index]= ' '; index--; } recoveredDocument.set(new String(content)); final ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL); parser.setResolveBindings(true); parser.setStatementsRecovery(true); parser.setSource(content); parser.setUnitName(fCompilationUnit.getElementName()); parser.setProject(fCompilationUnit.getJavaProject()); return (CompilationUnit) parser.createAST(new NullProgressMonitor()); }
Example #8
Source File: OverrideIndicatorManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Opens and reveals the defining method. */ public void open() { CompilationUnit ast= SharedASTProvider.getAST(fJavaElement, SharedASTProvider.WAIT_ACTIVE_ONLY, null); if (ast != null) { ASTNode node= ast.findDeclaringNode(fAstNodeKey); if (node instanceof MethodDeclaration) { try { IMethodBinding methodBinding= ((MethodDeclaration)node).resolveBinding(); IMethodBinding definingMethodBinding= Bindings.findOverriddenMethod(methodBinding, true); if (definingMethodBinding != null) { IJavaElement definingMethod= definingMethodBinding.getJavaElement(); if (definingMethod != null) { JavaUI.openInEditor(definingMethod, true, true); return; } } } catch (CoreException e) { ExceptionHandler.handle(e, JavaEditorMessages.OverrideIndicatorManager_open_error_title, JavaEditorMessages.OverrideIndicatorManager_open_error_messageHasLogEntry); return; } } } String title= JavaEditorMessages.OverrideIndicatorManager_open_error_title; String message= JavaEditorMessages.OverrideIndicatorManager_open_error_message; MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), title, message); }
Example #9
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected void installOccurrencesFinder(boolean forceUpdate) { fMarkOccurrenceAnnotations= true; fPostSelectionListenerWithAST= new ISelectionListenerWithAST() { public void selectionChanged(IEditorPart part, ITextSelection selection, CompilationUnit astRoot) { updateOccurrenceAnnotations(selection, astRoot); } }; SelectionListenerWithASTManager.getDefault().addListener(this, fPostSelectionListenerWithAST); if (forceUpdate && getSelectionProvider() != null) { fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection(); ITypeRoot inputJavaElement= getInputJavaElement(); if (inputJavaElement != null) updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, SharedASTProvider.getAST(inputJavaElement, SharedASTProvider.WAIT_NO, getProgressMonitor())); } if (fOccurrencesFinderJobCanceler == null) { fOccurrencesFinderJobCanceler= new OccurrencesFinderJobCanceler(); fOccurrencesFinderJobCanceler.install(); } }
Example #10
Source File: JavaASTCodeMiningProvider.java From jdt-codemining with Eclipse Public License 1.0 | 5 votes |
private void collectCodeMinings(ITypeRoot unit, ITextEditor textEditor, ITextViewer viewer, List<ICodeMining> minings) { CompilationUnit cu = SharedASTProvider.getAST(unit, SharedASTProvider.WAIT_YES, null); JavaCodeMiningASTVisitor visitor = new JavaCodeMiningASTVisitor(cu, textEditor, viewer, minings, this); visitor.setShowParameterName(showParameterName); visitor.setShowParameterType(showParameterType); visitor.setShowParameterOnlyForLiteral(showParameterOnlyForLiteral); visitor.setShowParameterByUsingFilters(showParameterByUsingFilters); visitor.setShowEndStatement(showEndStatement); visitor.setEndStatementMinLineNumber(endStatementMinLineNumber); visitor.setShowJava10VarType(showJava10VarType); cu.accept(visitor); }
Example #11
Source File: AssistContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public CompilationUnit getASTRoot() { if (fASTRoot == null) { fASTRoot= SharedASTProvider.getAST(fCompilationUnit, fWaitFlag, null); if (fASTRoot == null) { // see bug 63554 fASTRoot= ASTResolving.createQuickFixAST(fCompilationUnit, null); } } return fASTRoot; }
Example #12
Source File: AssistContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private AssistContext(ICompilationUnit cu, ISourceViewer sourceViewer, IEditorPart editor, int offset, int length, SharedASTProvider.WAIT_FLAG waitFlag) { super(sourceViewer, offset, length); Assert.isLegal(cu != null); Assert.isLegal(waitFlag != null); fCompilationUnit= cu; fEditor= editor; fWaitFlag= waitFlag; }
Example #13
Source File: SurroundWith.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean isApplicable(IInvocationContext context) throws CoreException { ICompilationUnit unit= context.getCompilationUnit(); CompilationUnit ast= SharedASTProvider.getAST(unit, SharedASTProvider.WAIT_NO, null); if (ast == null) return true; Selection selection= Selection.createFromStartLength(context.getSelectionOffset(), context.getSelectionLength()); SurroundWithAnalyzer analyzer= new SurroundWithAnalyzer(unit, selection); context.getASTRoot().accept(analyzer); return analyzer.getStatus().isOK() && analyzer.hasSelectedNodes(); }
Example #14
Source File: JavadocHover.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static ASTNode getHoveredASTNode(ITypeRoot editorInputElement, IRegion hoverRegion) { if (editorInputElement == null) return null; CompilationUnit unit= SharedASTProvider.getAST(editorInputElement, SharedASTProvider.WAIT_ACTIVE_ONLY, null); if (unit == null) return null; return NodeFinder.perform(unit, hoverRegion.getOffset(), hoverRegion.getLength()); }
Example #15
Source File: JavaElementHyperlinkDetector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Finds the target for break or continue node. * * @param input the editor input * @param region the region * @return the break or continue target location or <code>null</code> if none * @since 3.7 */ public static OccurrenceLocation findBreakOrContinueTarget(ITypeRoot input, IRegion region) { CompilationUnit astRoot= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_NO, null); if (astRoot == null) return null; ASTNode node= NodeFinder.perform(astRoot, region.getOffset(), region.getLength()); ASTNode breakOrContinueNode= null; boolean labelSelected= false; if (node instanceof SimpleName) { SimpleName simpleName= (SimpleName) node; StructuralPropertyDescriptor location= simpleName.getLocationInParent(); if (location == ContinueStatement.LABEL_PROPERTY || location == BreakStatement.LABEL_PROPERTY) { breakOrContinueNode= simpleName.getParent(); labelSelected= true; } } else if (node instanceof ContinueStatement || node instanceof BreakStatement) breakOrContinueNode= node; if (breakOrContinueNode == null) return null; BreakContinueTargetFinder finder= new BreakContinueTargetFinder(); if (finder.initialize(astRoot, breakOrContinueNode) == null) { OccurrenceLocation[] locations= finder.getOccurrences(); if (locations != null) { if (breakOrContinueNode instanceof BreakStatement && !labelSelected) return locations[locations.length - 1]; // points to the end of target statement return locations[0]; // points to the beginning of target statement } } return null; }
Example #16
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void installOverrideIndicator(boolean provideAST) { uninstallOverrideIndicator(); IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); final ITypeRoot inputElement= getInputJavaElement(); if (model == null || inputElement == null) return; fOverrideIndicatorManager= new OverrideIndicatorManager(model, inputElement, null); if (provideAST) { CompilationUnit ast= SharedASTProvider.getAST(inputElement, SharedASTProvider.WAIT_ACTIVE_ONLY, getProgressMonitor()); fOverrideIndicatorManager.reconciled(ast, true, getProgressMonitor()); } }
Example #17
Source File: ClassFileEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void installSemanticHighlighting() { super.installSemanticHighlighting(); Job job= new Job(JavaEditorMessages.OverrideIndicatorManager_intallJob) { /* * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) * @since 3.0 */ @Override protected IStatus run(IProgressMonitor monitor) { CompilationUnit ast= SharedASTProvider.getAST(getInputJavaElement(), SharedASTProvider.WAIT_YES, null); if (fOverrideIndicatorManager != null) fOverrideIndicatorManager.reconciled(ast, true, monitor); if (fSemanticManager != null) { SemanticHighlightingReconciler reconciler= fSemanticManager.getReconciler(); if (reconciler != null) reconciler.reconciled(ast, false, monitor); } if (isMarkingOccurrences()) installOccurrencesFinder(false); return Status.OK_STATUS; } }; job.setPriority(Job.DECORATE); job.setSystem(true); job.schedule(); }
Example #18
Source File: JavaDebugElementCodeMiningProvider.java From jdt-codemining with Eclipse Public License 1.0 | 5 votes |
@Override protected List provideCodeMinings(ITextViewer viewer, IJavaStackFrame frame, IProgressMonitor monitor) { List<ICodeMining> minings = new ArrayList<>(); ITextEditor textEditor = super.getAdapter(ITextEditor.class); ITypeRoot unit = EditorUtility.getEditorInputJavaElement(textEditor, true); if (unit == null) { return minings; } CompilationUnit cu = SharedASTProvider.getAST(unit, SharedASTProvider.WAIT_YES, null); JavaDebugElementCodeMiningASTVisitor visitor = new JavaDebugElementCodeMiningASTVisitor(frame, cu, viewer, minings, this); cu.accept(visitor); return minings; }
Example #19
Source File: NLSHintHelper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static String getResourceBundleName(ITypeBinding accessorClassBinding) { IJavaElement je= accessorClassBinding.getJavaElement(); if (!(je instanceof IType)) return null; ITypeRoot typeRoot= ((IType) je).getTypeRoot(); CompilationUnit astRoot= SharedASTProvider.getAST(typeRoot, SharedASTProvider.WAIT_YES, null); return getResourceBundleName(astRoot); }
Example #20
Source File: FindOccurrencesEngine.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public String run(ITypeRoot input, int offset, int length) throws JavaModelException { if (input.getSourceRange() == null) { return SearchMessages.FindOccurrencesEngine_noSource_text; } final CompilationUnit root= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_YES, null); if (root == null) { return SearchMessages.FindOccurrencesEngine_cannotParse_text; } return run(root, offset, length); }
Example #21
Source File: OccurrencesSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void installOnActiveEditor(IWorkbenchPage page) { IEditorPart activeEditor= page.getActiveEditor(); if (activeEditor instanceof ITextEditor) { editorActive(activeEditor); ISelection selection= activeEditor.getSite().getSelectionProvider().getSelection(); ITypeRoot typeRoot= JavaUI.getEditorInputTypeRoot(activeEditor.getEditorInput()); if (typeRoot != null && selection instanceof ITextSelection) { CompilationUnit astRoot= SharedASTProvider.getAST(typeRoot, SharedASTProvider.WAIT_ACTIVE_ONLY, null); if (astRoot != null) { preformEditorSelectionChanged((ITextSelection) selection, astRoot); } } } }
Example #22
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void windowActivated(IWorkbenchWindow window) { if (window == getEditorSite().getWorkbenchWindow() && fMarkOccurrenceAnnotations && isActivePart()) { fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection(); ITypeRoot inputJavaElement= getInputJavaElement(); if (inputJavaElement != null) updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, SharedASTProvider.getAST(inputJavaElement, SharedASTProvider.WAIT_NO, getProgressMonitor())); } }
Example #23
Source File: JavaTextSelection.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public CompilationUnit resolvePartialAstAtOffset() { if (fPartialASTRequested) return fPartialAST; fPartialASTRequested= true; // long start= System.currentTimeMillis(); fPartialAST= SharedASTProvider.getAST(fElement, SharedASTProvider.WAIT_YES, null); // System.out.println("Time requesting partial AST: " + (System.currentTimeMillis() - start)); return fPartialAST; }
Example #24
Source File: NLSKeyHyperlinkDetector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class); if (region == null || textEditor == null) return null; IEditorSite site= textEditor.getEditorSite(); if (site == null) return null; ITypeRoot javaElement= getInputJavaElement(textEditor); if (javaElement == null) return null; CompilationUnit ast= SharedASTProvider.getAST(javaElement, SharedASTProvider.WAIT_NO, null); if (ast == null) return null; ASTNode node= NodeFinder.perform(ast, region.getOffset(), 1); if (!(node instanceof StringLiteral) && !(node instanceof SimpleName)) return null; if (node.getLocationInParent() == QualifiedName.QUALIFIER_PROPERTY) return null; IRegion nlsKeyRegion= new Region(node.getStartPosition(), node.getLength()); AccessorClassReference ref= NLSHintHelper.getAccessorClassReference(ast, nlsKeyRegion); if (ref == null) return null; String keyName= null; if (node instanceof StringLiteral) { keyName= ((StringLiteral)node).getLiteralValue(); } else { keyName= ((SimpleName)node).getIdentifier(); } if (keyName != null) return new IHyperlink[] {new NLSKeyHyperlink(nlsKeyRegion, keyName, ref, textEditor)}; return null; }
Example #25
Source File: RenameLinkedMode.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void start() { if (getActiveLinkedMode() != null) { // for safety; should already be handled in RenameJavaElementAction fgActiveLinkedMode.startFullDialog(); return; } ISourceViewer viewer= fEditor.getViewer(); IDocument document= viewer.getDocument(); fOriginalSelection= viewer.getSelectedRange(); int offset= fOriginalSelection.x; try { CompilationUnit root= SharedASTProvider.getAST(getCompilationUnit(), SharedASTProvider.WAIT_YES, null); fLinkedPositionGroup= new LinkedPositionGroup(); ASTNode selectedNode= NodeFinder.perform(root, fOriginalSelection.x, fOriginalSelection.y); if (! (selectedNode instanceof SimpleName)) { return; // TODO: show dialog } SimpleName nameNode= (SimpleName) selectedNode; if (viewer instanceof ITextViewerExtension6) { IUndoManager undoManager= ((ITextViewerExtension6)viewer).getUndoManager(); if (undoManager instanceof IUndoManagerExtension) { IUndoManagerExtension undoManagerExtension= (IUndoManagerExtension)undoManager; IUndoContext undoContext= undoManagerExtension.getUndoContext(); IOperationHistory operationHistory= OperationHistoryFactory.getOperationHistory(); fStartingUndoOperation= operationHistory.getUndoOperation(undoContext); } } fOriginalName= nameNode.getIdentifier(); final int pos= nameNode.getStartPosition(); ASTNode[] sameNodes= LinkedNodeFinder.findByNode(root, nameNode); //TODO: copied from LinkedNamesAssistProposal#apply(..): // sort for iteration order, starting with the node @ offset Arrays.sort(sameNodes, new Comparator<ASTNode>() { public int compare(ASTNode o1, ASTNode o2) { return rank(o1) - rank(o2); } /** * Returns the absolute rank of an <code>ASTNode</code>. Nodes * preceding <code>pos</code> are ranked last. * * @param node the node to compute the rank for * @return the rank of the node with respect to the invocation offset */ private int rank(ASTNode node) { int relativeRank= node.getStartPosition() + node.getLength() - pos; if (relativeRank < 0) return Integer.MAX_VALUE + relativeRank; else return relativeRank; } }); for (int i= 0; i < sameNodes.length; i++) { ASTNode elem= sameNodes[i]; LinkedPosition linkedPosition= new LinkedPosition(document, elem.getStartPosition(), elem.getLength(), i); if (i == 0) fNamePosition= linkedPosition; fLinkedPositionGroup.addPosition(linkedPosition); } fLinkedModeModel= new LinkedModeModel(); fLinkedModeModel.addGroup(fLinkedPositionGroup); fLinkedModeModel.forceInstall(); fLinkedModeModel.addLinkingListener(new EditorHighlightingSynchronizer(fEditor)); fLinkedModeModel.addLinkingListener(new EditorSynchronizer()); LinkedModeUI ui= new EditorLinkedModeUI(fLinkedModeModel, viewer); ui.setExitPosition(viewer, offset, 0, Integer.MAX_VALUE); ui.setExitPolicy(new ExitPolicy(document)); ui.enter(); viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y); // by default, full word is selected; restore original selection if (viewer instanceof IEditingSupportRegistry) { IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer; registry.register(fFocusEditingSupport); } openSecondaryPopup(); // startAnimation(); fgActiveLinkedMode= this; } catch (BadLocationException e) { JavaPlugin.log(e); } }
Example #26
Source File: NLSHintHelper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static String getResourceBundleName(ITypeRoot input) { return getResourceBundleName(SharedASTProvider.getAST(input, SharedASTProvider.WAIT_YES, null)); }
Example #27
Source File: AssistContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public AssistContext(ICompilationUnit cu, ISourceViewer sourceViewer, IEditorPart editor, int offset, int length) { this(cu, sourceViewer, editor, offset, length, SharedASTProvider.WAIT_YES); }
Example #28
Source File: AssistContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public AssistContext(ICompilationUnit cu, ISourceViewer sourceViewer, int offset, int length, SharedASTProvider.WAIT_FLAG waitFlag) { this(cu, sourceViewer, null, offset, length, waitFlag); }
Example #29
Source File: NLSHint.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private AccessorClassReference createEclipseNLSLines(final IDocument document, CompilationUnit astRoot, List<NLSLine> nlsLines) { final AccessorClassReference[] firstAccessor= new AccessorClassReference[1]; final SortedMap<Integer, NLSLine> lineToNLSLine= new TreeMap<Integer, NLSLine>(); astRoot.accept(new ASTVisitor() { private ICompilationUnit fCache_CU; private CompilationUnit fCache_AST; @Override public boolean visit(QualifiedName node) { ITypeBinding type= node.getQualifier().resolveTypeBinding(); if (type != null) { ITypeBinding superType= type.getSuperclass(); if (superType != null && NLS.class.getName().equals(superType.getQualifiedName())) { Integer line; try { line = new Integer(document.getLineOfOffset(node.getStartPosition())); } catch (BadLocationException e) { return true; // ignore and continue } NLSLine nlsLine= lineToNLSLine.get(line); if (nlsLine == null) { nlsLine= new NLSLine(line.intValue()); lineToNLSLine.put(line, nlsLine); } SimpleName name= node.getName(); NLSElement element= new NLSElement(node.getName().getIdentifier(), name.getStartPosition(), name.getLength(), nlsLine.size() - 1, true); nlsLine.add(element); String bundleName; ICompilationUnit bundleCU= (ICompilationUnit)type.getJavaElement().getAncestor(IJavaElement.COMPILATION_UNIT); if (fCache_CU == null || !fCache_CU.equals(bundleCU) || fCache_AST == null) { fCache_CU= bundleCU; if (fCache_CU != null) fCache_AST= SharedASTProvider.getAST(fCache_CU, SharedASTProvider.WAIT_YES, null); else fCache_AST= null; } bundleName= NLSHintHelper.getResourceBundleName(fCache_AST); element.setAccessorClassReference(new AccessorClassReference(type, bundleName, new Region(node.getStartPosition(), node.getLength()))); if (firstAccessor[0] == null) firstAccessor[0]= element.getAccessorClassReference(); } } return true; } }); nlsLines.addAll(lineToNLSLine.values()); return firstAccessor[0]; }
Example #30
Source File: JavaCorrectionAssistant.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static void ensureUpdatedAnnotations(ITextEditor editor) { Object inputElement= editor.getEditorInput().getAdapter(IJavaElement.class); if (inputElement instanceof ICompilationUnit) { SharedASTProvider.getAST((ICompilationUnit) inputElement, SharedASTProvider.WAIT_ACTIVE_ONLY, null); } }