From 0e4ff9fae6a3f6ab82793d2ae18b73da8480dc99 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Mon, 27 May 2019 15:14:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8C=85=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eclipse/jgit/gitrepo/internal/RepoText.properties | 0 .../eclipse/jgit/internal/JGitText.properties | 0 .../eclipse/jgit/internal/storage/dfs/DfsText.properties | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename fine-jgit/resources/{org => com.fr.third}/eclipse/jgit/gitrepo/internal/RepoText.properties (100%) rename fine-jgit/resources/{org => com.fr.third}/eclipse/jgit/internal/JGitText.properties (100%) rename fine-jgit/resources/{org => com.fr.third}/eclipse/jgit/internal/storage/dfs/DfsText.properties (100%) diff --git a/fine-jgit/resources/org/eclipse/jgit/gitrepo/internal/RepoText.properties b/fine-jgit/resources/com.fr.third/eclipse/jgit/gitrepo/internal/RepoText.properties similarity index 100% rename from fine-jgit/resources/org/eclipse/jgit/gitrepo/internal/RepoText.properties rename to fine-jgit/resources/com.fr.third/eclipse/jgit/gitrepo/internal/RepoText.properties diff --git a/fine-jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/fine-jgit/resources/com.fr.third/eclipse/jgit/internal/JGitText.properties similarity index 100% rename from fine-jgit/resources/org/eclipse/jgit/internal/JGitText.properties rename to fine-jgit/resources/com.fr.third/eclipse/jgit/internal/JGitText.properties diff --git a/fine-jgit/resources/org/eclipse/jgit/internal/storage/dfs/DfsText.properties b/fine-jgit/resources/com.fr.third/eclipse/jgit/internal/storage/dfs/DfsText.properties similarity index 100% rename from fine-jgit/resources/org/eclipse/jgit/internal/storage/dfs/DfsText.properties rename to fine-jgit/resources/com.fr.third/eclipse/jgit/internal/storage/dfs/DfsText.properties From c878b16ffc0e79e734f28c0bb5e637070f924f28 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Mon, 27 May 2019 17:21:17 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8C=85=E5=90=8D=20resource=E4=B8=8B=E9=9D=A2?= =?UTF-8?q?=E7=94=A8=E4=BA=86refactor->=20rename=20=E4=BB=A5=E4=B8=BA?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5=E6=94=B9=E5=8C=85=E5=90=8D?= =?UTF-8?q?=20=E6=88=91=E7=9A=84=E9=94=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/third}/eclipse/jgit/gitrepo/internal/RepoText.properties | 0 .../fr/third}/eclipse/jgit/internal/JGitText.properties | 0 .../third}/eclipse/jgit/internal/storage/dfs/DfsText.properties | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename fine-jgit/resources/{com.fr.third => com/fr/third}/eclipse/jgit/gitrepo/internal/RepoText.properties (100%) rename fine-jgit/resources/{com.fr.third => com/fr/third}/eclipse/jgit/internal/JGitText.properties (100%) rename fine-jgit/resources/{com.fr.third => com/fr/third}/eclipse/jgit/internal/storage/dfs/DfsText.properties (100%) diff --git a/fine-jgit/resources/com.fr.third/eclipse/jgit/gitrepo/internal/RepoText.properties b/fine-jgit/resources/com/fr/third/eclipse/jgit/gitrepo/internal/RepoText.properties similarity index 100% rename from fine-jgit/resources/com.fr.third/eclipse/jgit/gitrepo/internal/RepoText.properties rename to fine-jgit/resources/com/fr/third/eclipse/jgit/gitrepo/internal/RepoText.properties diff --git a/fine-jgit/resources/com.fr.third/eclipse/jgit/internal/JGitText.properties b/fine-jgit/resources/com/fr/third/eclipse/jgit/internal/JGitText.properties similarity index 100% rename from fine-jgit/resources/com.fr.third/eclipse/jgit/internal/JGitText.properties rename to fine-jgit/resources/com/fr/third/eclipse/jgit/internal/JGitText.properties diff --git a/fine-jgit/resources/com.fr.third/eclipse/jgit/internal/storage/dfs/DfsText.properties b/fine-jgit/resources/com/fr/third/eclipse/jgit/internal/storage/dfs/DfsText.properties similarity index 100% rename from fine-jgit/resources/com.fr.third/eclipse/jgit/internal/storage/dfs/DfsText.properties rename to fine-jgit/resources/com/fr/third/eclipse/jgit/internal/storage/dfs/DfsText.properties From 71fb10f7656527d33677d1e4ca239f632e551692 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 30 May 2019 09:44:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-17530=20=E3=80=90CRM10.0=E3=80=91201?= =?UTF-8?q?90527=E5=AE=95=E6=9C=BA=E9=A3=8E=E9=99=A9=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9A12w=E6=9D=A1clientnode=20=E5=A4=9A=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E4=B8=8B,=20clientbox=20=E6=97=A0=E6=B3=95=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E6=95=88=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/third/socketio/handler/ClientHead.java | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/fine-socketio/src/com/fr/third/socketio/handler/ClientHead.java b/fine-socketio/src/com/fr/third/socketio/handler/ClientHead.java index b1fb85350..f0afabcb1 100644 --- a/fine-socketio/src/com/fr/third/socketio/handler/ClientHead.java +++ b/fine-socketio/src/com/fr/third/socketio/handler/ClientHead.java @@ -86,13 +86,28 @@ public class ClientHead { channels.put(Transport.WEBSOCKET, new TransportState()); } - public void bindChannel(Channel channel, Transport transport) { + + /** + * 这里多线程下,会有问题, + * 因为 channel 不会变, 但是 state 可能因为多线程下调用 bindChannel + * 从而导致 state.update , 致使真正 add() 时, + * channel 和 state 得数据不一致。 + * + * 解决方法 + * 1. 加锁 + * 2. 为 clientbox 加一个子线程, 定时清除 disconnected 为 true 的值。 + * + * @param channel 频道 + * @param transport 协议 + */ + public synchronized void bindChannel(Channel channel, Transport transport) { log.debug("binding channel: {} to transport: {}", channel, transport); TransportState state = channels.get(transport); Channel prevChannel = state.update(channel); if (prevChannel != null) { clientsBox.remove(prevChannel); + prevChannel.disconnect(); } clientsBox.add(channel, this); @@ -122,16 +137,7 @@ public class ClientHead { public void schedulePingTimeout() { SchedulerKey key = new SchedulerKey(Type.PING_TIMEOUT, sessionId); - disconnectScheduler.schedule(key, new Runnable() { - @Override - public void run() { - ClientHead client = clientsBox.get(sessionId); - if (client != null) { - client.disconnect(); - log.debug("{} removed due to ping timeout", sessionId); - } - } - }, configuration.getPingTimeout() + configuration.getPingInterval(), TimeUnit.MILLISECONDS); + disconnectScheduler.schedule(key, new TimeOutTask(this), configuration.getPingTimeout() + configuration.getPingInterval(), TimeUnit.MILLISECONDS); } public ChannelFuture send(Packet packet, Transport transport) { @@ -152,6 +158,8 @@ public class ClientHead { public void removeNamespaceClient(NamespaceClient client) { namespaceClients.remove(client.getNamespace()); + + // 清空到最后一个的时候, 断开连接。 调用 initializer.disconnect if (namespaceClients.isEmpty()) { disconnectableHub.onDisconnect(this); } @@ -268,4 +276,23 @@ public class ClientHead { return lastBinaryPacket; } + private class TimeOutTask implements Runnable{ + + ClientHead client; + + public TimeOutTask(ClientHead client) { + + assert client != null; + this.client = client; + } + + @Override + public void run() { + + if (client != null && !client.disconnected.get()) { + client.disconnect(); + log.debug("{} removed due to ping timeout", client.getSessionId()); + } + } + } } From 6dcadd7fb9b357aab135c4c6bc570730135958c5 Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 5 Jun 2019 15:28:37 +0800 Subject: [PATCH 4/4] =?UTF-8?q?JB=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.third_step1.gradle | 2 + fine-jetbrains/readme.md | 3 + .../src/org/jetbrains/annotations/Async.java | 33 +++++++ .../org/jetbrains/annotations/Contract.java | 93 +++++++++++++++++++ .../src/org/jetbrains/annotations/Nls.java | 48 ++++++++++ .../src/org/jetbrains/annotations/NonNls.java | 56 +++++++++++ .../org/jetbrains/annotations/NotNull.java | 46 +++++++++ .../org/jetbrains/annotations/Nullable.java | 44 +++++++++ .../jetbrains/annotations/PropertyKey.java | 41 ++++++++ .../org/jetbrains/annotations/TestOnly.java | 29 ++++++ 10 files changed, 395 insertions(+) create mode 100644 fine-jetbrains/readme.md create mode 100644 fine-jetbrains/src/org/jetbrains/annotations/Async.java create mode 100644 fine-jetbrains/src/org/jetbrains/annotations/Contract.java create mode 100644 fine-jetbrains/src/org/jetbrains/annotations/Nls.java create mode 100644 fine-jetbrains/src/org/jetbrains/annotations/NonNls.java create mode 100644 fine-jetbrains/src/org/jetbrains/annotations/NotNull.java create mode 100644 fine-jetbrains/src/org/jetbrains/annotations/Nullable.java create mode 100644 fine-jetbrains/src/org/jetbrains/annotations/PropertyKey.java create mode 100644 fine-jetbrains/src/org/jetbrains/annotations/TestOnly.java diff --git a/build.third_step1.gradle b/build.third_step1.gradle index e84c6bc8a..1b2354d62 100644 --- a/build.third_step1.gradle +++ b/build.third_step1.gradle @@ -28,6 +28,7 @@ sourceSets{ main{ java{ srcDirs=[ + "${srcDir}/fine-jetbrains/src", "${srcDir}/fine-poi/src", "${srcDir}/fine-quartz/src", "${srcDir}/fine-commons-io/src", @@ -79,6 +80,7 @@ def dataContent ={def dir -> task copyFiles(type:Copy,dependsOn:'compileJava'){ copy{ println "------------------------------------------------copyfiles" + with dataContent.call("${srcDir}/fine-jetbrains/src") with dataContent.call("${srcDir}/fine-poi/src") with dataContent.call("${srcDir}/fine-quartz/src") with dataContent.call("${srcDir}/fine-commons-io/src") diff --git a/fine-jetbrains/readme.md b/fine-jetbrains/readme.md new file mode 100644 index 000000000..867886b34 --- /dev/null +++ b/fine-jetbrains/readme.md @@ -0,0 +1,3 @@ +# jetbrains annotations + +作为注解事实上的标准,不能更改包名,半身也不存在什么冲突,直接放进来 \ No newline at end of file diff --git a/fine-jetbrains/src/org/jetbrains/annotations/Async.java b/fine-jetbrains/src/org/jetbrains/annotations/Async.java new file mode 100644 index 000000000..ee2c5a282 --- /dev/null +++ b/fine-jetbrains/src/org/jetbrains/annotations/Async.java @@ -0,0 +1,33 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package org.jetbrains.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Helper annotations for asynchronous computation. + * Used for example in IDEA debugger for async stacktraces feature. + * + * @author egor + */ +public interface Async { + + /** + * Indicates that the marked method schedules async computation. + * Scheduled object is either {@code this}, or the annotated parameter value. + */ + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) + @interface Schedule {} + + /** + * Indicates that the marked method executes async computation. + * Executed object is either {@code this}, or the annotated parameter value. + * This object needs to match with the one annotated with {@link Schedule} + */ + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) + @interface Execute {} +} diff --git a/fine-jetbrains/src/org/jetbrains/annotations/Contract.java b/fine-jetbrains/src/org/jetbrains/annotations/Contract.java new file mode 100644 index 000000000..cbaf6d1d5 --- /dev/null +++ b/fine-jetbrains/src/org/jetbrains/annotations/Contract.java @@ -0,0 +1,93 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.annotations; + +import java.lang.annotation.*; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * Specifies some aspects of the method behavior depending on the arguments. Can be used by tools for advanced data flow analysis. + * Note that this annotation just describes how the code works and doesn't add any functionality by means of code generation.

+ * + * Method contract has the following syntax:
+ * contract ::= (clause ';')* clause
+ * clause ::= args '->' effect
+ * args ::= ((arg ',')* arg )?
+ * arg ::= value-constraint
+ * value-constraint ::= '_' | 'null' | '!null' | 'false' | 'true'
+ * effect ::= value-constraint | 'fail'

+ * + * The constraints denote the following:
+ *

    + *
  • _ - any value + *
  • null - null value + *
  • !null - a value statically proved to be not-null + *
  • true - true boolean value + *
  • false - false boolean value + *
  • fail - the method throws an exception, if the arguments satisfy argument constraints + *
+ * Examples:

+ * {@code @Contract("_, null -> null")} - method returns null if its second argument is null
+ * {@code @Contract("_, null -> null; _, !null -> !null")} - method returns null if its second argument is null and not-null otherwise
+ * {@code @Contract("true -> fail")} - a typical assertFalse method which throws an exception if {@code true} is passed to it
+ * + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface Contract { + /** + * Contains the contract clauses describing causal relations between call arguments and the returned value + */ + String value() default ""; + + /** + * Specifies that the annotated method has no visible side effects. + * If its return value is not used, removing its invocation won't + * affect program state and change the semantics, unless method call throws an exception. + * Exception throwing is not considered to be a side effect. + *

+ * Method should not be marked as pure if it does not produce a side-effect by itself, + * but it could be used to establish a happens-before relation between an event in + * another thread, so changes performed in another thread might become visible in current thread + * after this method invocation. Examples of such methods are {@link Object#wait()}, {@link Thread#join()} + * or {@link AtomicBoolean#get()}. On the other hand, some synchronized methods like {@link java.util.Vector#get(int)} + * could be marked as pure, because the purpose of synchronization here is to keep the collection internal integrity + * rather than to wait for an event in another thread. + *

+ * "Invisible" side effects (such as logging) that don't affect the "important" program semantics are allowed.

+ *

+ * This annotation may be used for more precise data flow analysis, and + * to check that the method's return value is actually used in the call place. + */ + boolean pure() default false; + + /** + * Contains a specifier which describes which method parameters can be mutated during the method call. + *

+ * The following values are possible: + * + * + * + * + * + *
"this"Method mutates the receiver object, and doesn't mutates any objects passed as arguments (cannot be applied for static method or constructor)
"arg"Method mutates the sole argument and doesn't mutate the receiver object (if applicable)
"arg1", "arg2", ...Method mutates the N-th argument
"this,arg1"Method mutates the receiver and first argument and doesn't mutate any other arguments
+ * + * @return a mutation specifier string + * Warning: This annotation parameter is experimental and may be changed or removed without further notice! + */ + String mutates() default ""; +} diff --git a/fine-jetbrains/src/org/jetbrains/annotations/Nls.java b/fine-jetbrains/src/org/jetbrains/annotations/Nls.java new file mode 100644 index 000000000..85807d693 --- /dev/null +++ b/fine-jetbrains/src/org/jetbrains/annotations/Nls.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.annotations; + +import java.lang.annotation.*; + +/** + * Specifies that an element of the program is an user-visible string which needs to be localized. + * This annotation is intended to be used by localization tools for + * detecting strings which should be reported as requiring localization. + * + * @author mike + * @see NonNls + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE, ElementType.PACKAGE}) +public @interface Nls { + + enum Capitalization { + + NotSpecified, + /** + * e.g. This Is a Title + */ + Title, + /** + * e.g. This is a sentence + */ + Sentence + } + + Capitalization capitalization() default Capitalization.NotSpecified; +} diff --git a/fine-jetbrains/src/org/jetbrains/annotations/NonNls.java b/fine-jetbrains/src/org/jetbrains/annotations/NonNls.java new file mode 100644 index 000000000..790ea76da --- /dev/null +++ b/fine-jetbrains/src/org/jetbrains/annotations/NonNls.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.annotations; + +import java.lang.annotation.*; + +/** + * Specifies that an element of the program is not an user-visible string which needs to be localized, + * or does not contain such strings. This annotation is intended to be used by localization tools for + * detecting strings which should not be reported as requiring localization. + *

    + *
  • If a method parameter is annotated with {@code NonNls}, the strings passed + * as values of this parameter are not reported as requiring localization. + * Also, if the parameter of a property setter method is annotated with {@code NonNls}, values + * of that property in UI Designer forms are never highlighted as hard-coded strings.
  • + *
  • If a field is annotated with {@code NonNls}, all string literals found in the + * initializer of the field are not reported as requiring localization.
  • + *
  • If a method is called on a field, parameter or local variable annotated with {@code NonNls}, + * string literals passed as parameters to the method are not reported as requiring localization. + *
  • If a field, parameter or local variable annotated with {@code NonNls} is passed as a + * parameter to the {@code equals()} method invoked on a string literal, the literal is not + * reported as requiring localization.
  • + *
  • If a field, parameter or local variable annotated with {@code NonNls} is found at + * the left side of an assignment expression, all string literals in the right side + * of the expression are not reported as requiring localization.
  • + *
  • If a method is annotated with {@code NonNls}, string literals returned from the method + * are not reported as requiring localization.
  • + *
  • If a class is annotated with {@code NonNls}, all string literals in + * the class and all its subclasses are not reported as requiring localization.
  • + *
  • If a package is annotated with {@code NonNls}, all string literals in + * the package and all its subpackages are not reported as requiring localization.
  • + *
+ * + * @author max + * @see Nls + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE, ElementType.PACKAGE}) +public @interface NonNls { + +} diff --git a/fine-jetbrains/src/org/jetbrains/annotations/NotNull.java b/fine-jetbrains/src/org/jetbrains/annotations/NotNull.java new file mode 100644 index 000000000..81d5f86cb --- /dev/null +++ b/fine-jetbrains/src/org/jetbrains/annotations/NotNull.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.annotations; + +import java.lang.annotation.*; + +/** + * An element annotated with NotNull claims {@code null} value is forbidden + * to return (for methods), pass to (parameters) and hold (local variables and fields). + * Apart from documentation purposes this annotation is intended to be used by static analysis tools + * to validate against probable runtime errors and element contract violations. + * + * @author max + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE}) +public @interface NotNull { + /** + * @return Custom exception message + */ + String value() default ""; + + /** + * @return Custom exception type that should be thrown when not-nullity contract is violated. + * The exception class should have a constructor with one String argument (message). + * + * By default, {@link IllegalArgumentException} is thrown on null method arguments and + * {@link IllegalStateException} — on null return value. + */ + Class exception() default Exception.class; +} diff --git a/fine-jetbrains/src/org/jetbrains/annotations/Nullable.java b/fine-jetbrains/src/org/jetbrains/annotations/Nullable.java new file mode 100644 index 000000000..39e312306 --- /dev/null +++ b/fine-jetbrains/src/org/jetbrains/annotations/Nullable.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.annotations; + +import java.lang.annotation.*; + +/** + * An element annotated with {@link Nullable} claims {@code null} value is perfectly valid + * to return (for methods), pass to (parameters) or hold in (local variables and fields). + * Apart from documentation purposes this annotation is intended to be used by static analysis tools + * to validate against probable runtime errors or element contract violations. + *
+ * By convention, this annotation applied only when the value should always be checked against {@code null} + * because the developer could do nothing to prevent null from happening. + * Otherwise, too eager {@link Nullable} usage could lead to too many false positives from static analysis tools. + *
+ * For example, {@link java.util.Map#get(Object key)} should not be annotated {@link Nullable} because + * someone may have put not-null value in the map by this key and is expecting to find this value there ever since. + *
+ * On the other hand, the {@link java.lang.ref.Reference#get()} should be annotated {@link Nullable} because + * it returns {@code null} if object got collected which can happen at any time completely unexpectedly. + * + * @author max + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE}) +public @interface Nullable { + String value() default ""; +} diff --git a/fine-jetbrains/src/org/jetbrains/annotations/PropertyKey.java b/fine-jetbrains/src/org/jetbrains/annotations/PropertyKey.java new file mode 100644 index 000000000..1aeca8a7a --- /dev/null +++ b/fine-jetbrains/src/org/jetbrains/annotations/PropertyKey.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.annotations; + +import java.lang.annotation.*; + +/** + * Specifies that a method parameter accepts arguments which must be valid property + * keys in a specific resource bundle. When a string literal which is not a property + * key in the specified bundle is passed as a parameter, IntelliJ IDEA highlights + * it as an error. The annotation is also used to provide completion in string literals + * passed as parameters. + * + * @author max + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.FIELD}) +public @interface PropertyKey { + /** + * The full-qualified name of the resource bundle in which the property keys must + * be present. Consists of a full-qualified name of the package corresponding to the + * directory where the resource bundle is located and the base name of the resource + * bundle (with no locale specifier or extension), separated with a dot. + */ + String resourceBundle(); +} diff --git a/fine-jetbrains/src/org/jetbrains/annotations/TestOnly.java b/fine-jetbrains/src/org/jetbrains/annotations/TestOnly.java new file mode 100644 index 000000000..8ecfb73f1 --- /dev/null +++ b/fine-jetbrains/src/org/jetbrains/annotations/TestOnly.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.annotations; + +import java.lang.annotation.*; + +/** + * A method/constructor annotated with TestOnly claims that it should be called from testing code only. + *

+ * Apart from documentation purposes this annotation is intended to be used by static analysis tools + * to validate against element contract violations. + */ +@Documented +@Retention(RetentionPolicy.SOURCE) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.TYPE}) +public @interface TestOnly { } \ No newline at end of file