Coder Social home page Coder Social logo

visibilitydeductor's Introduction

VisibilityDeductor

Build status Coverage Status License

Many modern programming languages do not have visibility specifiers (a.k.a access specifiers) such as public, private, or protected. However, even though they can not be marked as private at language level, some methods or classes in software libraries are only meant for the internal use and are not supposed to be used by clients. For the tools that analyse the API of software libraries, it can be useful to "infer" the visibility of methods or classes even if it is not defined explicitly. This repository contains a simple package that can deduce the visibility of packages, classes, and methods in Pharo programming language.

How does it work?

Packages that can be considered private

  • Test packages - contain unit tests and mock classes used for testing. They are not meant to be reused by clients.
    • When split by -, the package name contains the word Test or Tests (e.g., Files-Tests, Fuel-Tests-Core)
  • Example packages - contain examples of how to use specific functionality. Examples only exist for demonstration purposes and are not meant to be reused.
    • Package name ends with -Example or -Examples (e.g., Athens-Examples, Clap-Examples)
  • Baseline packages - define the baselines of project (specify which packages belong to the project and how to load the dependencies).
    • Package name begins with BaselineOf (e.g., BaselineOfBasicTools)
  • Help packages - define documentation pages
    • Package name ends with -Help (e.g., Pharo-Help, FreeType-Help)

Classes that can be considered private

  • Classes that belong to a package which can be considered private
  • Test classes - define unit tests (note that tests classes may be located outside test packages)
    • Class inherits from TestCase
  • Example classes - contain examples of how to use specific functionality
    • Class name begins or ends with a word Example (e.g., CheckBoxExample, ExampleSlotWithState)
  • Baseline classes - classes that define the baselines projects
    • Class inherits from BaselineOf
  • Help classes - define documentation pages
    • Class inherits from CustomHelp or CustomHelp2

Methods that can be considered private

  • Method that belong to a class which can be considered private
  • Methods that belong to a private protocol
    • Protocol of the method contains a substring private (e.g., private, private - primitives, evaluating-private)
  • Example methods - contain examples of how to use specific functionality
    • Method name begins with example or ends with either Example or Example* where * represents a number (e.g. examplePrintf, example42, annotationExample3, menuActivationExample)

How to install it?

To install VisibilityDeductor, go to the Playground (Ctrl+OW) in your Pharo image and execute the following Metacello script (select it and press Do-it button or Ctrl+D):

Metacello new
  baseline: 'VisibilityDeductor';
  repository: 'github://olekscode/VisibilityDeductor/src';
  load.

How to depend on it?

If you want to add a dependency on VisibilityDeductor to your project, include the following lines into your baseline method:

spec
  baseline: 'VisibilityDeductor'
  with: [ spec repository: 'github://olekscode/VisibilityDeductor/src' ].

If you are new to baselines and Metacello, check out the Baselines tutorial on Pharo Wiki.

How to use it?

deductor := VisibilityDeductor new.

deductor isMethodPublic: Collection >> #do:. "true"
deductor isMethodPrivate: Collection >> #do:. "false"
deductor isMethodPrivate: Collection >> #emptyCheck. "true (because it's in a 'private' protocol)"
deductor isMethodPrivate: CollectionTest >> #testCopyWithoutDuplicates. "true"
deductor isMethodPrivate: StringTest >> #setUp. "true"

deductor isClassPublic: AthensSurfaceExamples. "false"
deductor isClassPrivate: AthensSurfaceExamples. "true"
deductor isClassPrivate: AnnouncementsHelp "true".

deductor isPackagePublic: 'RPackage-Tests' asPackage. "false"
deductor isPackagePrivate: 'RPackage-Tests' asPackage. "true"

visibilitydeductor's People

Contributors

olekscode avatar

Watchers

James Cloos avatar  avatar  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.