omegaui / omegaide

An Instant IDE from the Future that supports any programming language.
https://omegaui.github.io/omegaide/
GNU General Public License v3.0
77 stars 12 forks source link

Increase the usage of compound assignment operators #9

Closed elfring closed 2 years ago

elfring commented 2 years ago

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of compound operators accordingly.

diff --git a/src/omega/utils/IconManager.java b/src/omega/utils/IconManager.java
index 197bca4..ba18448 100644
--- a/src/omega/utils/IconManager.java
+++ b/src/omega/utils/IconManager.java
@@ -234,7 +234,7 @@ public class IconManager {
      private static final Icon getIcon(String path) {
           if(omega.utils.UIManager.isDarkMode()) {
                path = path.substring(0, path.lastIndexOf('.'));
-               path = path + "_dark" + ".png";
+               path += "_dark.png";
           }
           try {
                BufferedImage image = ImageIO.read(IconManager.class.getResource(path));
@@ -246,7 +246,7 @@ public class IconManager {
      private static final BufferedImage getImage(String path) {
           if(omega.utils.UIManager.isDarkMode()) {
                path = path.substring(0, path.lastIndexOf('.'));
-               path = path + "_dark" + ".png";
+               path += "_dark.png";
           }
           try {
                return ImageIO.read(IconManager.class.getResource(path));
@@ -261,7 +261,7 @@ public class IconManager {
        if(omega.utils.UIManager.isDarkMode()
                && !path.contains("Theme")) {
            path = path.substring(0, path.lastIndexOf('.'));
-           path = path + "_dark" + ".png";
+           path += "_dark.png";
        }
        try {
            BufferedImage image = ImageIO.read(IconManager.class.getResource(path));
diff --git a/src/omega/utils/systems/RunView.java b/src/omega/utils/systems/RunView.java
index 2b2d6c1..2f9e219 100644
--- a/src/omega/utils/systems/RunView.java
+++ b/src/omega/utils/systems/RunView.java
@@ -237,7 +237,7 @@ public class RunView extends View {
            String name = "Run";
            int count = OperationPane.count(name);
            if(count > -1)
-               name = name + " " + count;
+               name += " " + count;

            if(!Screen.isNotNull(Screen.getFileView().getArgumentManager().getRunCommand())){
                NotificationPopup.create(getScreen())
@@ -331,7 +331,7 @@ public class RunView extends View {

                if(!NATIVE_PATH.equals("")) {
                    NATIVE_PATH = NATIVE_PATH.substring(0, NATIVE_PATH.length() - 1);
-                   NATIVE_PATH = NATIVE_PATH + omega.Screen.PATH_SEPARATOR + "$PATH";
+                   NATIVE_PATH += omega.Screen.PATH_SEPARATOR + "$PATH";
                }
                else
                    NATIVE_PATH = "$PATH";
@@ -412,8 +412,8 @@ public class RunView extends View {
                String name = "Run("+mainClass;
                int count = OperationPane.count(name);
                if(count > -1)
-                   name = name + " " + count;
-               name =  name + ")";
+                   name += " " + count;
+               name += ")";

                getScreen().getOperationPanel().addTab(name, IconManager.fluentquickmodeonImage, terminal, terminal::killProcess);
                terminal.start();
@@ -789,7 +789,7 @@ public class RunView extends View {
                }
                if(!NATIVE_PATH.equals("")) {
                    NATIVE_PATH = NATIVE_PATH.substring(0, NATIVE_PATH.length() - 1);
-                   NATIVE_PATH = NATIVE_PATH + omega.Screen.PATH_SEPARATOR + "$PATH";
+                   NATIVE_PATH += omega.Screen.PATH_SEPARATOR + "$PATH";
                }
                else
                    NATIVE_PATH = "$PATH";
@@ -866,9 +866,9 @@ public class RunView extends View {
                String name = "Run("+mainClass;
                int count = OperationPane.count(name);
                if(count > -1) {
-                   name = name + " " + count;
+                   name += " " + count;
                }
-               name =  name + ")";
+               name += ")";

                getScreen().getOperationPanel().addTab(name, IconManager.fluentquickmodeonImage, terminal, terminal::killProcess);
                terminal.start();
diff --git a/src/org/fife/com/swabunga/spell/engine/GenericTransformator.java b/src/org/fife/com/swabunga/spell/engine/GenericTransformator.java
index 4e1fc46..0f59ffd 100644
--- a/src/org/fife/com/swabunga/spell/engine/GenericTransformator.java
+++ b/src/org/fife/com/swabunga/spell/engine/GenericTransformator.java
@@ -391,20 +391,20 @@ public String transform(String word) {
             if (matchCh == STARTMULTI || matchCh == ENDMULTI) {
                 inMulti = !inMulti;
                 if (!inMulti)
-                    matching = matching & multiMatch;
+                    matching &= multiMatch;
                 else
                     multiMatch = false;
             }
             else {
                 if (matchCh != word.charAt(wordPos)) {
                     if (inMulti)
-                        multiMatch = multiMatch | false;
+                        multiMatch |= false;
                     else
                         matching = false;
                 }
                 else {
                     if (inMulti)
-                        multiMatch = multiMatch | true;
+                        multiMatch |= true;
                     else
                         matching = true;
                 }
diff --git a/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java b/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
index 796fe92..a2602da 100644
--- a/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
+++ b/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
@@ -456,7 +456,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,

        int y = getY();
        if (aboveCaret) {
-           y = y + getHeight() - descWindow.getHeight();
+           y += getHeight() - descWindow.getHeight();
        }

        if (x!=descWindow.getX() || y!=descWindow.getY()) {
@@ -594,7 +594,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
            }
            break;
        default:
-           index = index - 1;
+           index -= 1;
            break;
        }
        list.setSelectedIndex(index);
diff --git a/src/org/fife/ui/rsyntaxtextarea/modes/JavaScriptTokenMaker.java b/src/org/fife/ui/rsyntaxtextarea/modes/JavaScriptTokenMaker.java
index 7ba391a..ebcb1ce 100644
--- a/src/org/fife/ui/rsyntaxtextarea/modes/JavaScriptTokenMaker.java
+++ b/src/org/fife/ui/rsyntaxtextarea/modes/JavaScriptTokenMaker.java
@@ -1819,7 +1819,7 @@ public class JavaScriptTokenMaker extends AbstractJFlexCTokenMaker {
                                            //System.out.println((start+operatorLen) + ", " + (zzMarkedPos-2));
                                            addToken(start+operatorLen,zzMarkedPos-2, Token.WHITESPACE);
                                        }
-                                       zzStartRead = zzCurrentPos = zzMarkedPos = zzMarkedPos - 1;
+                                       zzStartRead = zzCurrentPos = zzMarkedPos -= 1;
                                        if (isE4xSupported()) {
                                            // Scanning will continue with "<" as markup tag start
                                            yybegin(E4X, LANG_INDEX_E4X);
diff --git a/src/org/fife/ui/rsyntaxtextarea/modes/TypeScriptTokenMaker.java b/src/org/fife/ui/rsyntaxtextarea/modes/TypeScriptTokenMaker.java
index 3829ea9..8529e56 100644
--- a/src/org/fife/ui/rsyntaxtextarea/modes/TypeScriptTokenMaker.java
+++ b/src/org/fife/ui/rsyntaxtextarea/modes/TypeScriptTokenMaker.java
@@ -1742,7 +1742,7 @@ public class TypeScriptTokenMaker extends AbstractJFlexCTokenMaker {
                                            //System.out.println((start+operatorLen) + ", " + (zzMarkedPos-2));
                                            addToken(start+operatorLen,zzMarkedPos-2, Token.WHITESPACE);
                                        }
-                                       zzStartRead = zzCurrentPos = zzMarkedPos = zzMarkedPos - 1;
+                                       zzStartRead = zzCurrentPos = zzMarkedPos -= 1;
                                        if (isE4xSupported()) {
                                            // Scanning will continue with "<" as markup tag start
                                            yybegin(E4X, LANG_INDEX_E4X);
diff --git a/src/org/fife/ui/rtextarea/LineNumberList.java b/src/org/fife/ui/rtextarea/LineNumberList.java
index 1d6261a..655fbf5 100644
--- a/src/org/fife/ui/rtextarea/LineNumberList.java
+++ b/src/org/fife/ui/rtextarea/LineNumberList.java
@@ -656,7 +656,7 @@ public class LineNumberList extends AbstractGutterComponent
                int lineCount = textArea.getLineCount() +
                        getLineNumberingStartIndex() - 1;
                do {
-                   lineCount = lineCount/10;
+                   lineCount /= 10;
                    count++;
                } while (lineCount >= 10);
                cellWidth += fontMetrics.charWidth('9')*(count+1) + 3;
omegaui commented 2 years ago

Thanks! I updated them. It has been a long time since I checked those files. But as for the RSyntaxTextArea, you may address this thing to them.

elfring commented 2 years ago

Thanks for your source code adjustments.

elfring commented 2 years ago

Would you like to integrate any related change possibilities? :thinking: