-
Notifications
You must be signed in to change notification settings - Fork 7
Some fixes to run arg_scanner on diaspora specs. #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -1,6 +1,7 @@ | |||
require 'set' | |||
require 'socket' | |||
require 'singleton' | |||
require 'thread' | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
val currRTuple = ben(jsonTome) { RTupleBuilder.fromJson(jsonString) } | ||
|
||
if (currRTuple?.methodInfo?.classInfo?.classFQN?.startsWith("#<") == true) { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several nested try-while-try-etc are very difficult to understand. We have to refactor this into several methods.
Also: what kind of exception may occur which requires finally
block in the end? I do not see any returns from the above code.a
@@ -125,11 +147,22 @@ object SignatureServer { | |||
try { | |||
val br = BufferedReader(InputStreamReader(socket.getInputStream())) | |||
|
|||
var iter = 0L | |||
var millis = System.currentTimeMillis() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields and corresponding logic are just logging/debugging goodness. I think it should be encapsulated into some logger class or something; in other case it's difficult to understand where business logic starts and debugging info does.
val currString = ben(readTime) { br.readLine() } | ||
?: break | ||
if (queue.size > queue.remainingCapacity()) { | ||
LOGGER.info("Queue capacity is low") | ||
val remainingCapacity = queue.remainingCapacity() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this extraction makes much sense
SchemaUtils.create(GemInfoTable, ClassInfoTable, MethodInfoTable, SignatureTable) | ||
transaction.commit() | ||
runServer() | ||
Database.connect("jdbc:mysql://localhost:3306/" + "ruby_type_contracts" + "?serverTimezone=UTC&nullNamePatternMatchesAll=true&useSSL=false", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DatabaseProvider.connect()
?
final Set<String> returnTypes = contract.Companion.getAllReturnTypes(contract); | ||
final RType trueType = RBooleanType.getTrueType(project); | ||
final RType falseType = RBooleanType.getFalseType(project); | ||
final RType booleanType = RTypeUtil.union(trueType, falseType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
org.jetbrains.plugins.ruby.ruby.codeInsight.types.RTypeFactory#createBoolType
@@ -193,42 +250,62 @@ public RType createTypeByCallAndArgs(@NotNull final RExpression call, @NotNull f | |||
|
|||
if ((arg instanceof RAssoc) ^ (paramInfos.get(i1).getModifier() == ParameterInfo.Type.KEY || | |||
paramInfos.get(i1).getModifier() == ParameterInfo.Type.KEYREQ)) { | |||
Logger.getInstance(RubyStatTypeProviderImpl.class).error("wtf"); | |||
return REmptyType.INSTANCE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a sample of test on which this line fails?
RType returnVal = returnTypes.stream() | ||
.map(name -> RTypeFactory.createTypeByFQN(call.getProject(), name)) | ||
.reduce(REmptyType.INSTANCE, RTypeUtil::union); | ||
if (returnVal != REmptyType.INSTANCE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract debugging facilities.
@@ -307,7 +384,7 @@ private static MethodInfo findMethodInfo(@NotNull final PsiElement callElement) | |||
arg = ((RAssoc) arg).getValue(); | |||
} | |||
|
|||
final Set<String> argTypeNames = new HashSet<>(); | |||
final Set<String> argTypeNames = new LinkedHashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is order imporant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can sort stuff in debug messages; now you add memory and (little) cpu overhead for common code
} | ||
stream.writeInt(PROTOCOL_VERSION) | ||
stream.writeInt(gemInfo2Id.size) | ||
var iter = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this assertion is very helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the looks. The method is 40 lines long so every such variable complicates the state for the reader.
@@ -70,36 +84,44 @@ object SignatureServer { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 76 |
---|
It was used in RubyStatTypeProviderImpl |
@@ -70,36 +84,44 @@ object SignatureServer { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 76 |
---|
I suggest addressing that in another PR in order to increase the possiblity of that one be merged :) |
@@ -70,36 +84,44 @@ object SignatureServer { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 76 |
---|
Next time, yes, please. |
@@ -13,7 +56,9 @@ class TypeTracker | |||
def initialize | |||
@cache = Set.new | |||
@socket = TCPSocket.new('127.0.0.1', 7777) | |||
|
|||
@mutex = Mutex.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest instantiating it only on some condition (debugging env variable, etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw I think @perf_mon = TTPM.new if @enable_debug
will do the same :)
But we'll do it LATER
@@ -142,7 +165,31 @@ object SignatureServer { | |||
} catch (e: IOException) { | |||
LOGGER.severe("Can't close a socket") | |||
} | |||
onExit(handlerNumber) | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thx.
val args5 = listOf("Int1", "Int2", "Int3") | ||
private fun generateComplicatedContract() : RSignatureContract { | ||
val args1 = listOf("a1", "c2", "a3", "a4") | ||
val args2 = listOf("a1", "b2", "a3", "a4") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you changed existing tests? You might add new ones instead
|
||
val testArgs1 = listOf("Int1", "Int2", "Int3") | ||
val testArgs2 = listOf("String1", "Int2", "Int3") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serialisation has nothing to do with Merge, please move such tests to the corresponding class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I also want to extract common stuff for *Info generation into BaseTestClass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. BTW there are already serialisation tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take note on SignatureInfoData
and stuff: https://upsource.jetbrains.com/ruby-type-inference/file/1d921936421673c0375ac555967545959bfafbdf/storage-server-api/src/test/java/org/jetbrains/ruby/codeInsight/types/storage/server/impl/SignatureContractSerializationTest.kt?nav=964:981:focused&line=0
I mean they are not ideal, too and worth extracring to some testdata place.
|
||
|
||
fun connect(inMemory: Boolean = false, | ||
setupConnection: ((Connection) -> Unit)? = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure you need these params. In java classes they were specified just because kotlin did not generate enough overloads for this method. I'd remove all params (except inMemory
) and cleanup the code inside
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what about CallStatCompletionTest
? It passes additional parameters to DatabaseProvider
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In java classes they were specified just because kotlin did not generate enough overloads for this method
This is what I was talking about, in CallStatCompletionTest
I've just re-initialised the default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for explanation, now I get it.
|
||
def on_call | ||
@submitted_call_counter += 1 | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe navigation &.
FTW
But we'll do it LATER
|
Ofc, it cannot, ty :-) |
Add serialization/deserialization for list of `SignatureInfo` Refactor MergeTest.kt Fix misspelling in signature-viwer/build.gradle
Extract code for importing/exporting contract files to `RmcDirectory`. Add a binary serialization test.
- Move serialization tests to ruby-call-signature - Add base class for signature tests which contains common test data - Extract pure serialization tests from merge tests
No description provided.