private void preserveWhitespace(Token commentToken, int commentIndex) { if (this.options.comment_preserve_white_space_between_code_and_line_comments && commentToken.getLineBreaksBefore() == 0 && commentIndex > 0) { commentToken.clearSpaceBefore(); List<Token> structure = commentToken.getInternalStructure(); if (structure != null && !structure.isEmpty()) structure.get(0).clearSpaceBefore(); Token previous = this.tm.get(commentIndex - 1); previous.clearSpaceAfter(); if (previous.originalEnd + 1 >= commentToken.originalStart) return; if (structure == null || structure.isEmpty()) { structure = new ArrayList<>(); structure.add(new Token(previous.originalEnd + 1, commentToken.originalEnd, TokenNameCOMMENT_LINE)); commentToken.setInternalStructure(structure); } else { structure.add(0, new Token(previous.originalEnd + 1, commentToken.originalStart - 1, TokenNameWHITESPACE)); } } }
private void preserveWhitespace(Token commentToken, int commentIndex) { if (this.options.comment_preserve_white_space_between_code_and_line_comments && commentToken.getLineBreaksBefore() == 0 && commentIndex > 0) { commentToken.clearSpaceBefore(); List<Token> structure = commentToken.getInternalStructure(); if (structure != null && !structure.isEmpty()) structure.get(0).clearSpaceBefore(); Token previous = this.tm.get(commentIndex - 1); previous.clearSpaceAfter(); if (previous.originalEnd + 1 >= commentToken.originalStart) return; if (structure == null || structure.isEmpty()) { structure = new ArrayList<>(); structure.add(new Token(previous.originalEnd + 1, commentToken.originalEnd, TokenNameCOMMENT_LINE)); commentToken.setInternalStructure(structure); } else { structure.add(0, new Token(previous.originalEnd + 1, commentToken.originalStart - 1, TokenNameWHITESPACE)); } } }
private void preserveWhitespace(Token commentToken, int commentIndex) { if (this.options.comment_preserve_white_space_between_code_and_line_comments && commentToken.getLineBreaksBefore() == 0 && commentIndex > 0) { commentToken.clearSpaceBefore(); List<Token> structure = commentToken.getInternalStructure(); if (structure != null && !structure.isEmpty()) structure.get(0).clearSpaceBefore(); Token previous = this.tm.get(commentIndex - 1); previous.clearSpaceAfter(); if (previous.originalEnd + 1 >= commentToken.originalStart) return; if (structure == null || structure.isEmpty()) { structure = new ArrayList<>(); structure.add(new Token(previous.originalEnd + 1, commentToken.originalEnd, TokenNameCOMMENT_LINE)); commentToken.setInternalStructure(structure); } else { structure.add(0, new Token(previous.originalEnd + 1, commentToken.originalStart - 1, TokenNameWHITESPACE)); } } }
private void handleBreakBeforeTag(int start, int end, boolean isOpeningTag) { int firstPartIndex = tokenStartingAt(start); int lastPartIndex = tokenEndingAt(end); Token firstPartToken = this.ctm.get(firstPartIndex); firstPartToken.setWrapPolicy(null); if (isOpeningTag) { firstPartToken.breakBefore(); this.ctm.get(lastPartIndex + 1).clearSpaceBefore(); } else { firstPartToken.clearSpaceBefore(); } }
private void handleBreakBeforeTag(int start, int end, boolean isOpeningTag) { int firstPartIndex = tokenStartingAt(start); int lastPartIndex = tokenEndingAt(end); Token firstPartToken = this.ctm.get(firstPartIndex); firstPartToken.setWrapPolicy(null); if (isOpeningTag) { firstPartToken.breakBefore(); this.ctm.get(lastPartIndex + 1).clearSpaceBefore(); } else { firstPartToken.clearSpaceBefore(); } }
private void handleBreakBeforeTag(int start, int end, boolean isOpeningTag) { int firstPartIndex = tokenStartingAt(start); int lastPartIndex = tokenEndingAt(end); Token firstPartToken = this.ctm.get(firstPartIndex); firstPartToken.setWrapPolicy(null); if (isOpeningTag) { firstPartToken.breakBefore(); this.ctm.get(lastPartIndex + 1).clearSpaceBefore(); } else { firstPartToken.clearSpaceBefore(); } }
private void handleCompilerTags(Token commentToken, int commentIndex) { final String commentText = this.tm.toString(commentToken); final List<Token> structure = commentToken.getInternalStructure(); if (commentText.startsWith("//$FALL-THROUGH$") //$NON-NLS-1$ || commentText.startsWith("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ structure.get(1).clearSpaceBefore(); } if (commentText.contains("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ // make sure the whole line is not broken Token token = commentToken; for (int i = commentIndex; i > 0; i--) { Token left = this.tm.get(i - 1); if (this.tm.countLineBreaksBetween(left, token) > 0) break; token.clearLineBreaksBefore(); left.clearLineBreaksAfter(); token.setWrapPolicy(WrapPolicy.DISABLE_WRAP); token = left; } } }
private void handleCompilerTags(Token commentToken, int commentIndex) { final String commentText = this.tm.toString(commentToken); final List<Token> structure = commentToken.getInternalStructure(); if (commentText.startsWith("//$FALL-THROUGH$") //$NON-NLS-1$ || commentText.startsWith("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ structure.get(1).clearSpaceBefore(); } if (commentText.contains("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ // make sure the whole line is not broken Token token = commentToken; for (int i = commentIndex; i > 0; i--) { Token left = this.tm.get(i - 1); if (this.tm.countLineBreaksBetween(left, token) > 0) break; token.clearLineBreaksBefore(); left.clearLineBreaksAfter(); token.setWrapPolicy(WrapPolicy.DISABLE_WRAP); token = left; } } }
private void handleCompilerTags(Token commentToken, int commentIndex) { final String commentText = this.tm.toString(commentToken); final List<Token> structure = commentToken.getInternalStructure(); if (commentText.startsWith("//$FALL-THROUGH$") //$NON-NLS-1$ || commentText.startsWith("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ structure.get(1).clearSpaceBefore(); } if (commentText.contains("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ // make sure the whole line is not broken Token token = commentToken; for (int i = commentIndex; i > 0; i--) { Token left = this.tm.get(i - 1); if (this.tm.countLineBreaksBetween(left, token) > 0) break; token.clearLineBreaksBefore(); left.clearLineBreaksAfter(); token.setWrapPolicy(WrapPolicy.DISABLE_WRAP); token = left; } } }
if (existingBreaksBefore > 0) { commentToken.breakBefore(); commentToken.clearSpaceBefore();
if (existingBreaksBefore > 0) { commentToken.breakBefore(); commentToken.clearSpaceBefore();
if (existingBreaksBefore > 0) { commentToken.breakBefore(); commentToken.clearSpaceBefore();