mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
a840d359aa
commit
74d3d47147
3 changed files with 10 additions and 20 deletions
|
@ -51,9 +51,9 @@ import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
|
|||
* @since 4.0
|
||||
*/
|
||||
public abstract class CPreview {
|
||||
|
||||
|
||||
private final class CSourcePreviewerUpdater {
|
||||
|
||||
|
||||
final IPropertyChangeListener fontListener= new IPropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
|
||||
|
@ -76,7 +76,6 @@ public abstract class CPreview {
|
|||
};
|
||||
|
||||
public CSourcePreviewerUpdater() {
|
||||
|
||||
JFaceResources.getFontRegistry().addListener(fontListener);
|
||||
fPreferenceStore.addPropertyChangeListener(propertyListener);
|
||||
|
||||
|
@ -190,8 +189,6 @@ public abstract class CPreview {
|
|||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String, String> getWorkingValues() {
|
||||
return fWorkingValues;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* IBM Corporation - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -28,11 +27,9 @@ import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
|
|||
|
||||
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
||||
|
||||
|
||||
public class SnippetPreview extends CPreview {
|
||||
|
||||
public final static class PreviewSnippet {
|
||||
|
||||
public String header;
|
||||
public final String source;
|
||||
public final int kind;
|
||||
|
@ -45,7 +42,7 @@ public class SnippetPreview extends CPreview {
|
|||
|
||||
private ArrayList<PreviewSnippet> fSnippets;
|
||||
|
||||
public SnippetPreview(Map<String,String> workingValues, Composite parent) {
|
||||
public SnippetPreview(Map<String, String> workingValues, Composite parent) {
|
||||
super(workingValues, parent);
|
||||
fSnippets= new ArrayList<PreviewSnippet>();
|
||||
}
|
||||
|
@ -57,14 +54,15 @@ public class SnippetPreview extends CPreview {
|
|||
return;
|
||||
}
|
||||
|
||||
//This delimiter looks best for invisible characters
|
||||
// This delimiter looks best for invisible characters
|
||||
final String delimiter= "\n"; //$NON-NLS-1$
|
||||
|
||||
final StringBuffer buffer= new StringBuffer();
|
||||
for (PreviewSnippet snippet: fSnippets) {
|
||||
String formattedSource;
|
||||
try {
|
||||
TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter, fWorkingValues);
|
||||
TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter,
|
||||
fWorkingValues);
|
||||
if (edit == null) {
|
||||
formattedSource= snippet.source;
|
||||
} else {
|
||||
|
@ -73,8 +71,9 @@ public class SnippetPreview extends CPreview {
|
|||
formattedSource= document.get();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR,
|
||||
FormatterMessages.CPreview_formatter_exception, e);
|
||||
final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
|
||||
ICStatusConstants.INTERNAL_ERROR,
|
||||
FormatterMessages.CPreview_formatter_exception, e);
|
||||
CUIPlugin.log(status);
|
||||
continue;
|
||||
}
|
||||
|
@ -85,9 +84,7 @@ public class SnippetPreview extends CPreview {
|
|||
}
|
||||
fPreviewDocument.set(buffer.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void add(PreviewSnippet snippet) {
|
||||
fSnippets.add(snippet);
|
||||
}
|
||||
|
@ -103,5 +100,4 @@ public class SnippetPreview extends CPreview {
|
|||
public void clear() {
|
||||
fSnippets.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* Sergey Prigogin, Google
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -31,9 +30,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
|||
|
||||
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
||||
|
||||
|
||||
public class TranslationUnitPreview extends CPreview {
|
||||
|
||||
private String fPreviewText;
|
||||
private String fFormatterId;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue