1 11 12 package org.eclipse.jdt.internal.ui.text.comment; 13 14 import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement; 15 16 21 public class SingleCommentLine extends CommentLine { 22 23 24 public static final String SINGLE_COMMENT_PREFIX= "// "; 26 27 private boolean fLocaleSequence= false; 28 29 35 protected SingleCommentLine(final CommentRegion region) { 36 super(region); 37 } 38 39 42 protected void adapt(final CommentLine previous) { 43 } 45 46 49 protected void formatLowerBorder(final CommentRange range, final String indentation, final int length) { 50 51 final int offset= range.getOffset() + range.getLength(); 52 final CommentRegion parent= getParent(); 53 54 parent.logEdit(parent.getDelimiter(), offset, parent.getLength() - offset); 55 } 56 57 60 protected void formatUpperBorder(final CommentRange range, final String indentation, final int length) { 61 62 final CommentRegion parent= getParent(); 63 64 parent.logEdit(getContentPrefix(), 0, range.getOffset() - parent.getOffset()); 65 } 66 67 70 protected String getContentPrefix() { 71 return SINGLE_COMMENT_PREFIX; 72 } 73 74 77 protected String getEndingPrefix() { 78 return SINGLE_COMMENT_PREFIX; 79 } 80 81 84 protected String getStartingPrefix() { 85 return SINGLE_COMMENT_PREFIX; 86 } 87 88 91 protected void scanLine(final int line) { 92 93 final CommentRange range= getFirst(); 94 final String content= getParent().getText(range.getOffset(), range.getLength()); 95 final String prefix= getContentPrefix().trim(); 96 97 final int offset= content.indexOf(prefix); 98 if (offset >= 0) { 99 100 if (content.startsWith(NLSElement.TAG_PREFIX)) 101 fLocaleSequence= true; 102 103 range.trimBegin(offset + prefix.length()); 104 } 105 } 106 107 110 protected void tokenizeLine(final int line) { 111 112 if (!fLocaleSequence) 113 super.tokenizeLine(line); 114 } 115 } 116 | Popular Tags |