@Override protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration, ISourceViewer sourceViewer) { super.setContentAssistProcessor(assistant, configuration, sourceViewer); assistant.setContentAssistProcessor(jsDocContentAssistProcessor, TokenTypeToPartitionMapper.JS_DOC_PARTITION); assistant.setContentAssistProcessor(null, TokenTypeToPartitionMapper.REG_EX_PARTITION); assistant.setContentAssistProcessor(null, TokenTypeToPartitionMapper.TEMPLATE_LITERAL_PARTITION); assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION); assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION); }
@Override public boolean isInsertClosingBracket(IDocument doc, int offset) throws BadLocationException { if (offset >= 2) { ITypedRegion prevPartition = doc.getPartition(offset - 1); String prevPartitionType = prevPartition.getType(); if (TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION.equals(prevPartitionType)) { return false; } if (TokenTypeToPartitionMapper.REG_EX_PARTITION.equals(prevPartitionType)) { return prevPartition.getLength() == 1; } } return SingleLineTerminalsStrategy.DEFAULT.isInsertClosingBracket(doc, offset); }
@Override protected void configureMultilineComments(IEditStrategyAcceptor acceptor) { IAutoEditStrategy multiline = multiLineTerminals.newInstance("/*", " * ", " */"); IAutoEditStrategy singleline = singleLineTerminals.newInstance("/*", " */", new SupressingMLCommentPredicate()); acceptor.accept(singleline, IDocument.DEFAULT_CONTENT_TYPE); acceptor.accept(multiline, IDocument.DEFAULT_CONTENT_TYPE); acceptor.accept(multiline, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION); acceptor.accept(multiline, JS_DOC_PARTITION); acceptor.accept(singleLineTerminals.newInstance("/*", " */"), REG_EX_PARTITION); acceptor.accept(multiline, REG_EX_PARTITION); }
public ITextDoubleClickStrategy getStrategy(ISourceViewer sourceViewer, String contentType, String documentPartitioning) { if (TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION.equals(contentType)) return new FixedCharCountPartitionDoubleClickSelector(documentPartitioning, 0, 0); if (TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION.equals(contentType)) return new FixedCharCountPartitionDoubleClickSelector(documentPartitioning, 0, 0); if (TerminalsTokenTypeToPartitionMapper.STRING_LITERAL_PARTITION.equals(contentType)) return new FixedCharCountPartitionDoubleClickSelector(documentPartitioning, 1, 1); return defaultDoubleClickStrategy; }
protected void configureStringLiteral(IEditStrategyAcceptor acceptor) { acceptor.accept(partitionInsert.newInstance("\"","\""),IDocument.DEFAULT_CONTENT_TYPE); acceptor.accept(partitionInsert.newInstance("'","'"),IDocument.DEFAULT_CONTENT_TYPE); // The following two are registered for the default content type, because on deletion // the command.offset is cursor-1, which is outside the partition of terminals.length = 1. // How crude is that? // Note that in case you have two string literals following each other directly, the deletion strategy wouldn't apply. // One could add the same strategy for the STRING partition in addition to solve this acceptor.accept(partitionDeletion.newInstance("\"","\""),IDocument.DEFAULT_CONTENT_TYPE); acceptor.accept(partitionDeletion.newInstance("'","'"),IDocument.DEFAULT_CONTENT_TYPE); acceptor.accept(partitionEndSkippingEditStrategy.get(),TerminalsTokenTypeToPartitionMapper.STRING_LITERAL_PARTITION); }
/** * Configure the token to partition type mapper. */ public Class<? extends TerminalsTokenTypeToPartitionMapper> bindTerminalTokenTypeToPartitionMapper() { return TokenTypeToPartitionMapper.class; }
@Deprecated public DefaultFoldingRegionProvider(ILocationInFileProvider locationInFileProvider) { this.locationInFileProvider = locationInFileProvider; this.tokenTypeToPartitionTypeMapperExtension = new TerminalsTokenTypeToPartitionMapper(); }
protected void configureIndentationEditStrategy(IEditStrategyAcceptor acceptor) { acceptor.accept(defaultIndentLineAutoEditStrategy.get(), IDocument.DEFAULT_CONTENT_TYPE); acceptor.accept(defaultIndentLineAutoEditStrategy.get(), TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION); acceptor.accept(defaultIndentLineAutoEditStrategy.get(), TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION); }
protected void configureMultilineComments(IEditStrategyAcceptor acceptor) { acceptor.accept(singleLineTerminals.newInstance("/*", " */"),IDocument.DEFAULT_CONTENT_TYPE); acceptor.accept(multiLineTerminals.newInstance("/*"," * ", " */"),IDocument.DEFAULT_CONTENT_TYPE); acceptor.accept(multiLineTerminals.newInstance("/*"," * ", " */"),TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION); }