Giter Club home page Giter Club logo

jetbrains-practice-task's Introduction

Anti-copy-paster

Test task for JetBrains practice

Description

  • IntelliJ IDEA plugin which can show messages about an abstract syntax tree of selected code and warn if user wants to copy-paste.
  • When user runs plugin using a keyboard combination or toolbar button, ASTInfoMessageAction.actionPerformed is invoked. That method gets selected code from an editor, creates PSI file and runs recursiveASTWalking, which traverses AST using DFS and constructs record for info message.
  • InitModuleComponent.projectOpened is used such as an entry point. It setups MyEditorTextInsertHandler for handling editor-paste events. When it occurs, doExecute is called, and if clipboard isn't empty it shows warning.

TODO

  • Add unit tests
  • Think about using MVC pattern
  • Add smart analysis of pasting code (is it actually user's code, should it be moved to separate method)
  • Upgrade UI

Troubleshooting/Problems

  • Due to intellij-sdk docs Services should be used instead of Component, and projectOpened method is deprecated. But I don't actually understand where should I setup event handlers for editor, because here it is declared in class, which generally has no semantic connection to it.
  • MyEditorTextInsertHandler should implement (in order to avoid IDE fatal errors) EditorTextInsertHandler interface, which uses deprecated in Java Producer<Transferable>.
  • Built-in ASTNode's have all methods to iterate it in tree traversal order, but in fact body-nodes of if-conditions/loops/etc aren't a children of its command-node(am I wrong?). I've hardcoded nesting of blocks with curly braces, but it should be fixed in future.

jetbrains-practice-task's People

Contributors

smirnovoleg avatar

Watchers

 avatar

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.