Giter VIP home page Giter VIP logo

codescoop's People

Contributors

andrewhead avatar eglassman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

disco195

codescoop's Issues

Installation question

So, I got to this part of the README, and the following happened:

airbears2-10-142-37-169:examplify elenaglassman$ SOOT_JARS=`ls -d -1 $PWD/java/libs/*.jar | tr '\n' ':'`
airbears2-10-142-37-169:examplify elenaglassman$ JAVA_HOME_LIBS=`ls -d -1 $JAVA_HOME/jre/lib/*.jar | tr '\n' ':'`
ls: /jre/lib/*.jar: No such file or directory
airbears2-10-142-37-169:examplify elenaglassman$ cd java/
airbears2-10-142-37-169:java elenaglassman$ javac -cp $SOOT_JARS:$JAVA_HOME_LIBS:. DataflowAnalysis.java

airbears2-10-142-37-169:java elenaglassman$ 

I'm assumed that was because I didn't have Java installed, but once I installed it (from here: https://www.java.com/en/download/mac_download.jsp) I still got:

airbears2-10-142-37-169:examplify elenaglassman$ JAVA_HOME_LIBS=`ls -d -1 $JAVA_HOME/jre/lib/*.jar | tr '\n' ':'`
ls: /jre/lib/*.jar: No such file or directory

Thoughts?

Failed to work again on my computer :/

[Enter steps to reproduce:]

  1. open BookListing.java
  2. select Database database = new Database("lou", "PA$$W0RD", "https://acme-books.com/db"); and click menu item create example from selection

Atom: 1.18.0 x64
Electron: 1.3.15
OS: Mac OS X 10.12.6
Thrown From: examplify package 0.0.0

Stack Trace

Failed to activate the examplify package

At Could not create class ImportAnalysis
java.lang.UnsupportedClassVersionError: ImportAnalysis : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)


Error: Could not create class ImportAnalysis
java.lang.UnsupportedClassVersionError: ImportAnalysis : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

    at Error (native)
    at Java.java.import (/Users/elenaglassman/Gitrepos/examplify/node_modules/java/lib/nodeJavaBridge.js:227:20)
    at Object.<anonymous> (/Users/elenaglassman/Gitrepos/examplify/lib/analysis/import-analysis.coffee:9:19)
    at Object.<anonymous> (/Users/elenaglassman/Gitrepos/examplify/lib/analysis/import-analysis.coffee:1:1)
    at Module.get_Module._compile (/Applications/Atom.app/Contents/Resources/app/src/native-compile-cache.js:106:36)
    at Object.value [as .coffee] (/Applications/Atom.app/Contents/Resources/app/src/compile-cache.js:239:29)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (Applications/Atom.app/Contents/Resources/app/static/index.js:47:45)
    at require (/Applications/Atom.app/Contents/Resources/app/src/native-compile-cache.js:66:33)
    at Object.<anonymous> (/Users/elenaglassman/Gitrepos/examplify/lib/examplify.coffee:10:22)
    at Object.<anonymous> (/Users/elenaglassman/Gitrepos/examplify/lib/examplify.coffee:1:1)
    at Module.get_Module._compile (/Applications/Atom.app/Contents/Resources/app/src/native-compile-cache.js:106:36)
    at Object.value [as .coffee] (/Applications/Atom.app/Contents/Resources/app/src/compile-cache.js:239:29)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (Applications/Atom.app/Contents/Resources/app/static/index.js:47:45)
    at require (internal/module.js:20:19)
    at customRequire (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:96:26)
    at Package.module.exports.Package.requireMainModule (/Applications/Atom.app/Contents/Resources/app/src/package.js:887:35)
    at Package.module.exports.Package.activateNow (/Applications/Atom.app/Contents/Resources/app/src/package.js:242:22)
    at /Applications/Atom.app/Contents/Resources/app/src/package.js:968:31
    at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:20)
    at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:34)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:246:26)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:65)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:166:25)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchContextMenuCommand (/Applications/Atom.app/Contents/Resources/app/src/atom-environment.js:1320:34)

Commands

     -0:17.2.0 examplify:make-example-code (span.syntax--markup.syntax--underline.syntax--link.syntax--https.syntax--hyperlink)

Non-Core Packages

examplify 0.0.0 
java undefined 

suggested I add a line I'd already added, added it again

public class SmallScoop {
  
  public static void main(String[] args) {
    
    SSLSocketFactory factory = context.getSocketFactory();
    SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
    socket.setSoTimeout(10000);
    socket.startHandshake();
    socket.startHandshake();
    socket.close();
    
  }
  
}

What's the difference between these two classes?

In suggester/suggestion.coffee:

module.exports.DeclarationSuggestion = class DeclarationSuggestion

  constructor: (name, type, symbol) ->
    @name = name
    @type = type
    @symbol = symbol

  getName: ->
    @name

  getType: ->
    @type

  getSymbol: ->
    @symbol

versus

in error/missing-declaration.coffee

module.exports.MissingDeclarationError = class MissingDeclarationError

  constructor: (symbol) ->
    @symbol = symbol

  getSymbol: ->
    @symbol

Automatically include `import` statements for imported class and method symbols

Given a snippet that has an undefined symbol (like ArrayList here),

public class Example {
    public static void main(String[] args) {
        ArrayList<String> stringList = new ArrayList<String>();
    }
}

Search through the original code from which the snippet was made, and find the line with the import statement that defined that symbol. Add this line to the code example, so that it looks like:

import java.util.ArrayList;

public class Example {
    public static void main(String[] args) {
        ArrayList<String> stringList = new ArrayList<String>();
    }
}

assuming that ArrayList was originally imported from java.util.

Tools

Detect an undefined symbol using our existing def-use analysis. Then resolve which imports define it. I'm not sure the best way to do this. One way is to search through the import statements by visiting the parse tree, and just look for one that defines that symbol.

iterate on study protocol

Baseline: do by hand, with two Atom code editing windows with built-in Java compiler [check in, give survey] + manual clean-up [check in again, give survey]
vs.
CodeScoop [check in, give survey] + manual clean-up [check in again, give survey]

Measurements: edits, compilation errors, time, subjective sense of agency

error while creating socket example

Uncaught TypeError: Cannot read property 'getStubSpecs' of null
/Users/freshaccount/Gitrepos/examplify/lib/suggester/instance-stub-suggester.coffee:38
Hide Stack Trace
TypeError: Cannot read property 'getStubSpecs' of null
    at InstanceStubSuggester.module.exports.InstanceStubSuggester.InstanceStubSuggester.getSuggestions (/Users/freshaccount/Gitrepos/examplify/lib/suggester/instance-stub-suggester.coffee:38:32)
    at ExampleController.module.exports.ExampleController.ExampleController.getSuggestions (/Users/freshaccount/Gitrepos/examplify/lib/example-controller.coffee:159:40)
    at ExampleController.module.exports.ExampleController.ExampleController.onPropertyChanged (/Users/freshaccount/Gitrepos/examplify/lib/example-controller.coffee:190:24)
    at ExampleModel.module.exports.ExampleModel.ExampleModel.notifyObservers (/Users/freshaccount/Gitrepos/examplify/lib/model/example-model.coffee:116:16)
    at ExampleModel.module.exports.ExampleModel.ExampleModel.setErrorChoice (/Users/freshaccount/Gitrepos/examplify/lib/model/example-model.coffee:138:6)
    at HTMLDivElement.<anonymous> (/Users/freshaccount/Gitrepos/examplify/lib/view/example-view.coffee:339:18)
    at HTMLDivElement.dispatch (/Users/freshaccount/Gitrepos/examplify/node_modules/jquery/dist/jquery.js:5206:27)
    at HTMLDivElement.elemData.handle (/Users/freshaccount/Gitrepos/examplify/node_modules/jquery/dist/jquery.js:5014:28)
The error was thrown from the examplify package.

Aside from the duplicate handshake start, does this look like a reasonable example result to you? I cannot tell if it stopped prematurely

import javax.net.ssl.*;

public class SmallScoop {

  private static class Tm {

    public AnonymousClass1 chain = new AnonymousClass1();

    public AnonymousClass2 checkServerTrusted(java.security.cert.X509Certificate[] arg1, java.lang.String arg2) {
      return null;
    }

    public AnonymousClass3 getAcceptedIssuers() {
      return new AnonymousClass3();
    }

  }

  private static class AnonymousClass1 {
  }

  private static class AnonymousClass3 {
  }

  public static void main(String[] args) {

    SSLContext context = SSLContext.getInstance("TLS");
    context.init(null, new TrustManager[]{(new Tm())}, null);
    SSLSocketFactory factory = context.getSocketFactory();
    SSLSocket socket = (SSLSocket) factory.createSocket("woot.com", 443);
    socket.setSoTimeout(10000);
    socket.startHandshake();
    socket.startHandshake();
    socket.close();

  }

}

master does not build

Elenas-MacBook-Pro:examplify elenaglassman$ cd java/  # run this from the main directory
Elenas-MacBook-Pro:java elenaglassman$ ./build.sh
Note: tests/analysis_examples/Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: tests/scenarios/database-use/BookListing.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: tests/scenarios/polyglot-simple/Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
tests/scenarios/jsoup/CraigslistMonitor.java:1: error: package com.sun.mail.smtp does not exist
import com.sun.mail.smtp.SMTPTransport;
                        ^
tests/scenarios/jsoup/CraigslistMonitor.java:3: error: package org.apache.commons.lang does not exist
import org.apache.commons.lang.Validate;
                              ^
tests/scenarios/jsoup/CraigslistMonitor.java:4: error: package org.apache.commons.lang does not exist
import org.apache.commons.lang.StringUtils;
                              ^
tests/scenarios/jsoup/CraigslistMonitor.java:5: error: package org.jsoup.nodes does not exist
import org.jsoup.nodes.Document;
                      ^
tests/scenarios/jsoup/CraigslistMonitor.java:6: error: package org.jsoup.nodes does not exist
import org.jsoup.nodes.Element;
                      ^
tests/scenarios/jsoup/CraigslistMonitor.java:7: error: package org.jsoup does not exist
import org.jsoup.Jsoup;
                ^
tests/scenarios/jsoup/CraigslistMonitor.java:8: error: package org.jsoup.select does not exist
import org.jsoup.select.Elements;
                       ^
tests/scenarios/jsoup/CraigslistMonitor.java:22: error: package javax.mail does not exist
import javax.mail.Message;
                 ^
tests/scenarios/jsoup/CraigslistMonitor.java:23: error: package javax.mail does not exist
import javax.mail.MessagingException;
                 ^
tests/scenarios/jsoup/CraigslistMonitor.java:24: error: package javax.mail does not exist
import javax.mail.Session;
                 ^
tests/scenarios/jsoup/CraigslistMonitor.java:25: error: package javax.mail.internet does not exist
import javax.mail.internet.AddressException;
                          ^
tests/scenarios/jsoup/CraigslistMonitor.java:26: error: package javax.mail.internet does not exist
import javax.mail.internet.InternetAddress;
                          ^
tests/scenarios/jsoup/CraigslistMonitor.java:27: error: package javax.mail.internet does not exist
import javax.mail.internet.MimeMessage;
                          ^
tests/scenarios/jsoup/CraigslistMonitor.java:34: error: cannot find symbol
    public static void main(String[] args) throws IOException, MessagingException, AddressException {
                                                               ^
  symbol:   class MessagingException
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:34: error: cannot find symbol
    public static void main(String[] args) throws IOException, MessagingException, AddressException {
                                                                                   ^
  symbol:   class AddressException
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:49: error: cannot find symbol
        Document doc = Jsoup.parse(url, 3*1000);
        ^
  symbol:   class Document
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:49: error: cannot find symbol
        Document doc = Jsoup.parse(url, 3*1000);
                       ^
  symbol:   variable Jsoup
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:50: error: cannot find symbol
        Elements rows = doc.select("li.result-row");
        ^
  symbol:   class Elements
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:55: error: cannot find symbol
            Element row = (Element) rowsIterator.next();
            ^
  symbol:   class Element
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:55: error: cannot find symbol
            Element row = (Element) rowsIterator.next();
                           ^
  symbol:   class Element
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:66: error: cannot find symbol
            Element image = row.select("a.result-image.gallery").get(0);
            ^
  symbol:   class Element
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:97: error: cannot find symbol
            String titlePadded = title + StringUtils.repeat(" ", maxTitleLength - title.length());
                                         ^
  symbol:   variable StringUtils
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:98: error: cannot find symbol
            String pricePadded = priceString + StringUtils.repeat(" ", maxPriceLength - priceString.length());
                                               ^
  symbol:   variable StringUtils
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:99: error: cannot find symbol
            String linkPadded = link + StringUtils.repeat(" ", maxLinkLength - link.length());
                                       ^
  symbol:   variable StringUtils
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:119: error: cannot find symbol
        Session session = Session.getInstance(properties, null);
        ^
  symbol:   class Session
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:119: error: cannot find symbol
        Session session = Session.getInstance(properties, null);
                          ^
  symbol:   variable Session
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:121: error: cannot find symbol
        MimeMessage message = new MimeMessage(session);
        ^
  symbol:   class MimeMessage
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:121: error: cannot find symbol
        MimeMessage message = new MimeMessage(session);
                                  ^
  symbol:   class MimeMessage
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:122: error: cannot find symbol
        message.setFrom(new InternetAddress(username));
                            ^
  symbol:   class InternetAddress
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:123: error: package Message does not exist
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(destination, false));
                                     ^
tests/scenarios/jsoup/CraigslistMonitor.java:123: error: cannot find symbol
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(destination, false));
                                                        ^
  symbol:   variable InternetAddress
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:128: error: cannot find symbol
        SMTPTransport transport = (SMTPTransport) session.getTransport("smtps");
        ^
  symbol:   class SMTPTransport
  location: class CraigslistMonitor
tests/scenarios/jsoup/CraigslistMonitor.java:128: error: cannot find symbol
        SMTPTransport transport = (SMTPTransport) session.getTransport("smtps");
                                   ^
  symbol:   class SMTPTransport
  location: class CraigslistMonitor
Note: tests/scenarios/jsoup/CraigslistMonitor.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
33 errors

uncaught error when exemplifying Server (Uncaught Error: Cannot decorate a destroyed marker)

Uncaught Error: Cannot decorate a destroyed marker
/private/var/folders/rg/zpx7wc451jg1611kk5x0n0rc0000gp/T/AppTranslocation/800A794A-6E94-4616-A0D8-DF49D69EACDC/d/Atom.app/Contents/Resources/app.asar/src/decoration-manager.js:202
Hide Stack Trace
Error: Cannot decorate a destroyed marker
    at DecorationManager.module.exports.DecorationManager.decorateMarker (/private/var/folders/rg/zpx7wc451jg1611kk5x0n0rc0000gp/T/AppTranslocation/800A794A-6E94-4616-A0D8-DF49D69EACDC/d/Atom.app/Contents/Resources/app.asar/src/decoration-manager.js:192:17)
    at TextEditor.module.exports.TextEditor.decorateMarker (/private/var/folders/rg/zpx7wc451jg1611kk5x0n0rc0000gp/T/AppTranslocation/800A794A-6E94-4616-A0D8-DF49D69EACDC/d/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1689:37)
    at ExampleView.module.exports.ExampleView.ExampleView._addResolutionWidget (/Users/freshaccount/Gitrepos/examplify/lib/view/example-view.coffee:339:17)
    at ExampleView.module.exports.ExampleView.ExampleView.update (/Users/freshaccount/Gitrepos/examplify/lib/view/example-view.coffee:85:8)
    at ExampleView.module.exports.ExampleView.ExampleView.onPropertyChanged (/Users/freshaccount/Gitrepos/examplify/lib/view/example-view.coffee:65:8)
    at ExampleModel.module.exports.ExampleModel.ExampleModel.notifyObservers (/Users/freshaccount/Gitrepos/examplify/lib/model/example-model.coffee:116:16)
    at ExampleModel.module.exports.ExampleModel.ExampleModel.onPropertyChanged (/Users/freshaccount/Gitrepos/examplify/lib/model/example-model.coffee:90:6)
    at RangeSet.module.exports.RangeSet.RangeSet.notifyObservers (/Users/freshaccount/Gitrepos/examplify/lib/model/range-set.coffee:36:16)
    at RangeSet.module.exports.RangeSet.RangeSet.onPropertyChanged (/Users/freshaccount/Gitrepos/examplify/lib/model/range-set.coffee:29:6)
    at Array.array.notifyObservers (/Users/freshaccount/Gitrepos/examplify/lib/model/observable-array.coffee:17:16)
    at Array.array.push (/Users/freshaccount/Gitrepos/examplify/lib/model/observable-array.coffee:36:6)
    at atom-workspace.subscriptions.add.atom.commands.add.examplify:add-selection-to-example (/Users/freshaccount/Gitrepos/examplify/lib/examplify.coffee:42:36)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/private/var/folders/rg/zpx7wc451jg1611kk5x0n0rc0000gp/T/AppTranslocation/800A794A-6E94-4616-A0D8-DF49D69EACDC/d/Atom.app/Contents/Resources/app.asar/src/command-registry.js:259:29)
    at CommandRegistry.handleCommandEvent (/private/var/folders/rg/zpx7wc451jg1611kk5x0n0rc0000gp/T/AppTranslocation/800A794A-6E94-4616-A0D8-DF49D69EACDC/d/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:59)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (/private/var/folders/rg/zpx7wc451jg1611kk5x0n0rc0000gp/T/AppTranslocation/800A794A-6E94-4616-A0D8-DF49D69EACDC/d/Atom.app/Contents/Resources/app.asar/src/command-registry.js:160:19)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchContextMenuCommand (/private/var/folders/rg/zpx7wc451jg1611kk5x0n0rc0000gp/T/AppTranslocation/800A794A-6E94-4616-A0D8-DF49D69EACDC/d/Atom.app/Contents/Resources/app.asar/src/atom-environment.js:1170:28)
    at EventEmitter.outerCallback (/private/var/folders/rg/zpx7wc451jg1611kk5x0n0rc0000gp/T/AppTranslocation/800A794A-6E94-4616-A0D8-DF49D69EACDC/d/Atom.app/Contents/Resources/app.asar/src/application-delegate.js:333:25)
    at emitThree (events.js:116:13)
    at EventEmitter.emit (events.js:194:7)

When I added a new ServerSocket

Support multiple data replacements on the same line

Currently, multiple replacements works if you choose the later arguments first and then move on to earlier arguments. It doesn't work if you choose earlier arguments first (the labels and replacements get all jumbled---red marks appear in the wrong place and the replacements blend together).

Insert data for complex data types

We currently offer two ways to define undefined symbols: by including the code that defines it, or by substituting in the concrete value of that variable.

This substitution works fine for primitive data types. For example, changing

int i = j + 1;

to

int i = 1 + 1;

after it was detected that j held the value of 1 during some execution.

This doesn't work well when we want to substitute in concrete data for complex data types. For example, if we have a line that says

String title = book.getTitle()

what concrete data could we set book to? There are at least two options:

Option 1

The first option: find a call to the constructor of that object somewhere in the dynamic execution history of that variable. Put that constructor right above the line where the undefined symbol appears:

Book book = new Book("Moby Dick", 423);  // This line is added
String title = book.getTitle();

While this works well when all of the arguments to the constructor are primitive data types, it might get complex when some of the arguments are complex data types.

Option 2

The second option: create a mock class that returns just the values accessed during a recent execution of the program, and append it to the top of the program.

class Book {
    public String getTitle() { return "Moby Dick"; }
}

This has the benefit of ripping out entire classes that might contain irrelevant details. We might actually want to support both methods.

This option has the disadvantage that if an object returns a complex data type from one of its method call, that complex data type will also need a mock created for it. There might be a simple recursive solution to this for the typical case.

Tools

For option 1, for simple cases, it's probably sufficient to just use dynamic execution tracing tools that we've already used. Given an undefined type, just find all lines where a variable of that type is assigned. Save a reference to that line and offer it as an option to the user.

For option 2, use a parse tree with def-use analysis results to find all lines where a property or method is getting called on an object symbol. Then look at the results from dynamic execution of what the property or method evaluates to at that time. Create a list of the methods and properties accessed and the values they returned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.