org.eclipse.jdt.ui.text.IJavaPartitions Java Examples
The following examples show how to use
org.eclipse.jdt.ui.text.IJavaPartitions.
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: JvmImplementationOpener.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void openQuickHierarchy(ITextViewer textViewer, IJavaElement element, IRegion region) { HierarchyInformationPresenter presenter = new HierarchyInformationPresenter((ISourceViewer) textViewer, element, region); presenter.setDocumentPartitioning(IDocumentExtension3.DEFAULT_PARTITIONING); presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL); IInformationProvider provider = new JavaElementProvider(null, false); presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_MULTI_LINE_COMMENT); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_STRING); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_CHARACTER); presenter.setSizeConstraints(50, 20, true, false); presenter.install(textViewer); presenter.showInformation(); }
Example #2
Source File: AddBlockCommentAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException { int selectionOffset= selection.getOffset(); int selectionEndOffset= selectionOffset + selection.getLength(); List<Edit> edits= new LinkedList<Edit>(); ITypedRegion partition= docExtension.getPartition(IJavaPartitions.JAVA_PARTITIONING, selectionOffset, false); handleFirstPartition(partition, edits, factory, selectionOffset); while (partition.getOffset() + partition.getLength() < selectionEndOffset) { partition= handleInteriorPartition(partition, edits, factory, docExtension); } handleLastPartition(partition, edits, factory, selectionEndOffset); executeEdits(edits); }
Example #3
Source File: QuickTypeHierarchyHandler.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected void openPresentation(final XtextEditor editor, final IJavaElement javaElement, final EObject selectedElement) { final ISourceViewer sourceViewer = editor.getInternalSourceViewer(); ITextRegion significantTextRegion = locationInFileProvider.getSignificantTextRegion(selectedElement); InformationPresenter presenter = new HierarchyInformationPresenter(sourceViewer, javaElement, new Region(significantTextRegion.getOffset(),significantTextRegion.getLength())); presenter.setDocumentPartitioning(IDocumentExtension3.DEFAULT_PARTITIONING); presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL); IInformationProvider provider = new JavaElementProvider(editor, false); presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_MULTI_LINE_COMMENT); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_STRING); presenter.setInformationProvider(provider, IJavaPartitions.JAVA_CHARACTER); presenter.setSizeConstraints(50, 20, true, false); presenter.install(sourceViewer); presenter.showInformation(); }
Example #4
Source File: SpecificContentAssistAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Computes the partition type at the selection start and checks whether the proposal category * has any computers for this partition. * * @param selection the selection * @return <code>true</code> if there are any computers for the selection */ private boolean isValidSelection(ISelection selection) { if (!(selection instanceof ITextSelection)) return false; int offset= ((ITextSelection) selection).getOffset(); IDocument document= getDocument(); if (document == null) return false; String contentType; try { contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, true); } catch (BadLocationException x) { return false; } return fCategory.hasComputers(contentType); }
Example #5
Source File: AbstractJavaCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void handleSmartTrigger(IDocument document, char trigger, int referenceOffset) throws BadLocationException { DocumentCommand cmd= new DocumentCommand() { }; cmd.offset= referenceOffset; cmd.length= 0; cmd.text= Character.toString(trigger); cmd.doit= true; cmd.shiftsCaret= true; cmd.caretOffset= getReplacementOffset() + getCursorPosition(); SmartSemicolonAutoEditStrategy strategy= new SmartSemicolonAutoEditStrategy(IJavaPartitions.JAVA_PARTITIONING); strategy.customizeDocumentCommand(document, cmd); replace(document, cmd.offset, cmd.length, cmd.text); setCursorPosition(cmd.caretOffset - getReplacementOffset() + cmd.text.length()); }
Example #6
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void setPreferenceStore(IPreferenceStore store) { super.setPreferenceStore(store); SourceViewerConfiguration sourceViewerConfiguration= getSourceViewerConfiguration(); if (sourceViewerConfiguration == null || sourceViewerConfiguration instanceof JavaSourceViewerConfiguration) { JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); setSourceViewerConfiguration(new JavaSourceViewerConfiguration(textTools.getColorManager(), store, this, IJavaPartitions.JAVA_PARTITIONING)); } if (getSourceViewer() instanceof JavaSourceViewer) ((JavaSourceViewer)getSourceViewer()).setPreferenceStore(store); fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES); fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES); fMarkTypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES); fMarkMethodOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES); fMarkConstantOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES); fMarkFieldOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES); fMarkLocalVariableypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES); fMarkExceptions= store.getBoolean(PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES); fMarkImplementors= store.getBoolean(PreferenceConstants.EDITOR_MARK_IMPLEMENTORS); fMarkMethodExitPoints= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS); fMarkBreakContinueTargets= store.getBoolean(PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS); }
Example #7
Source File: JavaTemplatesPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected SourceViewer createPatternViewer(Composite parent) { IDocument document= new Document(); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); JavaSourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); viewer.setEditable(false); return viewer; }
Example #8
Source File: TemplateCompletionProposalComputer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) { try { String partition= TextUtilities.getContentType(context.getDocument(), IJavaPartitions.JAVA_PARTITIONING, context.getInvocationOffset(), true); if (partition.equals(IJavaPartitions.JAVA_DOC)) return fJavadocTemplateEngine; else { CompletionContext coreContext= context.getCoreContext(); if (coreContext != null) { int tokenLocation= coreContext.getTokenLocation(); if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) { return fJavaMembersTemplateEngine; } if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) { return fJavaStatementsTemplateEngine; } } return fJavaTemplateEngine; } } catch (BadLocationException x) { return null; } }
Example #9
Source File: JavaTemplatePreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected SourceViewer createViewer(Composite parent) { IDocument document= new Document(); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); return viewer; }
Example #10
Source File: JavaTextViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
JavaTextViewer(Composite parent) { fSourceViewer= new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL); JavaTextTools tools= JavaCompareUtilities.getJavaTextTools(); if (tools != null) { IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); fSourceViewer.configure(new JavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING)); } fSourceViewer.setEditable(false); String symbolicFontName= JavaMergeViewer.class.getName(); Font font= JFaceResources.getFont(symbolicFontName); if (font != null) fSourceViewer.getTextWidget().setFont(font); }
Example #11
Source File: JavaPairMatcher.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns true if the character at the specified offset is a greater-than sign, rather than an * type parameter list close angle bracket. * * @param document a document * @param offset an offset within the document * @return true if the character at the specified offset is a greater-than sign * @throws BadLocationException if offset is invalid in the document */ private boolean isGreaterThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false); if (!IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) { return false; } JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, contentType); return !isTypeParameterClosingBracket(offset, document, scanner); }
Example #12
Source File: JavaPairMatcher.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns <code>true</code> if the character at the specified offset is a less-than sign, rather than * the opening angle bracket of a type parameter list. * * @param document a document * @param offset an offset within the document * @return <code>true</code> if the character at the specified offset is a less-than sign * @throws BadLocationException if offset is invalid in the document */ private boolean isLessThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false); if (!IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) { return false; } JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, contentType); return !isTypeParameterOpeningBracket(offset, document, scanner); }
Example #13
Source File: ChangeHoverInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void setInformation(String content) { super.setInformation(content); IDocument doc= getViewer().getDocument(); if (doc == null) return; // ensure that we can scroll enough ensureScrollable(); String start= null; if (IJavaPartitions.JAVA_DOC.equals(fPartition)) { start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$ } else if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(fPartition)) { start= "/*" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$ } if (start != null) { try { doc.replace(0, 0, start); int startLen= start.length(); getViewer().setDocument(doc, startLen, doc.getLength() - startLen); } catch (BadLocationException e) { // impossible Assert.isTrue(false); } } getViewer().getTextWidget().setHorizontalPixel(fHorizontalScrollPixel); }
Example #14
Source File: SmartSemicolonAutoEditStrategy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns a valid insert location (except for whitespace) in <code>partition</code> or -1 if * there is no valid insert location. * An valid insert location is right after any java string or character partition, or at the end * of a java default partition, but never behind <code>maxOffset</code>. Comment partitions or * empty java partitions do never yield valid insert positions. * * @param doc the document being modified * @param partition the current partition * @param maxOffset the maximum offset to consider * @return a valid insert location in <code>partition</code>, or -1 if there is no valid insert location */ private static int getValidPositionForPartition(IDocument doc, ITypedRegion partition, int maxOffset) { final int INVALID= -1; if (IJavaPartitions.JAVA_DOC.equals(partition.getType())) return INVALID; if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(partition.getType())) return INVALID; if (IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(partition.getType())) return INVALID; int endOffset= Math.min(maxOffset, partition.getOffset() + partition.getLength()); if (IJavaPartitions.JAVA_CHARACTER.equals(partition.getType())) return endOffset; if (IJavaPartitions.JAVA_STRING.equals(partition.getType())) return endOffset; if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) { try { if (doc.get(partition.getOffset(), endOffset - partition.getOffset()).trim().length() == 0) return INVALID; else return endOffset; } catch (BadLocationException e) { return INVALID; } } // default: we don't know anything about the partition - assume valid return endOffset; }
Example #15
Source File: JavaAutoIndentStrategy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the indentation of the line <code>line</code> in <code>document</code>. * The returned string may contain pairs of leading slashes that are considered * part of the indentation. The space before the asterisk in a javadoc-like * comment is not considered part of the indentation. * * @param document the document * @param line the line * @return the indentation of <code>line</code> in <code>document</code> * @throws BadLocationException if the document is changed concurrently */ private static String getCurrentIndent(Document document, int line) throws BadLocationException { IRegion region= document.getLineInformation(line); int from= region.getOffset(); int endOffset= region.getOffset() + region.getLength(); // go behind line comments int to= from; while (to < endOffset - 2 && document.get(to, 2).equals(LINE_COMMENT)) to += 2; while (to < endOffset) { char ch= document.getChar(to); if (!Character.isWhitespace(ch)) break; to++; } // don't count the space before javadoc like, asterisk-style comment lines if (to > from && to < endOffset - 1 && document.get(to - 1, 2).equals(" *")) { //$NON-NLS-1$ String type= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, to, true); if (type.equals(IJavaPartitions.JAVA_DOC) || type.equals(IJavaPartitions.JAVA_MULTI_LINE_COMMENT)) to--; } return document.get(from, to - from); }
Example #16
Source File: JavaAutoIndentStrategy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Installs a java partitioner with <code>document</code>. * * @param document the document */ private static void installJavaStuff(Document document) { String[] types= new String[] { IJavaPartitions.JAVA_DOC, IJavaPartitions.JAVA_MULTI_LINE_COMMENT, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT, IJavaPartitions.JAVA_STRING, IJavaPartitions.JAVA_CHARACTER, IDocument.DEFAULT_CONTENT_TYPE }; FastPartitioner partitioner= new FastPartitioner(new FastJavaPartitionScanner(), types); partitioner.connect(document); document.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, partitioner); }
Example #17
Source File: SourceViewerInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void setInformation(String content) { if (content == null) { fViewer.setInput(null); return; } IDocument doc= new Document(content); JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(doc, IJavaPartitions.JAVA_PARTITIONING); fViewer.setInput(doc); }
Example #18
Source File: JavaPreview.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public JavaPreview(Map<String, String> workingValues, Composite parent) { JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); fPreviewDocument= new Document(); fWorkingValues= workingValues; tools.setupJavaDocumentPartitioner( fPreviewDocument, IJavaPartitions.JAVA_PARTITIONING); PreferenceStore prioritizedSettings= new PreferenceStore(); HashMap<String, String> complianceOptions= new HashMap<String, String>(); JavaModelUtil.setComplianceOptions(complianceOptions, JavaModelUtil.VERSION_LATEST); for (Entry<String, String> complianceOption : complianceOptions.entrySet()) { prioritizedSettings.setValue(complianceOption.getKey(), complianceOption.getValue()); } IPreferenceStore[] chain= { prioritizedSettings, JavaPlugin.getDefault().getCombinedPreferenceStore() }; fPreferenceStore= new ChainedPreferenceStore(chain); fSourceViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore); fSourceViewer.setEditable(false); Cursor arrowCursor= fSourceViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); fSourceViewer.getTextWidget().setCursor(arrowCursor); // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263 // fSourceViewer.getTextWidget().setCaret(null); fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, IJavaPartitions.JAVA_PARTITIONING, true); fSourceViewer.configure(fViewerConfiguration); fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); fMarginPainter= new MarginPainter(fSourceViewer); final RGB rgb= PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR); fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb)); fSourceViewer.addPainter(fMarginPainter); new JavaSourcePreviewerUpdater(); fSourceViewer.setDocument(fPreviewDocument); }
Example #19
Source File: CompletionProposalComputerRegistry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns if the registry detected that computers got uninstalled since the last run. * * @param included list of included proposal categories * @param partition the document partition * @return <code>true</code> if the registry detected that computers got uninstalled since the last run * <code>false</code> otherwise or if {@link #resetUnistalledComputers()} has been called * @since 3.4 */ boolean hasUninstalledComputers(String partition, List<CompletionProposalCategory> included) { if (fHasUninstalledComputers) return true; if (fIsFirstTimeCheckForUninstalledComputers) { if ((IJavaPartitions.JAVA_DOC.equals(partition) || IDocument.DEFAULT_CONTENT_TYPE.equals(partition)) && included.size() == 1 && !getProposalCategories().isEmpty()) { CompletionProposalCategory firstCategory= included.get(0); if (firstCategory != null) // paranoia check return "org.eclipse.jdt.ui.swtProposalCategory".equals(firstCategory.getId()); //$NON-NLS-1$ } } return false; }
Example #20
Source File: CodeTemplateSourceViewerConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); IColorManager manager= textTools.getColorManager(); ContentAssistant assistant= new ContentAssistant(); assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE); // Register the same processor for strings and single line comments to get code completion at the start of those partitions. assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_STRING); assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_CHARACTER); assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT); assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_DOC); assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT)); assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION)); assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY)); assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); assistant.setInformationControlCreator(new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString()); } }); Color background= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, manager); assistant.setContextInformationPopupBackground(background); assistant.setContextSelectorBackground(background); Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, manager); assistant.setContextInformationPopupForeground(foreground); assistant.setContextSelectorForeground(foreground); return assistant; }
Example #21
Source File: JavaEditorColoringConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Control createPreviewer(Composite parent) { IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore(); IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore }); fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.H_SCROLL | SWT.BORDER, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(fColorManager, store, null, IJavaPartitions.JAVA_PARTITIONING, false); fPreviewViewer.configure(configuration); // fake 1.5 source to get 1.5 features right. configuration.handlePropertyChangeEvent(new PropertyChangeEvent(this, JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4, JavaCore.VERSION_1_5)); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); Cursor arrowCursor= fPreviewViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); fPreviewViewer.getTextWidget().setCursor(arrowCursor); // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263 // fPreviewViewer.getTextWidget().setCaret(null); String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document= new Document(content); JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); fPreviewViewer.setDocument(document); installSemanticHighlighting(); return fPreviewViewer.getControl(); }
Example #22
Source File: SurroundWithTemplateMenuAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static boolean isInJavadoc(JavaEditor editor) { ITextSelection selection= getTextSelection(editor); if (selection == null) return false; IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput()); try { String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, selection.getOffset(), true); return contentType.equals(IJavaPartitions.JAVA_DOC); } catch (BadLocationException e) { return false; } }
Example #23
Source File: RemoveBlockCommentAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadPartitioningException, BadLocationException { List<Edit> edits= new LinkedList<Edit>(); int tokenLength= getCommentStart().length(); int offset= selection.getOffset(); int endOffset= offset + selection.getLength(); ITypedRegion partition= docExtension.getPartition(IJavaPartitions.JAVA_PARTITIONING, offset, false); int partOffset= partition.getOffset(); int partEndOffset= partOffset + partition.getLength(); while (partEndOffset < endOffset) { if (partition.getType() == IJavaPartitions.JAVA_MULTI_LINE_COMMENT) { edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$ edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$ } partition= docExtension.getPartition(IJavaPartitions.JAVA_PARTITIONING, partEndOffset, false); partOffset= partition.getOffset(); partEndOffset= partOffset + partition.getLength(); } if (partition.getType() == IJavaPartitions.JAVA_MULTI_LINE_COMMENT) { edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$ edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$ } executeEdits(edits); }
Example #24
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected int getLineStartPosition(final IDocument document, final String line, final int length, final int offset) { String type= IDocument.DEFAULT_CONTENT_TYPE; try { type= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, true); } catch (BadLocationException exception) { // Should not happen } int index= super.getLineStartPosition(document, line, length, offset); if (type.equals(IJavaPartitions.JAVA_DOC) || type.equals(IJavaPartitions.JAVA_MULTI_LINE_COMMENT)) { if (index < length - 1 && line.charAt(index) == '*' && line.charAt(index + 1) != '/') { do { ++index; } while (index < length && Character.isWhitespace(line.charAt(index))); } } else { if (index < length - 1 && line.charAt(index) == '/' && line.charAt(index + 1) == '/') { index++; do { ++index; } while (index < length && Character.isWhitespace(line.charAt(index))); } } return index; }
Example #25
Source File: SourceView.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void internalCreatePartControl(Composite parent) { IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); fViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store); fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); fViewer.configure(fViewerConfiguration); fViewer.setEditable(false); setViewerFont(); JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); store.addPropertyChangeListener(fPropertyChangeListener); getViewSite().setSelectionProvider(fViewer); }
Example #26
Source File: SourceView.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void doSetInput(Object input) { if (input instanceof IDocument) fViewer.setInput(input); else if (input == null) fViewer.setInput(new Document("")); //$NON-NLS-1$ else { IDocument document= new Document(input.toString()); JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); fViewer.setInput(document); } }
Example #27
Source File: JavaFormatter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Installs a java partitioner with <code>document</code>. * * @param document the document */ private static void installJavaStuff(Document document) { String[] types= new String[] { IJavaPartitions.JAVA_DOC, IJavaPartitions.JAVA_MULTI_LINE_COMMENT, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT, IJavaPartitions.JAVA_STRING, IJavaPartitions.JAVA_CHARACTER, IDocument.DEFAULT_CONTENT_TYPE }; FastPartitioner partitioner= new FastPartitioner(new FastJavaPartitionScanner(), types); partitioner.connect(document); document.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, partitioner); }
Example #28
Source File: GWTSourceViewerConfiguration.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) { try { ITextEditor editor = getEditor(); return ((GWTJavaEditor) editor).getInputPartitioning(); } catch (Exception e) { GWTPluginLog.logError(e); return IJavaPartitions.JAVA_PARTITIONING; } }
Example #29
Source File: ClassFileDocumentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected IDocument createDocument(Object element) throws CoreException { IDocument document= super.createDocument(element); if (document != null) { JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); } return document; }
Example #30
Source File: JavaTemplatesPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Get the active contexts for the given position in the document. * <p> * FIXME: should trigger code assist to get the context. * </p> * * @param document the document * @param offset the offset * @return an array of valid context id */ @Override protected String[] getContextTypeIds(IDocument document, int offset) { try { String partition= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, true); String[] ids= new String[] { JavaContextType.ID_ALL, JavaContextType.ID_MEMBERS, JavaContextType.ID_STATEMENTS, SWTContextType.ID_ALL, SWTContextType.ID_STATEMENTS, SWTContextType.ID_MEMBERS}; if (partition.equals(IJavaPartitions.JAVA_DOC)) ids= new String[] { JavaDocContextType.ID }; return ids; } catch (BadLocationException e) { return new String[0]; } }