diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index 1ea2de317799..84a00913a4c0 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -553,7 +553,7 @@ public class CompileDriver { } @Override - public void handleFailure(CmdlineRemoteProto.Message.Failure failure) { + public void handleFailure(UUID sessionId, CmdlineRemoteProto.Message.Failure failure) { compileContext.addMessage(CompilerMessageCategory.ERROR, failure.getDescription(), null, -1, -1); final String trace = failure.getStacktrace(); if (trace != null) { diff --git a/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java b/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java index 7cec2a50c8a5..deae76ab5d3f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java +++ b/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java @@ -279,7 +279,8 @@ public class ChangedConstantsDependencyProcessor { } */ - private PsiField getOwnerField(PsiElement element) { + @Nullable + private static PsiField getOwnerField(PsiElement element) { while (!(element instanceof PsiFile)) { if (element instanceof PsiClass) { break; @@ -292,6 +293,7 @@ public class ChangedConstantsDependencyProcessor { return null; } + @Nullable private FieldChangeInfo findChangeInfo(PsiField field) throws CacheCorruptedException { String name = field.getName(); for (final FieldChangeInfo changeInfo : myChangedFields) { diff --git a/java/compiler/impl/src/com/intellij/compiler/server/AutoMakeMessageHandler.java b/java/compiler/impl/src/com/intellij/compiler/server/AutoMakeMessageHandler.java index 4c720c003e03..e518d2135d46 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/AutoMakeMessageHandler.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/AutoMakeMessageHandler.java @@ -29,6 +29,7 @@ import com.intellij.problems.WolfTheProblemSolver; import org.jetbrains.jps.api.CmdlineRemoteProto; import java.util.Collections; +import java.util.UUID; /** * @author Eugene Zhuravlev @@ -83,7 +84,7 @@ class AutoMakeMessageHandler extends DefaultMessageHandler { } @Override - public void handleFailure(CmdlineRemoteProto.Message.Failure failure) { + public void handleFailure(UUID sessionId, CmdlineRemoteProto.Message.Failure failure) { CompilerManager.NOTIFICATION_GROUP.createNotification("Auto make failure: " + failure.getDescription(), MessageType.INFO); } diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index b49b88efc5c4..bb3f64f0720c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -369,7 +369,7 @@ public class BuildManager implements ApplicationComponent{ } catch (Exception e) { myMessageDispatcher.unregisterBuildMessageHandler(sessionId); - handler.handleFailure(CmdlineProtoUtil.createFailure(e.getMessage(), null)); + handler.handleFailure(sessionId, CmdlineProtoUtil.createFailure(e.getMessage(), null)); handler.sessionTerminated(); return null; } @@ -421,7 +421,7 @@ public class BuildManager implements ApplicationComponent{ } catch (ExecutionException e) { myMessageDispatcher.unregisterBuildMessageHandler(sessionId); - future.getMessageHandler().handleFailure(CmdlineProtoUtil.createFailure(e.getMessage(), e)); + future.getMessageHandler().handleFailure(sessionId, CmdlineProtoUtil.createFailure(e.getMessage(), e)); future.getMessageHandler().sessionTerminated(); } finally { diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java index 789948adbf75..bfe63f9f644f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java @@ -107,7 +107,7 @@ class BuildMessageDispatcher extends SimpleChannelHandler { final CmdlineRemoteProto.Message.Type messageType = message.getType(); switch (messageType) { case FAILURE: - handler.handleFailure(message.getFailure()); + handler.handleFailure(sessionId, message.getFailure()); break; case BUILDER_MESSAGE: @@ -124,7 +124,7 @@ class BuildMessageDispatcher extends SimpleChannelHandler { } } else { - handler.handleBuildMessage(builderMessage); + handler.handleBuildMessage(ctx.getChannel(), sessionId, builderMessage); } break; diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuilderMessageHandler.java b/java/compiler/impl/src/com/intellij/compiler/server/BuilderMessageHandler.java index b05396036520..bb304e07002b 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuilderMessageHandler.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuilderMessageHandler.java @@ -15,16 +15,19 @@ */ package com.intellij.compiler.server; +import org.jboss.netty.channel.Channel; import org.jetbrains.jps.api.CmdlineRemoteProto; +import java.util.UUID; + /** * @author Eugene Zhuravlev * Date: 4/25/12 */ public interface BuilderMessageHandler { - void handleBuildMessage(CmdlineRemoteProto.Message.BuilderMessage msg); + void handleBuildMessage(Channel channel, UUID sessionId, CmdlineRemoteProto.Message.BuilderMessage msg); - void handleFailure(CmdlineRemoteProto.Message.Failure failure); + void handleFailure(UUID sessionId, CmdlineRemoteProto.Message.Failure failure); void sessionTerminated(); } diff --git a/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java b/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java index 17b7774acde5..2dbe95da22fd 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java @@ -15,15 +15,20 @@ */ package com.intellij.compiler.server; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.Channels; +import org.jetbrains.jps.api.CmdlineProtoUtil; import org.jetbrains.jps.api.CmdlineRemoteProto; +import java.util.UUID; + /** * @author Eugene Zhuravlev * Date: 4/18/12 */ public abstract class DefaultMessageHandler implements BuilderMessageHandler { @Override - public final void handleBuildMessage(CmdlineRemoteProto.Message.BuilderMessage msg) { + public final void handleBuildMessage(Channel channel, UUID sessionId, CmdlineRemoteProto.Message.BuilderMessage msg) { switch (msg.getType()) { case BUILD_EVENT: handleBuildEvent(msg.getBuildEvent()); @@ -31,9 +36,23 @@ public abstract class DefaultMessageHandler implements BuilderMessageHandler { case COMPILE_MESSAGE: handleCompileMessage(msg.getCompileMessage()); break; + case CONSTANT_SEARCH_TASK: + handleConstantSearchTask(channel, sessionId, msg.getConstantSearchTask()); } } + protected void handleConstantSearchTask(Channel channel, UUID sessionId, CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask task) { + // todo: complete impl + final CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.Builder builder = + CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.newBuilder(); + builder.setOwnerClassName(task.getOwnerClassName()); + builder.setFieldName(task.getFieldName()); + builder.setIsSuccess(false); // todo + Channels.write(channel, CmdlineProtoUtil.toMessage(sessionId, CmdlineRemoteProto.Message.ControllerMessage.newBuilder().setType( + CmdlineRemoteProto.Message.ControllerMessage.Type.CONSTANT_SEARCH_RESULT).setConstantSearchResult(builder.build()).build() + )); + } + protected abstract void handleCompileMessage(CmdlineRemoteProto.Message.BuilderMessage.CompileMessage message); protected abstract void handleBuildEvent(CmdlineRemoteProto.Message.BuilderMessage.BuildEvent event); diff --git a/jps/jps-builders/proto/cmdline_remote_proto.proto b/jps/jps-builders/proto/cmdline_remote_proto.proto index 29d3e66a6c8b..d1e4f5a69c17 100644 --- a/jps/jps-builders/proto/cmdline_remote_proto.proto +++ b/jps/jps-builders/proto/cmdline_remote_proto.proto @@ -32,6 +32,7 @@ message Message { BUILD_PARAMETERS = 1; CANCEL_BUILD_COMMAND = 2; FS_EVENT = 3; + CONSTANT_SEARCH_RESULT = 4; } message FSEvent { @@ -74,9 +75,17 @@ message Message { repeated KeyValuePair builder_parameter = 7; } + message ConstantSearchResult { + required string owner_class_name = 1; + required string field_name = 2; + required bool is_success = 3; + repeated string path = 4; + } + required Type type = 1; optional ParametersMessage params_message = 2; optional FSEvent fs_event = 3; + optional ConstantSearchResult constant_search_result = 4; } message BuilderMessage { @@ -84,6 +93,7 @@ message Message { PARAM_REQUEST = 1; BUILD_EVENT = 2; COMPILE_MESSAGE = 3; + CONSTANT_SEARCH_TASK = 4; } message BuildEvent { @@ -128,9 +138,18 @@ message Message { optional float done = 9; } + message ConstantSearchTask { + required string owner_class_name = 1; + required string field_name = 2; + required int32 access_flags = 3; + optional bool is_access_changed = 4 [default = false]; + optional bool is_field_removed = 5 [default = false]; + } + required Type type = 1; optional BuildEvent build_event = 2; optional CompileMessage compile_message = 3; + optional ConstantSearchTask constant_search_task = 4; } required UUID session_id = 1; diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/BasicFuture.java b/jps/jps-builders/src/org/jetbrains/jps/api/BasicFuture.java new file mode 100644 index 000000000000..51edb3b2f19c --- /dev/null +++ b/jps/jps-builders/src/org/jetbrains/jps/api/BasicFuture.java @@ -0,0 +1,80 @@ +package org.jetbrains.jps.api; + +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * @author Eugene Zhuravlev + * Date: 5/3/12 + */ +public class BasicFuture implements Future { + protected final Semaphore mySemaphore = new Semaphore(1); + private final AtomicBoolean myDone = new AtomicBoolean(false); + private final AtomicBoolean myCanceledState = new AtomicBoolean(false); + + public BasicFuture() { + } + + public void setDone() { + if (!myDone.getAndSet(true)) { + mySemaphore.release(); + } + } + + public boolean cancel(boolean mayInterruptIfRunning) { + if (isDone()) { + return false; + } + if (!myCanceledState.getAndSet(true)) { + try { + performCancel(); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + return true; + } + + protected void performCancel() throws Exception { + } + + public boolean isCancelled() { + return myCanceledState.get(); + } + + public boolean isDone() { + return myDone.get(); + } + + public void waitFor() { + try { + while (!isDone()) { + mySemaphore.tryAcquire(100L, TimeUnit.MILLISECONDS); + } + } + catch (InterruptedException ignored) { + } + } + + public boolean waitFor(long timeout, TimeUnit unit) { + try { + if (!isDone()) { + mySemaphore.tryAcquire(timeout, unit); + } + } + catch (InterruptedException ignored) { + } + return isDone(); + } + + public T get() throws InterruptedException, ExecutionException { + waitFor(); + return null; + } + + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + waitFor(timeout, unit); + return null; + } +} diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineRemoteProto.java b/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineRemoteProto.java index 4c727199a518..64b7c3a4293c 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineRemoteProto.java +++ b/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineRemoteProto.java @@ -1364,6 +1364,10 @@ public final class CmdlineRemoteProto { // optional .org.jetbrains.jpsservice.Message.ControllerMessage.FSEvent fs_event = 3; boolean hasFsEvent(); org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.FSEvent getFsEvent(); + + // optional .org.jetbrains.jpsservice.Message.ControllerMessage.ConstantSearchResult constant_search_result = 4; + boolean hasConstantSearchResult(); + org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult getConstantSearchResult(); } public static final class ControllerMessage extends com.google.protobuf.GeneratedMessageLite @@ -1388,11 +1392,13 @@ public final class CmdlineRemoteProto { BUILD_PARAMETERS(0, 1), CANCEL_BUILD_COMMAND(1, 2), FS_EVENT(2, 3), + CONSTANT_SEARCH_RESULT(3, 4), ; public static final int BUILD_PARAMETERS_VALUE = 1; public static final int CANCEL_BUILD_COMMAND_VALUE = 2; public static final int FS_EVENT_VALUE = 3; + public static final int CONSTANT_SEARCH_RESULT_VALUE = 4; public final int getNumber() { return value; } @@ -1402,6 +1408,7 @@ public final class CmdlineRemoteProto { case 1: return BUILD_PARAMETERS; case 2: return CANCEL_BUILD_COMMAND; case 3: return FS_EVENT; + case 4: return CONSTANT_SEARCH_RESULT; default: return null; } } @@ -4513,6 +4520,612 @@ public final class CmdlineRemoteProto { // @@protoc_insertion_point(class_scope:org.jetbrains.jpsservice.Message.ControllerMessage.ParametersMessage) } + public interface ConstantSearchResultOrBuilder + extends com.google.protobuf.MessageLiteOrBuilder { + + // required string owner_class_name = 1; + boolean hasOwnerClassName(); + String getOwnerClassName(); + + // required string field_name = 2; + boolean hasFieldName(); + String getFieldName(); + + // required bool is_success = 3; + boolean hasIsSuccess(); + boolean getIsSuccess(); + + // repeated string path = 4; + java.util.List getPathList(); + int getPathCount(); + String getPath(int index); + } + public static final class ConstantSearchResult extends + com.google.protobuf.GeneratedMessageLite + implements ConstantSearchResultOrBuilder { + // Use ConstantSearchResult.newBuilder() to construct. + private ConstantSearchResult(Builder builder) { + super(builder); + } + private ConstantSearchResult(boolean noInit) {} + + private static final ConstantSearchResult defaultInstance; + public static ConstantSearchResult getDefaultInstance() { + return defaultInstance; + } + + public ConstantSearchResult getDefaultInstanceForType() { + return defaultInstance; + } + + private int bitField0_; + // required string owner_class_name = 1; + public static final int OWNER_CLASS_NAME_FIELD_NUMBER = 1; + private java.lang.Object ownerClassName_; + public boolean hasOwnerClassName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + public String getOwnerClassName() { + java.lang.Object ref = ownerClassName_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (com.google.protobuf.Internal.isValidUtf8(bs)) { + ownerClassName_ = s; + } + return s; + } + } + private com.google.protobuf.ByteString getOwnerClassNameBytes() { + java.lang.Object ref = ownerClassName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((String) ref); + ownerClassName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required string field_name = 2; + public static final int FIELD_NAME_FIELD_NUMBER = 2; + private java.lang.Object fieldName_; + public boolean hasFieldName() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + public String getFieldName() { + java.lang.Object ref = fieldName_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (com.google.protobuf.Internal.isValidUtf8(bs)) { + fieldName_ = s; + } + return s; + } + } + private com.google.protobuf.ByteString getFieldNameBytes() { + java.lang.Object ref = fieldName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((String) ref); + fieldName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required bool is_success = 3; + public static final int IS_SUCCESS_FIELD_NUMBER = 3; + private boolean isSuccess_; + public boolean hasIsSuccess() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + public boolean getIsSuccess() { + return isSuccess_; + } + + // repeated string path = 4; + public static final int PATH_FIELD_NUMBER = 4; + private com.google.protobuf.LazyStringList path_; + public java.util.List + getPathList() { + return path_; + } + public int getPathCount() { + return path_.size(); + } + public String getPath(int index) { + return path_.get(index); + } + + private void initFields() { + ownerClassName_ = ""; + fieldName_ = ""; + isSuccess_ = false; + path_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasOwnerClassName()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasFieldName()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasIsSuccess()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getOwnerClassNameBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getFieldNameBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBool(3, isSuccess_); + } + for (int i = 0; i < path_.size(); i++) { + output.writeBytes(4, path_.getByteString(i)); + } + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getOwnerClassNameBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getFieldNameBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, isSuccess_); + } + { + int dataSize = 0; + for (int i = 0; i < path_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(path_.getByteString(i)); + } + size += dataSize; + size += 1 * getPathList().size(); + } + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input, extensionRegistry)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult, Builder> + implements org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResultOrBuilder { + // Construct using org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + ownerClassName_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + fieldName_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + isSuccess_ = false; + bitField0_ = (bitField0_ & ~0x00000004); + path_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult getDefaultInstanceForType() { + return org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.getDefaultInstance(); + } + + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult build() { + org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + private org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return result; + } + + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult buildPartial() { + org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult result = new org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.ownerClassName_ = ownerClassName_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.fieldName_ = fieldName_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.isSuccess_ = isSuccess_; + if (((bitField0_ & 0x00000008) == 0x00000008)) { + path_ = new com.google.protobuf.UnmodifiableLazyStringList( + path_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.path_ = path_; + result.bitField0_ = to_bitField0_; + return result; + } + + public Builder mergeFrom(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult other) { + if (other == org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.getDefaultInstance()) return this; + if (other.hasOwnerClassName()) { + setOwnerClassName(other.getOwnerClassName()); + } + if (other.hasFieldName()) { + setFieldName(other.getFieldName()); + } + if (other.hasIsSuccess()) { + setIsSuccess(other.getIsSuccess()); + } + if (!other.path_.isEmpty()) { + if (path_.isEmpty()) { + path_ = other.path_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensurePathIsMutable(); + path_.addAll(other.path_); + } + + } + return this; + } + + public final boolean isInitialized() { + if (!hasOwnerClassName()) { + + return false; + } + if (!hasFieldName()) { + + return false; + } + if (!hasIsSuccess()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + while (true) { + int tag = input.readTag(); + switch (tag) { + case 0: + + return this; + default: { + if (!parseUnknownField(input, extensionRegistry, tag)) { + + return this; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + ownerClassName_ = input.readBytes(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + fieldName_ = input.readBytes(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + isSuccess_ = input.readBool(); + break; + } + case 34: { + ensurePathIsMutable(); + path_.add(input.readBytes()); + break; + } + } + } + } + + private int bitField0_; + + // required string owner_class_name = 1; + private java.lang.Object ownerClassName_ = ""; + public boolean hasOwnerClassName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + public String getOwnerClassName() { + java.lang.Object ref = ownerClassName_; + if (!(ref instanceof String)) { + String s = ((com.google.protobuf.ByteString) ref).toStringUtf8(); + ownerClassName_ = s; + return s; + } else { + return (String) ref; + } + } + public Builder setOwnerClassName(String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + ownerClassName_ = value; + + return this; + } + public Builder clearOwnerClassName() { + bitField0_ = (bitField0_ & ~0x00000001); + ownerClassName_ = getDefaultInstance().getOwnerClassName(); + + return this; + } + void setOwnerClassName(com.google.protobuf.ByteString value) { + bitField0_ |= 0x00000001; + ownerClassName_ = value; + + } + + // required string field_name = 2; + private java.lang.Object fieldName_ = ""; + public boolean hasFieldName() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + public String getFieldName() { + java.lang.Object ref = fieldName_; + if (!(ref instanceof String)) { + String s = ((com.google.protobuf.ByteString) ref).toStringUtf8(); + fieldName_ = s; + return s; + } else { + return (String) ref; + } + } + public Builder setFieldName(String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + fieldName_ = value; + + return this; + } + public Builder clearFieldName() { + bitField0_ = (bitField0_ & ~0x00000002); + fieldName_ = getDefaultInstance().getFieldName(); + + return this; + } + void setFieldName(com.google.protobuf.ByteString value) { + bitField0_ |= 0x00000002; + fieldName_ = value; + + } + + // required bool is_success = 3; + private boolean isSuccess_ ; + public boolean hasIsSuccess() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + public boolean getIsSuccess() { + return isSuccess_; + } + public Builder setIsSuccess(boolean value) { + bitField0_ |= 0x00000004; + isSuccess_ = value; + + return this; + } + public Builder clearIsSuccess() { + bitField0_ = (bitField0_ & ~0x00000004); + isSuccess_ = false; + + return this; + } + + // repeated string path = 4; + private com.google.protobuf.LazyStringList path_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensurePathIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + path_ = new com.google.protobuf.LazyStringArrayList(path_); + bitField0_ |= 0x00000008; + } + } + public java.util.List + getPathList() { + return java.util.Collections.unmodifiableList(path_); + } + public int getPathCount() { + return path_.size(); + } + public String getPath(int index) { + return path_.get(index); + } + public Builder setPath( + int index, String value) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathIsMutable(); + path_.set(index, value); + + return this; + } + public Builder addPath(String value) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathIsMutable(); + path_.add(value); + + return this; + } + public Builder addAllPath( + java.lang.Iterable values) { + ensurePathIsMutable(); + super.addAll(values, path_); + + return this; + } + public Builder clearPath() { + path_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000008); + + return this; + } + void addPath(com.google.protobuf.ByteString value) { + ensurePathIsMutable(); + path_.add(value); + + } + + // @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.ControllerMessage.ConstantSearchResult) + } + + static { + defaultInstance = new ConstantSearchResult(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.jetbrains.jpsservice.Message.ControllerMessage.ConstantSearchResult) + } + private int bitField0_; // required .org.jetbrains.jpsservice.Message.ControllerMessage.Type type = 1; public static final int TYPE_FIELD_NUMBER = 1; @@ -4544,10 +5157,21 @@ public final class CmdlineRemoteProto { return fsEvent_; } + // optional .org.jetbrains.jpsservice.Message.ControllerMessage.ConstantSearchResult constant_search_result = 4; + public static final int CONSTANT_SEARCH_RESULT_FIELD_NUMBER = 4; + private org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult constantSearchResult_; + public boolean hasConstantSearchResult() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult getConstantSearchResult() { + return constantSearchResult_; + } + private void initFields() { type_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.Type.BUILD_PARAMETERS; paramsMessage_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.getDefaultInstance(); fsEvent_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.FSEvent.getDefaultInstance(); + constantSearchResult_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.getDefaultInstance(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -4570,6 +5194,12 @@ public final class CmdlineRemoteProto { return false; } } + if (hasConstantSearchResult()) { + if (!getConstantSearchResult().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } memoizedIsInitialized = 1; return true; } @@ -4586,6 +5216,9 @@ public final class CmdlineRemoteProto { if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeMessage(3, fsEvent_); } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeMessage(4, constantSearchResult_); + } } private int memoizedSerializedSize = -1; @@ -4606,6 +5239,10 @@ public final class CmdlineRemoteProto { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, fsEvent_); } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, constantSearchResult_); + } memoizedSerializedSize = size; return size; } @@ -4714,6 +5351,8 @@ public final class CmdlineRemoteProto { bitField0_ = (bitField0_ & ~0x00000002); fsEvent_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.FSEvent.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000004); + constantSearchResult_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.getDefaultInstance(); + bitField0_ = (bitField0_ & ~0x00000008); return this; } @@ -4759,6 +5398,10 @@ public final class CmdlineRemoteProto { to_bitField0_ |= 0x00000004; } result.fsEvent_ = fsEvent_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.constantSearchResult_ = constantSearchResult_; result.bitField0_ = to_bitField0_; return result; } @@ -4774,6 +5417,9 @@ public final class CmdlineRemoteProto { if (other.hasFsEvent()) { mergeFsEvent(other.getFsEvent()); } + if (other.hasConstantSearchResult()) { + mergeConstantSearchResult(other.getConstantSearchResult()); + } return this; } @@ -4794,6 +5440,12 @@ public final class CmdlineRemoteProto { return false; } } + if (hasConstantSearchResult()) { + if (!getConstantSearchResult().isInitialized()) { + + return false; + } + } return true; } @@ -4841,6 +5493,15 @@ public final class CmdlineRemoteProto { setFsEvent(subBuilder.buildPartial()); break; } + case 34: { + org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.Builder subBuilder = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.newBuilder(); + if (hasConstantSearchResult()) { + subBuilder.mergeFrom(getConstantSearchResult()); + } + input.readMessage(subBuilder, extensionRegistry); + setConstantSearchResult(subBuilder.buildPartial()); + break; + } } } } @@ -4957,6 +5618,49 @@ public final class CmdlineRemoteProto { return this; } + // optional .org.jetbrains.jpsservice.Message.ControllerMessage.ConstantSearchResult constant_search_result = 4; + private org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult constantSearchResult_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.getDefaultInstance(); + public boolean hasConstantSearchResult() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult getConstantSearchResult() { + return constantSearchResult_; + } + public Builder setConstantSearchResult(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult value) { + if (value == null) { + throw new NullPointerException(); + } + constantSearchResult_ = value; + + bitField0_ |= 0x00000008; + return this; + } + public Builder setConstantSearchResult( + org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.Builder builderForValue) { + constantSearchResult_ = builderForValue.build(); + + bitField0_ |= 0x00000008; + return this; + } + public Builder mergeConstantSearchResult(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult value) { + if (((bitField0_ & 0x00000008) == 0x00000008) && + constantSearchResult_ != org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.getDefaultInstance()) { + constantSearchResult_ = + org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.newBuilder(constantSearchResult_).mergeFrom(value).buildPartial(); + } else { + constantSearchResult_ = value; + } + + bitField0_ |= 0x00000008; + return this; + } + public Builder clearConstantSearchResult() { + constantSearchResult_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult.getDefaultInstance(); + + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + // @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.ControllerMessage) } @@ -4982,6 +5686,10 @@ public final class CmdlineRemoteProto { // optional .org.jetbrains.jpsservice.Message.BuilderMessage.CompileMessage compile_message = 3; boolean hasCompileMessage(); org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.CompileMessage getCompileMessage(); + + // optional .org.jetbrains.jpsservice.Message.BuilderMessage.ConstantSearchTask constant_search_task = 4; + boolean hasConstantSearchTask(); + org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask getConstantSearchTask(); } public static final class BuilderMessage extends com.google.protobuf.GeneratedMessageLite @@ -5006,11 +5714,13 @@ public final class CmdlineRemoteProto { PARAM_REQUEST(0, 1), BUILD_EVENT(1, 2), COMPILE_MESSAGE(2, 3), + CONSTANT_SEARCH_TASK(3, 4), ; public static final int PARAM_REQUEST_VALUE = 1; public static final int BUILD_EVENT_VALUE = 2; public static final int COMPILE_MESSAGE_VALUE = 3; + public static final int CONSTANT_SEARCH_TASK_VALUE = 4; public final int getNumber() { return value; } @@ -5020,6 +5730,7 @@ public final class CmdlineRemoteProto { case 1: return PARAM_REQUEST; case 2: return BUILD_EVENT; case 3: return COMPILE_MESSAGE; + case 4: return CONSTANT_SEARCH_TASK; default: return null; } } @@ -7053,6 +7764,615 @@ public final class CmdlineRemoteProto { // @@protoc_insertion_point(class_scope:org.jetbrains.jpsservice.Message.BuilderMessage.CompileMessage) } + public interface ConstantSearchTaskOrBuilder + extends com.google.protobuf.MessageLiteOrBuilder { + + // required string owner_class_name = 1; + boolean hasOwnerClassName(); + String getOwnerClassName(); + + // required string field_name = 2; + boolean hasFieldName(); + String getFieldName(); + + // required int32 access_flags = 3; + boolean hasAccessFlags(); + int getAccessFlags(); + + // optional bool is_access_changed = 4 [default = false]; + boolean hasIsAccessChanged(); + boolean getIsAccessChanged(); + + // optional bool is_field_removed = 5 [default = false]; + boolean hasIsFieldRemoved(); + boolean getIsFieldRemoved(); + } + public static final class ConstantSearchTask extends + com.google.protobuf.GeneratedMessageLite + implements ConstantSearchTaskOrBuilder { + // Use ConstantSearchTask.newBuilder() to construct. + private ConstantSearchTask(Builder builder) { + super(builder); + } + private ConstantSearchTask(boolean noInit) {} + + private static final ConstantSearchTask defaultInstance; + public static ConstantSearchTask getDefaultInstance() { + return defaultInstance; + } + + public ConstantSearchTask getDefaultInstanceForType() { + return defaultInstance; + } + + private int bitField0_; + // required string owner_class_name = 1; + public static final int OWNER_CLASS_NAME_FIELD_NUMBER = 1; + private java.lang.Object ownerClassName_; + public boolean hasOwnerClassName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + public String getOwnerClassName() { + java.lang.Object ref = ownerClassName_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (com.google.protobuf.Internal.isValidUtf8(bs)) { + ownerClassName_ = s; + } + return s; + } + } + private com.google.protobuf.ByteString getOwnerClassNameBytes() { + java.lang.Object ref = ownerClassName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((String) ref); + ownerClassName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required string field_name = 2; + public static final int FIELD_NAME_FIELD_NUMBER = 2; + private java.lang.Object fieldName_; + public boolean hasFieldName() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + public String getFieldName() { + java.lang.Object ref = fieldName_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (com.google.protobuf.Internal.isValidUtf8(bs)) { + fieldName_ = s; + } + return s; + } + } + private com.google.protobuf.ByteString getFieldNameBytes() { + java.lang.Object ref = fieldName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((String) ref); + fieldName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required int32 access_flags = 3; + public static final int ACCESS_FLAGS_FIELD_NUMBER = 3; + private int accessFlags_; + public boolean hasAccessFlags() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + public int getAccessFlags() { + return accessFlags_; + } + + // optional bool is_access_changed = 4 [default = false]; + public static final int IS_ACCESS_CHANGED_FIELD_NUMBER = 4; + private boolean isAccessChanged_; + public boolean hasIsAccessChanged() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + public boolean getIsAccessChanged() { + return isAccessChanged_; + } + + // optional bool is_field_removed = 5 [default = false]; + public static final int IS_FIELD_REMOVED_FIELD_NUMBER = 5; + private boolean isFieldRemoved_; + public boolean hasIsFieldRemoved() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + public boolean getIsFieldRemoved() { + return isFieldRemoved_; + } + + private void initFields() { + ownerClassName_ = ""; + fieldName_ = ""; + accessFlags_ = 0; + isAccessChanged_ = false; + isFieldRemoved_ = false; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasOwnerClassName()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasFieldName()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasAccessFlags()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getOwnerClassNameBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getFieldNameBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt32(3, accessFlags_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeBool(4, isAccessChanged_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeBool(5, isFieldRemoved_); + } + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getOwnerClassNameBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getFieldNameBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, accessFlags_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(4, isAccessChanged_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(5, isFieldRemoved_); + } + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input, extensionRegistry)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask, Builder> + implements org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTaskOrBuilder { + // Construct using org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + ownerClassName_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + fieldName_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + accessFlags_ = 0; + bitField0_ = (bitField0_ & ~0x00000004); + isAccessChanged_ = false; + bitField0_ = (bitField0_ & ~0x00000008); + isFieldRemoved_ = false; + bitField0_ = (bitField0_ & ~0x00000010); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask getDefaultInstanceForType() { + return org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.getDefaultInstance(); + } + + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask build() { + org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + private org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return result; + } + + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask buildPartial() { + org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask result = new org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.ownerClassName_ = ownerClassName_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.fieldName_ = fieldName_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.accessFlags_ = accessFlags_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.isAccessChanged_ = isAccessChanged_; + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000010; + } + result.isFieldRemoved_ = isFieldRemoved_; + result.bitField0_ = to_bitField0_; + return result; + } + + public Builder mergeFrom(org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask other) { + if (other == org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.getDefaultInstance()) return this; + if (other.hasOwnerClassName()) { + setOwnerClassName(other.getOwnerClassName()); + } + if (other.hasFieldName()) { + setFieldName(other.getFieldName()); + } + if (other.hasAccessFlags()) { + setAccessFlags(other.getAccessFlags()); + } + if (other.hasIsAccessChanged()) { + setIsAccessChanged(other.getIsAccessChanged()); + } + if (other.hasIsFieldRemoved()) { + setIsFieldRemoved(other.getIsFieldRemoved()); + } + return this; + } + + public final boolean isInitialized() { + if (!hasOwnerClassName()) { + + return false; + } + if (!hasFieldName()) { + + return false; + } + if (!hasAccessFlags()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + while (true) { + int tag = input.readTag(); + switch (tag) { + case 0: + + return this; + default: { + if (!parseUnknownField(input, extensionRegistry, tag)) { + + return this; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + ownerClassName_ = input.readBytes(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + fieldName_ = input.readBytes(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + accessFlags_ = input.readInt32(); + break; + } + case 32: { + bitField0_ |= 0x00000008; + isAccessChanged_ = input.readBool(); + break; + } + case 40: { + bitField0_ |= 0x00000010; + isFieldRemoved_ = input.readBool(); + break; + } + } + } + } + + private int bitField0_; + + // required string owner_class_name = 1; + private java.lang.Object ownerClassName_ = ""; + public boolean hasOwnerClassName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + public String getOwnerClassName() { + java.lang.Object ref = ownerClassName_; + if (!(ref instanceof String)) { + String s = ((com.google.protobuf.ByteString) ref).toStringUtf8(); + ownerClassName_ = s; + return s; + } else { + return (String) ref; + } + } + public Builder setOwnerClassName(String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + ownerClassName_ = value; + + return this; + } + public Builder clearOwnerClassName() { + bitField0_ = (bitField0_ & ~0x00000001); + ownerClassName_ = getDefaultInstance().getOwnerClassName(); + + return this; + } + void setOwnerClassName(com.google.protobuf.ByteString value) { + bitField0_ |= 0x00000001; + ownerClassName_ = value; + + } + + // required string field_name = 2; + private java.lang.Object fieldName_ = ""; + public boolean hasFieldName() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + public String getFieldName() { + java.lang.Object ref = fieldName_; + if (!(ref instanceof String)) { + String s = ((com.google.protobuf.ByteString) ref).toStringUtf8(); + fieldName_ = s; + return s; + } else { + return (String) ref; + } + } + public Builder setFieldName(String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + fieldName_ = value; + + return this; + } + public Builder clearFieldName() { + bitField0_ = (bitField0_ & ~0x00000002); + fieldName_ = getDefaultInstance().getFieldName(); + + return this; + } + void setFieldName(com.google.protobuf.ByteString value) { + bitField0_ |= 0x00000002; + fieldName_ = value; + + } + + // required int32 access_flags = 3; + private int accessFlags_ ; + public boolean hasAccessFlags() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + public int getAccessFlags() { + return accessFlags_; + } + public Builder setAccessFlags(int value) { + bitField0_ |= 0x00000004; + accessFlags_ = value; + + return this; + } + public Builder clearAccessFlags() { + bitField0_ = (bitField0_ & ~0x00000004); + accessFlags_ = 0; + + return this; + } + + // optional bool is_access_changed = 4 [default = false]; + private boolean isAccessChanged_ ; + public boolean hasIsAccessChanged() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + public boolean getIsAccessChanged() { + return isAccessChanged_; + } + public Builder setIsAccessChanged(boolean value) { + bitField0_ |= 0x00000008; + isAccessChanged_ = value; + + return this; + } + public Builder clearIsAccessChanged() { + bitField0_ = (bitField0_ & ~0x00000008); + isAccessChanged_ = false; + + return this; + } + + // optional bool is_field_removed = 5 [default = false]; + private boolean isFieldRemoved_ ; + public boolean hasIsFieldRemoved() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + public boolean getIsFieldRemoved() { + return isFieldRemoved_; + } + public Builder setIsFieldRemoved(boolean value) { + bitField0_ |= 0x00000010; + isFieldRemoved_ = value; + + return this; + } + public Builder clearIsFieldRemoved() { + bitField0_ = (bitField0_ & ~0x00000010); + isFieldRemoved_ = false; + + return this; + } + + // @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.BuilderMessage.ConstantSearchTask) + } + + static { + defaultInstance = new ConstantSearchTask(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.jetbrains.jpsservice.Message.BuilderMessage.ConstantSearchTask) + } + private int bitField0_; // required .org.jetbrains.jpsservice.Message.BuilderMessage.Type type = 1; public static final int TYPE_FIELD_NUMBER = 1; @@ -7084,10 +8404,21 @@ public final class CmdlineRemoteProto { return compileMessage_; } + // optional .org.jetbrains.jpsservice.Message.BuilderMessage.ConstantSearchTask constant_search_task = 4; + public static final int CONSTANT_SEARCH_TASK_FIELD_NUMBER = 4; + private org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask constantSearchTask_; + public boolean hasConstantSearchTask() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask getConstantSearchTask() { + return constantSearchTask_; + } + private void initFields() { type_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.Type.PARAM_REQUEST; buildEvent_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.getDefaultInstance(); compileMessage_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.CompileMessage.getDefaultInstance(); + constantSearchTask_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.getDefaultInstance(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -7110,6 +8441,12 @@ public final class CmdlineRemoteProto { return false; } } + if (hasConstantSearchTask()) { + if (!getConstantSearchTask().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } memoizedIsInitialized = 1; return true; } @@ -7126,6 +8463,9 @@ public final class CmdlineRemoteProto { if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeMessage(3, compileMessage_); } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeMessage(4, constantSearchTask_); + } } private int memoizedSerializedSize = -1; @@ -7146,6 +8486,10 @@ public final class CmdlineRemoteProto { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, compileMessage_); } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, constantSearchTask_); + } memoizedSerializedSize = size; return size; } @@ -7254,6 +8598,8 @@ public final class CmdlineRemoteProto { bitField0_ = (bitField0_ & ~0x00000002); compileMessage_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.CompileMessage.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000004); + constantSearchTask_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.getDefaultInstance(); + bitField0_ = (bitField0_ & ~0x00000008); return this; } @@ -7299,6 +8645,10 @@ public final class CmdlineRemoteProto { to_bitField0_ |= 0x00000004; } result.compileMessage_ = compileMessage_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.constantSearchTask_ = constantSearchTask_; result.bitField0_ = to_bitField0_; return result; } @@ -7314,6 +8664,9 @@ public final class CmdlineRemoteProto { if (other.hasCompileMessage()) { mergeCompileMessage(other.getCompileMessage()); } + if (other.hasConstantSearchTask()) { + mergeConstantSearchTask(other.getConstantSearchTask()); + } return this; } @@ -7334,6 +8687,12 @@ public final class CmdlineRemoteProto { return false; } } + if (hasConstantSearchTask()) { + if (!getConstantSearchTask().isInitialized()) { + + return false; + } + } return true; } @@ -7381,6 +8740,15 @@ public final class CmdlineRemoteProto { setCompileMessage(subBuilder.buildPartial()); break; } + case 34: { + org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.Builder subBuilder = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.newBuilder(); + if (hasConstantSearchTask()) { + subBuilder.mergeFrom(getConstantSearchTask()); + } + input.readMessage(subBuilder, extensionRegistry); + setConstantSearchTask(subBuilder.buildPartial()); + break; + } } } } @@ -7497,6 +8865,49 @@ public final class CmdlineRemoteProto { return this; } + // optional .org.jetbrains.jpsservice.Message.BuilderMessage.ConstantSearchTask constant_search_task = 4; + private org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask constantSearchTask_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.getDefaultInstance(); + public boolean hasConstantSearchTask() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + public org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask getConstantSearchTask() { + return constantSearchTask_; + } + public Builder setConstantSearchTask(org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask value) { + if (value == null) { + throw new NullPointerException(); + } + constantSearchTask_ = value; + + bitField0_ |= 0x00000008; + return this; + } + public Builder setConstantSearchTask( + org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.Builder builderForValue) { + constantSearchTask_ = builderForValue.build(); + + bitField0_ |= 0x00000008; + return this; + } + public Builder mergeConstantSearchTask(org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask value) { + if (((bitField0_ & 0x00000008) == 0x00000008) && + constantSearchTask_ != org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.getDefaultInstance()) { + constantSearchTask_ = + org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.newBuilder(constantSearchTask_).mergeFrom(value).buildPartial(); + } else { + constantSearchTask_ = value; + } + + bitField0_ |= 0x00000008; + return this; + } + public Builder clearConstantSearchTask() { + constantSearchTask_ = org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.getDefaultInstance(); + + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + // @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.BuilderMessage) } diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/RequestFuture.java b/jps/jps-builders/src/org/jetbrains/jps/api/RequestFuture.java index b0b77c08db9a..eacfa29bb36e 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/api/RequestFuture.java +++ b/jps/jps-builders/src/org/jetbrains/jps/api/RequestFuture.java @@ -18,99 +18,40 @@ package org.jetbrains.jps.api; import org.jetbrains.annotations.Nullable; import java.util.UUID; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicBoolean; /** * @author Eugene Zhuravlev * Date: 9/13/11 */ -public class RequestFuture implements Future { - private final Semaphore mySemaphore = new Semaphore(1); - private final AtomicBoolean myDone = new AtomicBoolean(false); +public class RequestFuture extends BasicFuture { private final T myHandler; private final UUID myRequestID; @Nullable private final CancelAction myCancelAction; - private final AtomicBoolean myCanceledState = new AtomicBoolean(false); public interface CancelAction { void cancel(RequestFuture future) throws Exception; } public RequestFuture(T handler, UUID requestID, @Nullable CancelAction cancelAction) { + super(); + myCancelAction = cancelAction; myHandler = handler; myRequestID = requestID; - myCancelAction = cancelAction; mySemaphore.acquireUninterruptibly(); } - public void setDone() { - if (!myDone.getAndSet(true)) { - mySemaphore.release(); - } - } - public UUID getRequestID() { return myRequestID; } - public boolean cancel(boolean mayInterruptIfRunning) { - if (isDone()) { - return false; - } - if (!myCanceledState.getAndSet(true)) { - try { - if (myCancelAction != null) { - myCancelAction.cancel(this); - } - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - return true; - } - - public boolean isCancelled() { - return myCanceledState.get(); - } - - public boolean isDone() { - return myDone.get(); - } - - public void waitFor() { - try { - while (!isDone()) { - mySemaphore.tryAcquire(100L, TimeUnit.MILLISECONDS); - } - } - catch (InterruptedException ignored) { - } - } - - public boolean waitFor(long timeout, TimeUnit unit) { - try { - if (!isDone()) { - mySemaphore.tryAcquire(timeout, unit); - } - } - catch (InterruptedException ignored) { - } - return isDone(); - } - - public Object get() throws InterruptedException, ExecutionException { - waitFor(); - return null; - } - - public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - waitFor(timeout, unit); - return null; - } - public T getMessageHandler() { return myHandler; } + + @Override + protected void performCancel() throws Exception { + if (myCancelAction != null) { + myCancelAction.cancel(this); + } + } } diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildMain.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildMain.java index 637cf04e41fa..d3406d063ee7 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildMain.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildMain.java @@ -110,6 +110,14 @@ public class BuildMain { return; } + case CONSTANT_SEARCH_RESULT: { + final BuildSession session = mySession; + if (session != null) { + session.processConstantSearchResult(controllerMessage.getConstantSearchResult()); + } + return; + } + case CANCEL_BUILD_COMMAND: { final BuildSession session = mySession; if (session != null) { diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java index 705096beb3b3..f6adf474c8ae 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java @@ -15,6 +15,7 @@ import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.Channels; import org.jetbrains.annotations.Nullable; +import org.jetbrains.ether.dependencyView.Callbacks; import org.jetbrains.jps.Library; import org.jetbrains.jps.Module; import org.jetbrains.jps.Project; @@ -34,6 +35,10 @@ import org.jetbrains.jps.server.ProjectDescriptor; import java.io.*; import java.util.*; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -65,6 +70,8 @@ final class BuildSession implements Runnable, CanceledStatus { private EventsProcessor myEventsProcessor = new EventsProcessor(); private volatile long myLastEventOrdinal; private volatile ProjectDescriptor myProjectDescriptor; + private final Map, ConstantSearchFuture> mySearchTasks = Collections.synchronizedMap(new HashMap, ConstantSearchFuture>()); + private final ConstantSearch myConstantSearch = new ConstantSearch(); BuildSession(UUID sessionId, Channel channel, @@ -208,7 +215,7 @@ final class BuildSession implements Runnable, CanceledStatus { final Timestamps timestamps = pd.timestamps.getStorage(); final CompileScope compileScope = createCompilationScope(buildType, pd, timestamps, modules, artifacts, paths); - final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), timestamps, builderParams, cs); + final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), timestamps, builderParams, cs, myConstantSearch); builder.addMessageHandler(msgHandler); try { switch (buildType) { @@ -262,6 +269,23 @@ final class BuildSession implements Runnable, CanceledStatus { }); } + public void processConstantSearchResult(CmdlineRemoteProto.Message.ControllerMessage.ConstantSearchResult result) { + final ConstantSearchFuture future = mySearchTasks.remove(Pair.create(result.getOwnerClassName(), result.getFieldName())); + if (future != null) { + if (result.getIsSuccess()) { + final List paths = result.getPathList(); + final List files = new ArrayList(paths.size()); + for (String path : paths) { + files.add(new File(path)); + } + future.setResult(files); + } + else { + future.setDone(); + } + } + } + private void applyFSEvent(ProjectDescriptor pd, @Nullable CmdlineRemoteProto.Message.ControllerMessage.FSEvent event) throws IOException { if (event == null) { return; @@ -600,4 +624,52 @@ final class BuildSession implements Runnable, CanceledStatus { } } } + + private class ConstantSearch implements Callbacks.ConstantAffectionResolver { + @Nullable @Override + public Future request(String ownerClassName, String fieldName, int accessFlags, boolean fieldRemoved, boolean accessChanged) { + final CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.Builder task = + CmdlineRemoteProto.Message.BuilderMessage.ConstantSearchTask.newBuilder(); + task.setOwnerClassName(ownerClassName); + task.setFieldName(fieldName); + task.setAccessFlags(accessFlags); + task.setIsAccessChanged(accessChanged); + task.setIsFieldRemoved(fieldRemoved); + final ConstantSearchFuture future = new ConstantSearchFuture(); + final ConstantSearchFuture prev = mySearchTasks.put(new Pair(ownerClassName, fieldName), future); + if (prev != null) { + prev.setDone(); + } + Channels.write(myChannel, + CmdlineProtoUtil.toMessage( + mySessionId, CmdlineRemoteProto.Message.BuilderMessage.newBuilder().setType(CmdlineRemoteProto.Message.BuilderMessage.Type.CONSTANT_SEARCH_TASK).setConstantSearchTask(task.build()).build() + ) + ); + return future; + } + } + + private static class ConstantSearchFuture extends BasicFuture { + private volatile Callbacks.ConstantAffection myResult = Callbacks.ConstantAffection.EMPTY; + + private ConstantSearchFuture() { + } + + public void setResult(final Collection affectedFiles) { + myResult = new Callbacks.ConstantAffection(affectedFiles); + setDone(); + } + + @Override + public Callbacks.ConstantAffection get() throws InterruptedException, ExecutionException { + super.get(); + return myResult; + } + + @Override + public Callbacks.ConstantAffection get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + super.get(timeout, unit); + return myResult; + } + } } diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java index 1b20dac5216a..68907e23c8cd 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java @@ -8,6 +8,8 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.io.MappingFailedException; import com.intellij.util.io.PersistentEnumerator; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.ether.dependencyView.Callbacks; import org.jetbrains.ether.dependencyView.Mappings; import org.jetbrains.jps.*; import org.jetbrains.jps.api.CanceledStatus; @@ -49,6 +51,7 @@ public class IncProjectBuilder { private final BuilderRegistry myBuilderRegistry; private final Map myBuilderParams; private final CanceledStatus myCancelStatus; + @Nullable private final Callbacks.ConstantAffectionResolver myConstantSearch; private ProjectChunks myProductionChunks; private ProjectChunks myTestChunks; private final List myMessageHandlers = new ArrayList(); @@ -70,11 +73,12 @@ public class IncProjectBuilder { BuilderRegistry builderRegistry, final Timestamps timestamps, Map builderParams, - CanceledStatus cs) { + CanceledStatus cs, @Nullable Callbacks.ConstantAffectionResolver constantSearch) { myProjectDescriptor = pd; myBuilderRegistry = builderRegistry; myBuilderParams = builderParams; myCancelStatus = cs; + myConstantSearch = constantSearch; myProductionChunks = new ProjectChunks(pd.project, ClasspathKind.PRODUCTION_COMPILE); myTestChunks = new ProjectChunks(pd.project, ClasspathKind.TEST_COMPILE); myTotalModulesWork = (float)pd.rootsIndex.getTotalModuleCount() * 2; /* multiply by 2 to reflect production and test sources */ @@ -246,10 +250,12 @@ public class IncProjectBuilder { } private CompileContext createContext(CompileScope scope, boolean isMake, final boolean isProjectRebuild) throws ProjectBuildException { - return new CompileContext( + final CompileContext context = new CompileContext( scope, myProjectDescriptor, isMake, isProjectRebuild, myProductionChunks, myTestChunks, myMessageDispatcher, myBuilderParams, myTimestamps, myCancelStatus ); + ModuleLevelBuilder.CONSTANT_SEARCH_SERVICE.set(context, myConstantSearch); + return context; } private void cleanOutputRoots(CompileContext context) throws ProjectBuildException { diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java index b062f7724b87..0e41a0cec7fb 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java @@ -3,6 +3,7 @@ package org.jetbrains.jps.incremental; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; +import org.jetbrains.ether.dependencyView.Callbacks; import org.jetbrains.ether.dependencyView.Mappings; import org.jetbrains.jps.Module; import org.jetbrains.jps.ModuleChunk; @@ -25,6 +26,7 @@ public abstract class ModuleLevelBuilder extends Builder { private static final Key> ALL_AFFECTED_FILES_KEY = Key.create("_all_affected_files_"); private static final Key> ALL_COMPILED_FILES_KEY = Key.create("_all_compiled_files_"); + static final Key CONSTANT_SEARCH_SERVICE = Key.create("_constant_search_service_"); private final BuilderCategory myCategory; @@ -83,7 +85,7 @@ public abstract class ModuleLevelBuilder extends Builder { final ModulesBasedFileFilter moduleBasedFilter = new ModulesBasedFileFilter(context, chunk); final boolean incremental = globalMappings.differentiate( - delta, removedPaths, filesToCompile, allCompiledFiles, allAffectedFiles, moduleBasedFilter, null + delta, removedPaths, filesToCompile, allCompiledFiles, allAffectedFiles, moduleBasedFilter, CONSTANT_SEARCH_SERVICE.get(context) ); if (LOG.isDebugEnabled()) { diff --git a/jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java b/jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java index f675d361abab..cf720345f2b1 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java +++ b/jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java @@ -181,7 +181,7 @@ class ServerState { final Timestamps timestamps = pd.timestamps.getStorage(); final CompileScope compileScope = createCompilationScope(buildType, pd, timestamps, modules, artifacts, paths); - final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), timestamps, builderParams, cs); + final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), timestamps, builderParams, cs, null); builder.addMessageHandler(msgHandler); try { switch (buildType) { diff --git a/jps/jps-builders/testSrc/org/jetbrains/ether/IncrementalTestCase.java b/jps/jps-builders/testSrc/org/jetbrains/ether/IncrementalTestCase.java index c51683c00f27..6c8040a80311 100644 --- a/jps/jps-builders/testSrc/org/jetbrains/ether/IncrementalTestCase.java +++ b/jps/jps-builders/testSrc/org/jetbrains/ether/IncrementalTestCase.java @@ -208,8 +208,8 @@ public abstract class IncrementalTestCase extends TestCase { new BuildDataManager(dataStorageRoot, true), new BuildLoggingManager(new ArtifactBuilderLoggerImpl(), javaBuilderLogger)); try { new IncProjectBuilder( - projectDescriptor, BuilderRegistry.getInstance(), projectDescriptor.timestamps.getStorage(), Collections.emptyMap(), CanceledStatus.NULL - ).build( + projectDescriptor, BuilderRegistry.getInstance(), projectDescriptor.timestamps.getStorage(), Collections.emptyMap(), CanceledStatus.NULL, + null).build( new AllProjectScope(project, Collections.emptySet(), true), false, true, false ); @@ -220,8 +220,8 @@ public abstract class IncrementalTestCase extends TestCase { } new IncProjectBuilder( - projectDescriptor, BuilderRegistry.getInstance(), projectDescriptor.timestamps.getStorage(), Collections.emptyMap(), CanceledStatus.NULL - ).build( + projectDescriptor, BuilderRegistry.getInstance(), projectDescriptor.timestamps.getStorage(), Collections.emptyMap(), CanceledStatus.NULL, + null).build( new AllProjectScope(project, Collections.emptySet(), false), true, false, false ); diff --git a/jps/jps-builders/testSrc/org/jetbrains/jps/incremental/artifacts/ArtifactBuilderTestCase.java b/jps/jps-builders/testSrc/org/jetbrains/jps/incremental/artifacts/ArtifactBuilderTestCase.java index 0bde98391973..2a53c96dbe51 100644 --- a/jps/jps-builders/testSrc/org/jetbrains/jps/incremental/artifacts/ArtifactBuilderTestCase.java +++ b/jps/jps-builders/testSrc/org/jetbrains/jps/incremental/artifacts/ArtifactBuilderTestCase.java @@ -181,7 +181,8 @@ public abstract class ArtifactBuilderTestCase extends UsefulTestCase { } myArtifactBuilderLogger.clear(); final Timestamps timestamps = myDescriptor.timestamps.getStorage(); - IncProjectBuilder builder = new IncProjectBuilder(myDescriptor, BuilderRegistry.getInstance(), timestamps, Collections.emptyMap(), CanceledStatus.NULL); + IncProjectBuilder builder = new IncProjectBuilder(myDescriptor, BuilderRegistry.getInstance(), timestamps, Collections.emptyMap(), CanceledStatus.NULL, + null); final List errorMessages = new ArrayList(); final List infoMessages = new ArrayList(); builder.addMessageHandler(new MessageHandler() { diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Callbacks.java b/jps/model/src/org/jetbrains/ether/dependencyView/Callbacks.java index 7835c8911f48..2b3e499a2493 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Callbacks.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Callbacks.java @@ -21,6 +21,7 @@ public class Callbacks { } public static class ConstantAffection { + public static final ConstantAffection EMPTY = new ConstantAffection(); private final boolean myKnown; private final Collection myAffectedFiles; @@ -44,6 +45,10 @@ public class Callbacks { } public interface ConstantAffectionResolver { - Future request(final String owner, final String name); + Future request(final String ownerClassName, + final String fieldName, + int accessFlags, + boolean fieldRemoved, + boolean accessChanged); } } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java index 3fd6c9dcfcf4..06cdd47625a5 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java @@ -772,10 +772,7 @@ public class Mappings { } } - private boolean incrementalDecision(final int owner, - final Proto member, - final Collection affectedFiles, - final DependentFilesFilter filter) { + private boolean incrementalDecision(final int owner, final Proto member, final Collection affectedFiles, final DependentFilesFilter filter) { final boolean isField = member instanceof FieldRepr; final Util self = new Util(this); @@ -844,28 +841,25 @@ public class Mappings { final Collection compiledFiles, final Collection affectedFiles, final DependentFilesFilter filter, - final Callbacks.ConstantAffectionResolver lastResort) { + @Nullable final Callbacks.ConstantAffectionResolver constantSearch) { synchronized (myLock) { class DelayedWorks { class Triple { final int owner; final FieldRepr field; + @Nullable final Future affection; - private Triple(final int owner, final FieldRepr field, final Future affection) { + private Triple(final int owner, final FieldRepr field, @Nullable final Future affection) { this.owner = owner; this.field = field; this.affection = affection; } Callbacks.ConstantAffection getAffection() { - if (affection == null) { - return null; - } - try { - return affection.get(); + return affection != null? affection.get() : Callbacks.ConstantAffection.EMPTY; } catch (Exception e) { throw new RuntimeException(e); @@ -875,35 +869,46 @@ public class Mappings { final Collection myQueue = new LinkedList(); - void addConstantWork(final int owner, final FieldRepr field) { - myQueue.add(new Triple(owner, field, lastResort.request(myContext.getValue(owner), myContext.getValue(field.name)))); + void addConstantWork(final int ownerClass, final FieldRepr changedField, final boolean isRemoved, boolean accessChanged) { + final Future future; + if (constantSearch == null) { + future = null; + } + else { + final String className = myContext.getValue(ownerClass); + final String fieldName = myContext.getValue(changedField.name); + future = constantSearch.request(className.replace('/', '.'), fieldName, changedField.access, isRemoved, accessChanged); + } + myQueue.add(new Triple(ownerClass, changedField, future)); } boolean doWork(final Collection affectedFiles) { - debug("Starting delayed works."); + if (!myQueue.isEmpty()) { + debug("Starting delayed works."); - for (final Triple t : myQueue) { - final Callbacks.ConstantAffection affection = t.getAffection(); + for (final Triple t : myQueue) { + final Callbacks.ConstantAffection affection = t.getAffection(); - debug("Class: ", t.owner); - debug("Field: ", t.field.name); + debug("Class: ", t.owner); + debug("Field: ", t.field.name); - if (!affection.isKnown()) { - debug("No external dependency information available."); - debug("Trying to soften non-incremental decision."); - if (!incrementalDecision(t.owner, t.field, affectedFiles, filter)) { - debug("No luck."); - debug("End of delayed work, returning false."); - return false; + if (!affection.isKnown()) { + debug("No external dependency information available."); + debug("Trying to soften non-incremental decision."); + if (!incrementalDecision(t.owner, t.field, affectedFiles, filter)) { + debug("No luck."); + debug("End of delayed work, returning false."); + return false; + } + } + else { + debug("External dependency information retrieved."); + affectedFiles.addAll(affection.getAffectedFiles()); } } - else { - debug("External dependency information retrieved."); - affectedFiles.addAll(affection.getAffectedFiles()); - } - } - debug("End of delayed work, returning true."); + debug("End of delayed work, returning true."); + } return true; } } @@ -1472,8 +1477,8 @@ public class Mappings { if ((f.access & Opcodes.ACC_PRIVATE) == 0 && (f.access & mask) == mask && f.hasValue()) { debug("Field had value and was (non-private) final static => a switch to non-incremental mode requested"); - if (lastResort != null) { - works.addConstantWork(it.name, f); + if (constantSearch != null) { + works.addConstantWork(it.name, f, true, false); } else { if (!incrementalDecision(it.name, f, affectedFiles, filter)) { @@ -1503,8 +1508,8 @@ public class Mappings { if (harmful || valueChanged || (accessChanged && !d.weakedAccess())) { debug("Inline field changed it's access or value => a switch to non-incremental mode requested"); - if (lastResort != null) { - works.addConstantWork(it.name, field); + if (constantSearch != null) { + works.addConstantWork(it.name, field, false, accessChanged); } else { if (!incrementalDecision(it.name, field, affectedFiles, filter)) {