1 11 package org.eclipse.jdt.internal.ui.propertiesfileeditor; 12 13 import org.eclipse.core.filebuffers.IDocumentSetupParticipant; 14 15 import org.eclipse.jface.text.IDocument; 16 import org.eclipse.jface.text.IDocumentExtension3; 17 import org.eclipse.jface.text.IDocumentPartitioner; 18 import org.eclipse.jface.text.rules.FastPartitioner; 19 20 25 public class PropertiesFileDocumentSetupParticipant implements IDocumentSetupParticipant { 26 27 30 public void setup(IDocument document) { 31 setupDocument(document); 32 } 33 34 37 public static void setupDocument(IDocument document) { 38 IDocumentPartitioner partitioner= createDocumentPartitioner(); 39 if (document instanceof IDocumentExtension3) { 40 IDocumentExtension3 extension3= (IDocumentExtension3) document; 41 extension3.setDocumentPartitioner(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, partitioner); 42 } else { 43 document.setDocumentPartitioner(partitioner); 44 } 45 partitioner.connect(document); 46 } 47 48 54 private static IDocumentPartitioner createDocumentPartitioner() { 55 return new FastPartitioner(new PropertiesFilePartitionScanner(), IPropertiesFilePartitions.PARTITIONS); 56 } 57 } 58 | Popular Tags |