Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Change line length to a more modern 120 #20169

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions eclipse/VaadinJavaConventions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
Expand Down Expand Up @@ -199,7 +199,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
/**
* Application configuration data.
* <p>
* This class is effectively immutable although setters exist to assign the
* values during construction.
* This class is effectively immutable although setters exist to assign the values during construction.
*
* @author Vaadin Ltd
* @since 1.0
Expand Down Expand Up @@ -127,10 +126,9 @@ public void setWebComponentMode(boolean mode) {
}

/**
* Gets the UI id of the server-side UI associated with this client-side
* instance. The UI id should be included in every request originating from
* this instance in order to associate the request with the right UI
* instance on the server.
* Gets the UI id of the server-side UI associated with this client-side instance. The UI id should be included in
* every request originating from this instance in order to associate the request with the right UI instance on the
* server.
*
* @return the UI id
*/
Expand All @@ -139,8 +137,7 @@ public int getUIId() {
}

/**
* Sets the UI id of the server-side UI associated with this client-side
* instance.
* Sets the UI id of the server-side UI associated with this client-side instance.
*
* @param uiId
* the UI id
Expand All @@ -152,8 +149,7 @@ public void setUIId(int uiId) {
/**
* Gets the interval for heartbeat requests.
*
* @return The interval in seconds between heartbeat requests, or -1 if
* heartbeat is disabled.
* @return The interval in seconds between heartbeat requests, or -1 if heartbeat is disabled.
*/
public int getHeartbeatInterval() {
return heartbeatInterval;
Expand All @@ -163,8 +159,7 @@ public int getHeartbeatInterval() {
* Sets the interval for heartbeat requests.
*
* @param heartbeatInterval
* The interval in seconds between heartbeat requests, or -1 if
* heartbeat is disabled.
* The interval in seconds between heartbeat requests, or -1 if heartbeat is disabled.
*/
public void setHeartbeatInterval(int heartbeatInterval) {
this.heartbeatInterval = heartbeatInterval;
Expand All @@ -173,8 +168,8 @@ public void setHeartbeatInterval(int heartbeatInterval) {
/**
* Gets the maximum message suspension delay.
*
* @return The maximum time, in milliseconds, to suspend out-of-order
* messages waiting for their predecessor before resynchronizing.
* @return The maximum time, in milliseconds, to suspend out-of-order messages waiting for their predecessor before
* resynchronizing.
*/
public int getMaxMessageSuspendTimeout() {
return maxMessageSuspendTimeout;
Expand All @@ -184,8 +179,8 @@ public int getMaxMessageSuspendTimeout() {
* Sets the maximum message suspension delay.
*
* @param maxMessageSuspendTimeout
* The maximum time, in milliseconds, to suspend out-of-order
* messages waiting for their predecessor before resynchronizing.
* The maximum time, in milliseconds, to suspend out-of-order messages waiting for their predecessor
* before resynchronizing.
*/
public void setMaxMessageSuspendTimeout(int maxMessageSuspendTimeout) {
this.maxMessageSuspendTimeout = maxMessageSuspendTimeout;
Expand Down Expand Up @@ -270,13 +265,11 @@ public void setAtmosphereJSVersion(String atmosphereJSVersion) {
/**
* Checks if we are running in production mode.
* <p>
* With production mode disabled, a lot more information is logged to the
* browser console. In production you should always enable production mode,
* because logging and other debug features can have a significant
* performance impact.
* With production mode disabled, a lot more information is logged to the browser console. In production you should
* always enable production mode, because logging and other debug features can have a significant performance
* impact.
*
* @return {@code true} if production mode is enabled, {@code false}
* otherwise
* @return {@code true} if production mode is enabled, {@code false} otherwise
*/
public boolean isProductionMode() {
return productionMode;
Expand All @@ -285,8 +278,7 @@ public boolean isProductionMode() {
/**
* Checks if request timing info should be made available.
*
* @return {@code true} if request timing info should be made availble,
* {@code false} otherwise
* @return {@code true} if request timing info should be made availble, {@code false} otherwise
*/
public boolean isRequestTiming() {
return requestTiming;
Expand All @@ -295,14 +287,12 @@ public boolean isRequestTiming() {
/**
* Sets whether we are running in production mode.
* <p>
* With production mode disabled, a lot more information is logged to the
* browser console. In production you should always enable production mode,
* because logging and other debug features can have a significant
* performance impact.
* With production mode disabled, a lot more information is logged to the browser console. In production you should
* always enable production mode, because logging and other debug features can have a significant performance
* impact.
*
* @param productionMode
* {@code true} if production mode is enabled, {@code false}
* otherwise
* {@code true} if production mode is enabled, {@code false} otherwise
*/
public void setProductionMode(boolean productionMode) {
this.productionMode = productionMode;
Expand All @@ -313,8 +303,7 @@ public void setProductionMode(boolean productionMode) {
* Sets whether request timing info should be made available.
*
* @param requestTiming
* {@code true} if request timing info should be made available,
* {@code false} otherwise
* {@code true} if request timing info should be made available, {@code false} otherwise
*/
public void setRequestTiming(boolean requestTiming) {
this.requestTiming = requestTiming;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ public class ApplicationConnection {
* @param applicationConfiguration
* the configuration object for the application
*/
public ApplicationConnection(
ApplicationConfiguration applicationConfiguration) {
public ApplicationConnection(ApplicationConfiguration applicationConfiguration) {

registry = new DefaultRegistry(this, applicationConfiguration);
GWT.setUncaughtExceptionHandler(
registry.getSystemErrorHandler()::handleError);
GWT.setUncaughtExceptionHandler(registry.getSystemErrorHandler()::handleError);

StateNode rootNode = registry.getStateTree().getRootNode();

Expand All @@ -71,25 +69,20 @@ public ApplicationConnection(
rootNode.setDomNode(body);
Binder.bind(rootNode, body);

Console.log("Starting application "
+ applicationConfiguration.getApplicationId());
Console.log("Starting application " + applicationConfiguration.getApplicationId());

String appRootPanelName = applicationConfiguration.getApplicationId();
// remove the end (window name) of autogenerated rootpanel id
appRootPanelName = appRootPanelName.replaceFirst("-\\d+$", "");

boolean productionMode = applicationConfiguration.isProductionMode();
boolean requestTiming = applicationConfiguration.isRequestTiming();
publishJavascriptMethods(appRootPanelName, productionMode,
requestTiming,
publishJavascriptMethods(appRootPanelName, productionMode, requestTiming,
applicationConfiguration.getExportedWebComponents());
if (!productionMode) {
String servletVersion = applicationConfiguration
.getServletVersion();
publishDevelopmentModeJavascriptMethods(appRootPanelName,
servletVersion);
Console.log(
"Vaadin application servlet version: " + servletVersion);
String servletVersion = applicationConfiguration.getServletVersion();
publishDevelopmentModeJavascriptMethods(appRootPanelName, servletVersion);
Console.log("Vaadin application servlet version: " + servletVersion);
}

ConnectionIndicator.setState(ConnectionIndicator.LOADING);
Expand All @@ -98,8 +91,7 @@ public ApplicationConnection(
/**
* Starts this application.
* <p>
* Called by the bootstrapper, which ensures applications are started in
* order.
* Called by the bootstrapper, which ensures applications are started in order.
*
* @param initialUidl
* the initial UIDL or null if the server did not provide any
Expand Down Expand Up @@ -139,8 +131,7 @@ public void start(ValueMap initialUidl) {
*/
private boolean isActive() {
return !registry.getMessageHandler().isInitialUidlHandled()
|| registry.getRequestResponseTracker().hasActiveRequest()
|| isExecutingDeferredCommands();
|| registry.getRequestResponseTracker().hasActiveRequest() || isExecutingDeferredCommands();
}

/**
Expand All @@ -149,16 +140,13 @@ private boolean isActive() {
* @param applicationId
* the application id provided by the server
* @param productionMode
* <code>true</code> if running in production mode,
* <code>false</code> otherwise
* <code>true</code> if running in production mode, <code>false</code> otherwise
* @param requestTiming
* <code>true</code> if request timing info should be made
* available, <code>false</code> otherwise
* <code>true</code> if request timing info should be made available, <code>false</code> otherwise
* @param exportedWebComponents
* a list of web component tags exported by this UI
*/
private native void publishJavascriptMethods(String applicationId,
boolean productionMode, boolean requestTiming,
private native void publishJavascriptMethods(String applicationId, boolean productionMode, boolean requestTiming,
String[] exportedWebComponents)
/*-{
var ap = this;
Expand Down Expand Up @@ -231,9 +219,7 @@ private Node getDomElementByNodeId(int id) {
private String getJavaClass(int id) {
StateNode node = registry.getStateTree().getNode(id);
return node == null ? null
: node.getMap(NodeFeatures.ELEMENT_DATA)
.getProperty(NodeProperties.JAVA_CLASS)
.getValueOrDefault(null);
: node.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.JAVA_CLASS).getValueOrDefault(null);
}

public static final class Styles extends JavaScriptObject {
Expand All @@ -250,31 +236,25 @@ private JavaScriptObject getElementStyleProperties(int id) {
StateNode node = registry.getStateTree().getNode(id);
Styles styles = JavaScriptObject.createObject().cast();
if (node != null) {
JsArray<String> names = node
.getMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES)
.getPropertyNames();
JsArray<String> names = node.getMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES).getPropertyNames();
for (int i = 0; i < names.length(); i++) {
String name = names.get(i);
styles.set(name,
node.getMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES)
.getProperty(name).getValue());
styles.set(name, node.getMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES).getProperty(name).getValue());

}
}
return styles;
}

private int getNodeId(Element element) {
StateNode node = registry.getStateTree()
.getStateNodeForDomNode(DomApi.wrap(element));
StateNode node = registry.getStateTree().getStateNodeForDomNode(DomApi.wrap(element));
return node == null ? -1 : node.getId();
}

private void addDomSetListener(int nodeId, JavaScriptObject callback) {
registry.getStateTree().getNode(nodeId).addDomNodeSetListener(node -> {
if (nodeId == node.getId()) {
NativeFunction function = NativeFunction.create("callback",
"callback();");
NativeFunction function = NativeFunction.create("callback", "callback();");
function.call(null, callback);
return true;
}
Expand All @@ -288,8 +268,7 @@ private void addDomSetListener(int nodeId, JavaScriptObject callback) {
* @param applicationId
* the application id provided by the server
*/
private native void publishDevelopmentModeJavascriptMethods(
String applicationId, String servletVersion)
private native void publishDevelopmentModeJavascriptMethods(String applicationId, String servletVersion)
/*-{
var ap = this;
var client = $wnd.Vaadin.Flow.clients[applicationId];
Expand All @@ -314,16 +293,14 @@ private native void publishDevelopmentModeJavascriptMethods(
}-*/;

/**
* Checks if deferred commands are (potentially) still being executed as a
* result of an update from the server. Returns true if a deferred command
* might still be executing, false otherwise. This will not work correctly
* if a deferred command is added in another deferred command.
* Checks if deferred commands are (potentially) still being executed as a result of an update from the server.
* Returns true if a deferred command might still be executing, false otherwise. This will not work correctly if a
* deferred command is added in another deferred command.
* <p>
* Used by the native "client.isActive" function.
* </p>
*
* @return true if deferred commands are (potentially) being executed, false
* otherwise
* @return true if deferred commands are (potentially) being executed, false otherwise
*/
private boolean isExecutingDeferredCommands() {
Scheduler s = Scheduler.get();
Expand Down
29 changes: 11 additions & 18 deletions flow-client/src/main/java/com/vaadin/client/BrowserInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
/**
* Provides a way to query information about web browser.
*
* Browser details are detected only once and those are stored in this singleton
* class.
* Browser details are detected only once and those are stored in this singleton class.
*
* @since 1.0
*/
Expand Down Expand Up @@ -131,8 +130,7 @@ public boolean isSafari() {
}

/**
* Checks if the browser is Safari or runs on IOS (covering also Chrome on
* iOS).
* Checks if the browser is Safari or runs on IOS (covering also Chrome on iOS).
*
* @return true if the browser is Safari or running on IOS, false otherwise
*/
Expand Down Expand Up @@ -168,8 +166,8 @@ public boolean isWebkit() {
}

/**
* Returns the Gecko version if the browser is Gecko based. The Gecko
* version for Firefox 2 is 1.8 and 1.9 for Firefox 3.
* Returns the Gecko version if the browser is Gecko based. The Gecko version for Firefox 2 is 1.8 and 1.9 for
* Firefox 3.
*
* @return The Gecko version or -1 if the browser is not Gecko based
*/
Expand All @@ -182,8 +180,8 @@ public float getGeckoVersion() {
}

/**
* Returns the WebKit version if the browser is WebKit based. The WebKit
* version returned is the major version e.g., 523.
* Returns the WebKit version if the browser is WebKit based. The WebKit version returned is the major version e.g.,
* 523.
*
* @return The WebKit version or -1 if the browser is not WebKit based
*/
Expand Down Expand Up @@ -234,27 +232,22 @@ public boolean isAndroid() {
}

/**
* Tests if this is an Android devices with a broken scrollTop
* implementation.
* Tests if this is an Android devices with a broken scrollTop implementation.
*
* @return true if scrollTop cannot be trusted on this device, false
* otherwise
* @return true if scrollTop cannot be trusted on this device, false otherwise
*/
public boolean isAndroidWithBrokenScrollTop() {
return isAndroid() && (getOperatingSystemMajorVersion() == 3
|| getOperatingSystemMajorVersion() == 4);
return isAndroid() && (getOperatingSystemMajorVersion() == 3 || getOperatingSystemMajorVersion() == 4);
}

private int getOperatingSystemMajorVersion() {
return browserDetails.getOperatingSystemMajorVersion();
}

/**
* Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome
* 4, 8 for Internet Explorer 8.
* Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome 4, 8 for Internet Explorer 8.
* <p>
* Note that Internet Explorer 8 and newer will return the document mode so
* IE8 rendering as IE7 will return 7.
* Note that Internet Explorer 8 and newer will return the document mode so IE8 rendering as IE7 will return 7.
* </p>
*
* @return The major version of the browser.
Expand Down
Loading
Loading