org.eclipse.xtext.ui.editor.folding.IFoldingRegionAcceptor Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.folding.IFoldingRegionAcceptor.
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: SolidityFoldingRegionProvider.java From solidity-ide with Eclipse Public License 1.0 | 6 votes |
@Override protected void computeCommentFolding(IXtextDocument xtextDocument, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor, ITypedRegion typedRegion, boolean initiallyFolded) { String text; try { text = xtextDocument.get(typedRegion.getOffset(), typedRegion.getLength()); int lines = Strings.countLines(text); if (shouldCreateCommentFolding(lines)) { boolean collapse = shouldCollapse(typedRegion, lines); super.computeCommentFolding(xtextDocument, foldingRegionAcceptor, typedRegion, collapse); } } catch (BadLocationException e) { log.error(e, e); } }
Example #2
Source File: GamaFoldingRegionProvider.java From gama with GNU General Public License v3.0 | 6 votes |
@Override protected void computeCommentFolding(final IXtextDocument xtextDocument, final IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor, final ITypedRegion typedRegion, final boolean initiallyFolded) throws BadLocationException { final int offset = typedRegion.getOffset(); final int length = typedRegion.getLength(); final Matcher matcher = getTextPatternInComment().matcher(xtextDocument.get(offset, length)); ((GamaFoldingRegionAcceptor) foldingRegionAcceptor).type = typedRegion.getType(); if (matcher.find()) { final TextRegion significant = new TextRegion(offset + matcher.start(), 0); ((IFoldingRegionAcceptorExtension<ITextRegion>) foldingRegionAcceptor).accept(offset, length, initiallyFolded, significant); } else { ((IFoldingRegionAcceptorExtension<ITextRegion>) foldingRegionAcceptor).accept(offset, length, initiallyFolded); } }
Example #3
Source File: DotHtmlLabelFoldingRegionProvider.java From gef with Eclipse Public License 2.0 | 6 votes |
@Override protected void computeObjectFolding(EObject eObject, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { /* * Do not calculate folding region if the html content contains only * whitespaces */ if (eObject instanceof HtmlContent) { HtmlContent htmlContent = (HtmlContent) eObject; if (htmlContent.getText() != null && !htmlContent.getText().trim().isEmpty()) { super.computeObjectFolding(eObject, foldingRegionAcceptor); } } else { super.computeObjectFolding(eObject, foldingRegionAcceptor); } }
Example #4
Source File: DotFoldingRegionProvider.java From gef with Eclipse Public License 2.0 | 6 votes |
@Override protected void computeObjectFolding(EObject eObject, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { ILocationInFileProvider locationInFileProvider = getLocationInFileProvider(); ITextRegion region = locationInFileProvider.getFullTextRegion(eObject); ITextRegionWithLineInformation regionWithLineInformation = (ITextRegionWithLineInformation) region; if (region != null) { ITextRegion significant = locationInFileProvider .getSignificantTextRegion(eObject); if (significant == null) throw new NullPointerException( "significant region may not be null"); //$NON-NLS-1$ if (!isAlreadyAccepted(regionWithLineInformation)) { foldingRegionAcceptor.accept(region.getOffset(), region.getLength(), significant); acceptedRegions.add(regionWithLineInformation); } } }
Example #5
Source File: DotFoldingRegionProvider.java From gef with Eclipse Public License 2.0 | 6 votes |
protected void computeObjectFolding(XtextResource xtextResource, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { acceptedRegions.clear(); IParseResult parseResult = xtextResource.getParseResult(); if (parseResult != null) { EObject rootASTElement = parseResult.getRootASTElement(); if (rootASTElement != null) { TreeIterator<EObject> allContents = rootASTElement .eAllContents(); while (allContents.hasNext()) { EObject eObject = allContents.next(); if (isHandled(eObject)) { computeObjectFolding(eObject, foldingRegionAcceptor); } if (eObject instanceof Attribute) { computeDotAttributeValueFolding((Attribute) eObject, foldingRegionAcceptor); } if (!shouldProcessContent(eObject)) { allContents.prune(); } } } } }
Example #6
Source File: StatemachineFoldingRegionProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void computeFoldingRegionBetweenKeywords(XtextResource it, Keyword startKeyword, Keyword endKeyword, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { ITextRegion region = textRegionBetween(it, startKeyword, endKeyword); if (region != null) { foldingRegionAcceptor.accept(region.getOffset(), region.getLength()); } }
Example #7
Source File: DotFoldingRegionProvider.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * Compute folding regions for the dot attribute value if possible. * * @param dotAttribute * @param foldingRegionAcceptor */ private void computeDotAttributeValueFolding(Attribute attribute, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { // The folding should be able to cope with incomplete statements if (attribute.getValue() != null && attribute.getValue().getType() == ID.Type.HTML_STRING) { String htmlLabelValue = attribute.getValue().toValue(); Injector injector = DotActivator.getInstance().getInjector( DotActivator.ORG_ECLIPSE_GEF_DOT_INTERNAL_LANGUAGE_DOTHTMLLABEL); IFoldingRegionProvider htmlLabelFoldingRegionProvider = injector .getInstance(IFoldingRegionProvider.class); IXtextDocument xtextDocument = null; try { xtextDocument = DotEditorUtils.getDocument(injector, htmlLabelValue); } catch (Exception e) { DotActivatorEx.logError(e); } if (xtextDocument != null) { Collection<FoldedPosition> htmlLabelFoldingRegions = htmlLabelFoldingRegionProvider .getFoldingRegions(xtextDocument); for (Iterator<FoldedPosition> iterator = htmlLabelFoldingRegions .iterator(); iterator.hasNext();) { FoldedPosition htmlFoldedPosition = iterator.next(); int attributeValueStartOffset = getAttributeValueStartOffset( attribute); foldingRegionAcceptor.accept( attributeValueStartOffset + htmlFoldedPosition.getOffset(), htmlFoldedPosition.getLength() - 1); } } } }
Example #8
Source File: StatemachineFoldingRegionProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected void computeObjectFolding(EObject o, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { if (o instanceof Statemachine) { XtextResource res = (XtextResource) o.eResource(); computeEventsFolding(res, foldingRegionAcceptor); computeResetEventsFolding(res, foldingRegionAcceptor); computeCommandsFolding(res, foldingRegionAcceptor); } else { super.computeObjectFolding(o, foldingRegionAcceptor); } }
Example #9
Source File: XtendFoldingRegionProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected void computeCommentFolding(IXtextDocument xtextDocument, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor, ITypedRegion typedRegion, boolean initiallyFolded) throws BadLocationException { if (xtextDocument.get(0, typedRegion.getOffset()).trim().length()==0) { super.computeCommentFolding(xtextDocument, foldingRegionAcceptor, typedRegion, foldingPreferences.isFoldHeader()); } else { super.computeCommentFolding(xtextDocument, foldingRegionAcceptor, typedRegion, foldingPreferences.isFoldComments()); } }
Example #10
Source File: XtendFoldingRegionProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected void computeObjectFolding(EObject eObject, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { if (eObject instanceof XtendFile) { computeImportFolding((XtendFile)eObject, foldingRegionAcceptor); } else { boolean initiallyFolded = false; if (eObject instanceof XtendFunction) { initiallyFolded = foldingPreferences.isFoldMethods(); } if (eObject instanceof XtendTypeDeclaration && !(eObject.eContainer() instanceof XtendFile)) { initiallyFolded = foldingPreferences.isFoldInnerTypes(); } super.computeObjectFolding(eObject, foldingRegionAcceptor, initiallyFolded); } }
Example #11
Source File: XtendFoldingRegionProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void computeImportFolding(XtendFile xtendFile, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { if(xtendFile.getImportSection() != null && xtendFile.getImportSection().getImportDeclarations().size() >1) { ICompositeNode node = NodeModelUtils.findActualNodeFor(xtendFile.getImportSection()); if(node != null) { ITextRegion textRegion = node.getTextRegion(); ((IFoldingRegionAcceptorExtension<ITextRegion>)foldingRegionAcceptor).accept(textRegion.getOffset(), textRegion.getLength(), foldingPreferences.isFoldImports()); } } }
Example #12
Source File: SolidityFoldingRegionProvider.java From solidity-ide with Eclipse Public License 1.0 | 5 votes |
@Override protected void computeObjectFolding(EObject eObject, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor, boolean initiallyFolded) { if (FOLDING_TYPES.contains(eObject.eClass())) { super.computeObjectFolding(eObject, foldingRegionAcceptor, initiallyFolded); } }
Example #13
Source File: StatemachineFoldingRegionProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private void computeCommandsFolding(XtextResource res, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { computeFoldingRegionBetweenKeywords(res, statemachineGrammarAccess.getStatemachineAccess().getCommandsKeyword_3_0(), statemachineGrammarAccess.getStatemachineAccess().getEndKeyword_3_2(), foldingRegionAcceptor); }
Example #14
Source File: StatemachineFoldingRegionProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private void computeResetEventsFolding(XtextResource res, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { computeFoldingRegionBetweenKeywords(res, statemachineGrammarAccess.getStatemachineAccess().getResetEventsKeyword_2_0(), statemachineGrammarAccess.getStatemachineAccess().getEndKeyword_2_2(), foldingRegionAcceptor); }
Example #15
Source File: StatemachineFoldingRegionProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private void computeEventsFolding(XtextResource res, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { computeFoldingRegionBetweenKeywords(res, statemachineGrammarAccess.getStatemachineAccess().getEventsKeyword_1_0(), statemachineGrammarAccess.getStatemachineAccess().getEndKeyword_1_2(), foldingRegionAcceptor); }
Example #16
Source File: GamaFoldingRegionProvider.java From gama with GNU General Public License v3.0 | 4 votes |
@Override protected void computeObjectFolding(final XtextResource xtextResource, final IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { super.computeObjectFolding(xtextResource, foldingRegionAcceptor); }
Example #17
Source File: GamaFoldingRegionProvider.java From gama with GNU General Public License v3.0 | 4 votes |
@Override protected void computeObjectFolding(final EObject eObject, final IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { super.computeObjectFolding(eObject, foldingRegionAcceptor); }
Example #18
Source File: GamaFoldingRegionProvider.java From gama with GNU General Public License v3.0 | 4 votes |
@Override protected void computeObjectFolding(final EObject eObject, final IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor, final boolean initiallyFolded) { super.computeObjectFolding(eObject, foldingRegionAcceptor, initiallyFolded); }
Example #19
Source File: GamaFoldingRegionProvider.java From gama with GNU General Public License v3.0 | 4 votes |
@Override protected IFoldingRegionAcceptor<ITextRegion> createAcceptor(final IXtextDocument xtextDocument, final Collection<FoldedPosition> foldedPositions) { return new GamaFoldingRegionAcceptor(xtextDocument, foldedPositions); }