Skip to content

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

Merged
merged 22 commits into from
Nov 8, 2017
Merged

Some fixes to run arg_scanner on diaspora specs. #7

merged 22 commits into from
Nov 8, 2017

Conversation

vladimir-koshelev
Copy link
Collaborator

No description provided.

@valich
Copy link
Collaborator

valich commented Oct 26, 2017

@@ -1,6 +1,7 @@
require 'set'
require 'socket'
require 'singleton'
require 'thread'

Copy link
Collaborator

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 {
Copy link
Collaborator

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()
Copy link
Collaborator

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()
Copy link
Collaborator

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",
Copy link
Collaborator

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);
Copy link
Collaborator

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;
Copy link
Collaborator

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) {
Copy link
Collaborator

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<>();
Copy link
Collaborator

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?

Copy link
Collaborator

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
Copy link
Collaborator

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

Copy link
Collaborator

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 {

Copy link
Collaborator

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 {

Copy link
Collaborator

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 {

Copy link
Collaborator

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
Copy link
Collaborator

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Collaborator

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)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private?

Copy link
Collaborator Author

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")
Copy link
Collaborator

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")
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



fun connect(inMemory: Boolean = false,
setupConnection: ((Connection) -> Unit)? = null,
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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
Copy link
Collaborator

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

@valich
Copy link
Collaborator

valich commented Nov 7, 2017

ide-plugin/src/test/java/CallStatCompletionTest.java:100
concatenating something and absolute path? How should this work? Could you please provide an example?

@vladimir-koshelev
Copy link
Collaborator Author

Ofc, it cannot, ty :-)

@valich valich merged commit d5a3bf3 into JetBrains:master Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants