Skip to content

Commit

Permalink
Code samples: Change the CONTINUATION_INDENT_SIZE from 8 to 4 and ref…
Browse files Browse the repository at this point in the history
…ormat code.

We use INDENT_SIZE = 2 and continuation size should be at most 4 in this case.
  • Loading branch information
karollewandowski committed Sep 7, 2023
1 parent 9519c2e commit e87f195
Show file tree
Hide file tree
Showing 43 changed files with 230 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public void visitBinaryExpression(@NotNull PsiBinaryExpression expression) {
if (isStringType(lOperand) || isStringType(rOperand)) {
// Identified an expression with potential problems, register problem with the quick fix object
holder.registerProblem(expression,
InspectionBundle.message("inspection.comparing.string.references.problem.descriptor"),
myQuickFix);
InspectionBundle.message("inspection.comparing.string.references.problem.descriptor"),
myQuickFix);
}
}
}
Expand All @@ -75,7 +75,7 @@ private boolean isStringType(PsiExpression operand) {

private static boolean isNullLiteral(PsiExpression expression) {
return expression instanceof PsiLiteralExpression &&
((PsiLiteralExpression) expression).getValue() == null;
((PsiLiteralExpression) expression).getValue() == null;
}
};
}
Expand Down Expand Up @@ -115,7 +115,7 @@ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descri

PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
PsiMethodCallExpression equalsCall =
(PsiMethodCallExpression) factory.createExpressionFromText("a.equals(b)", null);
(PsiMethodCallExpression) factory.createExpressionFromText("a.equals(b)", null);

PsiExpression qualifierExpression = equalsCall.getMethodExpression().getQualifierExpression();
assert qualifierExpression != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class ComparingStringReferencesInspectionTest extends LightJavaCodeInsightFixtureTestCase {

private static final String QUICK_FIX_NAME =
InspectionBundle.message("inspection.comparing.string.references.use.quickfix");
InspectionBundle.message("inspection.comparing.string.references.use.quickfix");

@Override
protected void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void actionPerformed(@NotNull final AnActionEvent e) {
int caretOffset = primaryCaret.getOffset();
// Build and display the caret report.
String report = logicalPos + "\n" + visualPos + "\n" +
"Offset: " + caretOffset;
"Offset: " + caretOffset;
Messages.showInfoMessage(report, "Caret Parameters Inside The Editor");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void actionPerformed(@NotNull final AnActionEvent e) {
final EditorActionManager actionManager = EditorActionManager.getInstance();
// Get the action handler registered to clone carets
final EditorActionHandler actionHandler =
actionManager.getActionHandler(IdeActions.ACTION_EDITOR_CLONE_CARET_BELOW);
actionManager.getActionHandler(IdeActions.ACTION_EDITOR_CLONE_CARET_BELOW);
// Clone one caret below the active caret
actionHandler.execute(editor, editor.getCaretModel().getPrimaryCaret(), e.getDataContext());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void actionPerformed(@NotNull final AnActionEvent e) {
// Replace the selection with a fixed string.
// Must do this document change in a write action context.
WriteCommandAction.runWriteCommandAction(project, () ->
document.replaceString(start, end, "Replacement")
document.replaceString(start, end, "Replacement")
);
// De-select the text range that was just replaced
primaryCaret.removeSelection();
Expand All @@ -67,7 +67,7 @@ public void update(@NotNull final AnActionEvent e) {
final Editor editor = e.getData(CommonDataKeys.EDITOR);
// Set visibility and enable only in case of existing project and editor and if a selection exists
e.getPresentation().setEnabledAndVisible(
project != null && editor != null && editor.getSelectionModel().hasSelection()
project != null && editor != null && editor.getSelectionModel().hasSelection()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void loadState(@NotNull DemoFacetState state) {
@Override
public FacetEditorTab[] createEditorTabs(FacetEditorContext context, FacetValidatorsManager manager) {
return new FacetEditorTab[]{
new DemoFacetEditorTab(myFacetState, context, manager)
new DemoFacetEditorTab(myFacetState, context, manager)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Manages validation and modification of the {@link DemoFacet} state.
*/
public class DemoFacetEditorTab extends FacetEditorTab {

private static final String FACET_PANEL_PROMPT = "Path To SDK: ";

private final DemoFacetState mySettings;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void apply() throws ConfigurationException {
try {
String newTextContent = myPath.getText();
mySettings.setDemoFacetState(newTextContent);
} catch(Exception e) {
} catch (Exception e) {
throw new ConfigurationException(e.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void projectClosed(@NotNull Project project) {

// Get the counting service
ProjectCountingService projectCountingService =
ApplicationManager.getApplication().getService(ProjectCountingService.class);
ApplicationManager.getApplication().getService(ProjectCountingService.class);
// Decrement the count because a project just closed
projectCountingService.decreaseOpenProjectCount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void runActivity(@NotNull Project project) {

// Get the counting service
ProjectCountingService projectCountingService =
ApplicationManager.getApplication().getService(ProjectCountingService.class);
ApplicationManager.getApplication().getService(ProjectCountingService.class);
// Increment the project count
projectCountingService.increaseOpenProjectCount();

Expand All @@ -33,7 +33,7 @@ public void runActivity(@NotNull Project project) {
String message = "<br>The number of open projects exceeds the SDK plugin max_opened_projects limit.<br><br>";

ApplicationManager.getApplication().invokeLater(() ->
Messages.showMessageDialog(project, message, title, Messages.getInformationIcon())
Messages.showMessageDialog(project, message, title, Messages.getInformationIcon())
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class PopupDialogAction extends AnAction {
public void actionPerformed(@NotNull AnActionEvent event) {
Project project = event.getProject();
Messages.showMessageDialog(project,
"Popup dialog action",
"Greetings from PyCharm Basics Plugin",
Messages.getInformationIcon());
"Popup dialog action",
"Greetings from PyCharm Basics Plugin",
Messages.getInformationIcon());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void actionPerformed(@NotNull AnActionEvent event) {
fileAndLibs = "None";
}
Messages.showInfoMessage("Libraries for file: " + fileAndLibs,
"Libraries Info");
"Libraries Info");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public void actionPerformed(@NotNull final AnActionEvent event) {
boolean isInLibraryClasses = projectFileIndex.isInLibraryClasses(virtualFile);
boolean isInLibrarySource = projectFileIndex.isInLibrarySource(virtualFile);
Messages.showInfoMessage("Module: " + moduleName + "\n" +
"Module content root: " + moduleContentRoot + "\n" +
"Is library file: " + isLibraryFile + "\n" +
"Is in library classes: " + isInLibraryClasses +
", Is in library source: " + isInLibrarySource,
"Main File Info for" + virtualFile.getName());
"Module content root: " + moduleContentRoot + "\n" +
"Is library file: " + isLibraryFile + "\n" +
"Is in library classes: " + isInLibraryClasses +
", Is in library source: " + isInLibrarySource,
"Main File Info for" + virtualFile.getName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public void actionPerformed(@NotNull final AnActionEvent event) {
sourceRootsList.append(file.getUrl()).append("\n");
}
Messages.showInfoMessage(
"Source roots for the " + projectName + " plugin:\n" + sourceRootsList.toString(),
"Project Properties"
"Source roots for the " + projectName + " plugin:\n" + sourceRootsList.toString(),
"Project Properties"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public void run() {
getImagesFiles(project).clear();
scanImages(project);
ApplicationManager.getApplication().invokeLater(() ->
ProjectView.getInstance(project)
.getProjectViewPaneById(ImagesProjectViewPane.ID)
.updateFromRoot(true),
ProjectView.getInstance(project)
.getProjectViewPaneById(ImagesProjectViewPane.ID)
.updateFromRoot(true),
project.getDisposed()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public void actionPerformed(AnActionEvent anActionEvent) {
if (element != null) {
PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
infoBuilder
.append("Containing method: ")
.append(containingMethod != null ? containingMethod.getName() : "none")
.append("\n");
.append("Containing method: ")
.append(containingMethod != null ? containingMethod.getName() : "none")
.append("\n");
if (containingMethod != null) {
PsiClass containingClass = containingMethod.getContainingClass();
infoBuilder
.append("Containing class: ")
.append(containingClass != null ? containingClass.getName() : "none")
.append("\n");
.append("Containing class: ")
.append(containingClass != null ? containingClass.getName() : "none")
.append("\n");

infoBuilder.append("Local variables:\n");
containingMethod.accept(new JavaRecursiveElementVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected DemoConfigurationFactory(ConfigurationType type) {
@NotNull
@Override
public RunConfiguration createTemplateConfiguration(
@NotNull Project project) {
@NotNull Project project) {
return new DemoRunConfiguration(project, this, "Demo");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public RunProfileState getState(@NotNull Executor executor,
@Override
protected ProcessHandler startProcess() throws ExecutionException {
GeneralCommandLine commandLine =
new GeneralCommandLine(getOptions().getScriptName());
new GeneralCommandLine(getOptions().getScriptName());
OSProcessHandler processHandler = ProcessHandlerFactory.getInstance()
.createColoredProcessHandler(commandLine);
.createColoredProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class DemoRunConfigurationOptions extends RunConfigurationOptions {

private final StoredProperty<String> myScriptName =
string("").provideDelegate(this, "scriptName");
string("").provideDelegate(this, "scriptName");

public String getScriptName() {
return myScriptName.getValue(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DemoRunConfigurationType extends ConfigurationTypeBase {

protected DemoRunConfigurationType() {
super(ID, "Demo", "Demo run configuration type",
NotNullLazyValue.createValue(() -> AllIcons.Nodes.Console));
NotNullLazyValue.createValue(() -> AllIcons.Nodes.Console));
addFactory(new DemoConfigurationFactory(this));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public class DemoSettingsEditor extends SettingsEditor<DemoRunConfiguration> {
public DemoSettingsEditor() {
scriptPathField = new TextFieldWithBrowseButton();
scriptPathField.addBrowseFolderListener("Select Script File", null, null,
FileChooserDescriptorFactory.createSingleFileDescriptor());
FileChooserDescriptorFactory.createSingleFileDescriptor());
myPanel = FormBuilder.createFormBuilder()
.addLabeledComponent("Script file", scriptPathField)
.getPanel();
.addLabeledComponent("Script file", scriptPathField)
.getPanel();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class AppSettingsComponent {

public AppSettingsComponent() {
myMainPanel = FormBuilder.createFormBuilder()
.addLabeledComponent(new JBLabel("Enter user name: "), myUserNameText, 1, false)
.addComponent(myIdeaUserStatus, 1)
.addComponentFillVertically(new JPanel(), 0)
.getPanel();
.addLabeledComponent(new JBLabel("Enter user name: "), myUserNameText, 1, false)
.addComponent(myIdeaUserStatus, 1)
.addComponentFillVertically(new JPanel(), 0)
.getPanel();
}

public JPanel getPanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* these persistent application settings are stored.
*/
@State(
name = "org.intellij.sdk.settings.AppSettingsState",
storages = @Storage("SdkSettingsPlugin.xml")
name = "org.intellij.sdk.settings.AppSettingsState",
storages = @Storage("SdkSettingsPlugin.xml")
)
public class AppSettingsState implements PersistentStateComponent<AppSettingsState> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolde

// highlight "simple" prefix and ":" separator
holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(prefixRange).textAttributes(DefaultLanguageHighlighterColors.KEYWORD).create();
.range(prefixRange).textAttributes(DefaultLanguageHighlighterColors.KEYWORD).create();
holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(separatorRange).textAttributes(SimpleSyntaxHighlighter.SEPARATOR).create();
.range(separatorRange).textAttributes(SimpleSyntaxHighlighter.SEPARATOR).create();


// Get the list of properties for given key
String key = value.substring(SIMPLE_PREFIX_STR.length() + SIMPLE_SEPARATOR_STR.length());
List<SimpleProperty> properties = SimpleUtil.findProperties(element.getProject(), key);
if (properties.isEmpty()) {
holder.newAnnotation(HighlightSeverity.ERROR, "Unresolved property")
.range(keyRange)
.highlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL)
// ** Tutorial step 19. - Add a quick fix for the string containing possible properties
.withFix(new SimpleCreatePropertyQuickFix(key))
.create();
.range(keyRange)
.highlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL)
// ** Tutorial step 19. - Add a quick fix for the string containing possible properties
.withFix(new SimpleCreatePropertyQuickFix(key))
.create();
} else {
// Found at least one property, force the text attributes to Simple syntax value character
holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(keyRange).textAttributes(SimpleSyntaxHighlighter.VALUE).create();
.range(keyRange).textAttributes(SimpleSyntaxHighlighter.VALUE).create();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected List<Block> buildChildren() {
while (child != null) {
if (child.getElementType() != TokenType.WHITE_SPACE) {
Block block = new SimpleBlock(child, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment(),
spacingBuilder);
spacingBuilder);
blocks.add(block);
}
child = child.getTreeNext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void processNames(@NotNull Processor<? super String> processor,
@Nullable IdFilter filter) {
Project project = Objects.requireNonNull(scope.getProject());
List<String> propertyKeys = ContainerUtil.map(
SimpleUtil.findProperties(project), SimpleProperty::getKey);
SimpleUtil.findProperties(project), SimpleProperty::getKey);
ContainerUtil.process(propertyKeys, processor);
}

Expand All @@ -34,8 +34,8 @@ public void processElementsWithName(@NotNull String name,
@NotNull Processor<? super NavigationItem> processor,
@NotNull FindSymbolParameters parameters) {
List<NavigationItem> properties = ContainerUtil.map(
SimpleUtil.findProperties(parameters.getProject(), name),
property -> (NavigationItem) property);
SimpleUtil.findProperties(parameters.getProject(), name),
property -> (NavigationItem) property);
ContainerUtil.process(properties, processor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
public class SimpleColorSettingsPage implements ColorSettingsPage {

private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{
new AttributesDescriptor("Key", SimpleSyntaxHighlighter.KEY),
new AttributesDescriptor("Separator", SimpleSyntaxHighlighter.SEPARATOR),
new AttributesDescriptor("Value", SimpleSyntaxHighlighter.VALUE),
new AttributesDescriptor("Bad value", SimpleSyntaxHighlighter.BAD_CHARACTER)
new AttributesDescriptor("Key", SimpleSyntaxHighlighter.KEY),
new AttributesDescriptor("Separator", SimpleSyntaxHighlighter.SEPARATOR),
new AttributesDescriptor("Value", SimpleSyntaxHighlighter.VALUE),
new AttributesDescriptor("Bad value", SimpleSyntaxHighlighter.BAD_CHARACTER)
};

@Nullable
Expand All @@ -38,17 +38,17 @@ public SyntaxHighlighter getHighlighter() {
@Override
public String getDemoText() {
return "# You are reading the \".properties\" entry.\n" +
"! The exclamation mark can also mark text as comments.\n" +
"website = https://en.wikipedia.org/\n" +
"language = English\n" +
"# The backslash below tells the application to continue reading\n" +
"# the value onto the next line.\n" +
"message = Welcome to \\\n" +
" Wikipedia!\n" +
"# Add spaces to the key\n" +
"key\\ with\\ spaces = This is the value that could be looked up with the key \"key with spaces\".\n" +
"# Unicode\n" +
"tab : \\u0009";
"! The exclamation mark can also mark text as comments.\n" +
"website = https://en.wikipedia.org/\n" +
"language = English\n" +
"# The backslash below tells the application to continue reading\n" +
"# the value onto the next line.\n" +
"message = Welcome to \\\n" +
" Wikipedia!\n" +
"# Add spaces to the key\n" +
"key\\ with\\ spaces = This is the value that could be looked up with the key \"key with spaces\".\n" +
"# Unicode\n" +
"tab : \\u0009";
}

@Nullable
Expand Down
Loading

0 comments on commit e87f195

Please sign in to comment.