Skip to content

Commit

Permalink
Merge branch 'release/1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
sanhozay committed Feb 15, 2018
2 parents d9cfc57 + bd91f87 commit 9573162
Show file tree
Hide file tree
Showing 42 changed files with 204 additions and 117 deletions.
21 changes: 21 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing

## Pull Requests

Pull requests are welcome but please contact the project maintainer to discuss your plans before starting significant pieces of work.

## Code Style

Aim to follow the coding style currently in use in the project. Broadly speaking this is based on [Sun's Java coding standards](http://www.oracle.com/technetwork/java/codeconventions-150003.pdf).

If you don't want to read all that: it's 4 spaces for indentation, K&R style. Prefer explict imports over wildcards in Java code and add JavaDoc where it might be useful.

If you use your IDE to format automatically, please ensure that it doesn't make widespread changes to the existing code. If in doubt, turn it off.

## Version control

Commit often but group related changes into a single commit. An ideal commit should represent one idea or step in the process toward implementing a feature.

Commit messages need not be verbose, but please make an effort. Messages like "fixed bug" are not helpful.

The project `.gitignore` file has exclusions for Gradle builds only. If you are using an IDE, please ensure that your global gitignore file is configured to exclude any project files and build directories that it creates.
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Versions

Please complete all of the following:

CLGen version :
Java version :
O/S :
O/S version :

## Problem Description

Please try and describe all steps to reproduce the problem.
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Change Description

Please include issue numbers where applicable, e.g. (Issue #0).
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
.gradle/
build/

# Eclipse
.classpath
.project
.settings
bin/

# Ignore samples outputs
# Samples outputs
samples/**/*.dot
samples/**/*.pdf
samples/**/*.png
Expand Down
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: java
branches:
only:
- master
- develop
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
47 changes: 47 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![GPL3](https://img.shields.io/badge/license-GPL3-%23a42e2b.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
[![Travis branch](https://img.shields.io/travis/sanhozay/CLGen/master.svg?label=master)](https://travis-ci.org/sanhozay/CLGen)
[![Travis branch](https://img.shields.io/travis/sanhozay/CLGen/develop.svg?label=develop)](https://travis-ci.org/sanhozay/CLGen)

# CLGen

CLGen is a tool for generating Flightgear checklists. Input is in the form of a
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'antlr'
apply plugin: 'groovy'
apply plugin: 'java'

project.version = '1.2.1'
project.version = '1.2.2'

defaultTasks 'build'

Expand Down
2 changes: 1 addition & 1 deletion clgen
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
java -jar $(dirname $0)/build/libs/CLGen-1.2.1.jar $*
java -jar $(dirname $0)/build/libs/CLGen-1.2.2.jar $*
2 changes: 1 addition & 1 deletion clgen.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
java -jar %~dp0/build/libs/CLGen-1.2.1.jar %*
java -jar %~dp0/build/libs/CLGen-1.2.2.jar %*
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue May 02 21:35:31 BST 2017
#Thu Feb 15 16:13:06 GMT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip
6 changes: 3 additions & 3 deletions src/main/java/org/flightgear/clgen/CLGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*
* @author Richard Senior
*/
public class CLGen {
class CLGen {

private ErrorListener errorListener;
private final ParseTreeWalker walker = new ParseTreeWalker();
Expand All @@ -57,7 +57,7 @@ public class CLGen {
*
* @param input the path to the input file
*/
public CLGen(final Path input) {
private CLGen(final Path input) {
this.input = input;
}

Expand Down Expand Up @@ -160,7 +160,7 @@ private void run() throws IOException, GeneratorException {
/*
* Parses the input, producing a parse tree as output.
*/
private SpecificationContext parse(final CommonTokenStream tokenStream) throws IOException {
private SpecificationContext parse(final CommonTokenStream tokenStream) {
CLGenParser parser = new CLGenParser(tokenStream);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/flightgear/clgen/CLGenProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ private CLGenProperties() {
try (InputStream in = ClassLoader.getSystemResourceAsStream(PROPERTIES_FILE)) {
properties = new Properties();
properties.load(in);
} catch (IOException e) {}
} catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
}

/**
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/org/flightgear/clgen/ast/Checklist.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,8 @@ public boolean equals(final Object obj) {
return false;
Checklist other = (Checklist)obj;
if (title == null) {
if (other.title != null)
return false;
} else if (!title.equalsIgnoreCase(other.title))
return false;
return true;
return other.title == null;
} else return title.equalsIgnoreCase(other.title);
}

}
2 changes: 1 addition & 1 deletion src/main/java/org/flightgear/clgen/ast/Visitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @author Richard Senior
*/
@SuppressWarnings("javadoc")
@SuppressWarnings({"javadoc", "EmptyMethod"})
public interface Visitor {

void enter(final AbstractSyntaxTree ast);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public abstract class AbstractBinding implements Visitable {

protected Condition condition;
Condition condition;

/**
* Gets the condition applicable to the binding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
public class ValueBinding extends AbstractBinding {

protected final Symbol symbol;
protected Object value = null;
private final Symbol symbol;
private final Object value;

/**
* Constructs a value binding with a symbol and value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class AbstractCondition implements Visitable {
*
* @return the type of the condition
*/
public Type getType() {
Type getType() {
return Type.NULL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void addChild(final AbstractCondition child) {
}

@Override
public Type getType() {
Type getType() {
if (lhs.getType() == Type.NULL && rhs.getType() == Type.NULL)
return Type.NULL;
if (rhs.getType() != Type.NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public AbstractCondition getOperand() {
}

@Override
public Type getType() {
Type getType() {
return Type.BOOL;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/flightgear/clgen/backend/DotVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void enter(final AbstractSyntaxTree ast) {
.append(" pad=0.5;\n")
.append(" ranksep=0.35;\n");
if (ast.getProject() != null)
dot.append(" label=\"\\" + "n" + ast.getProject() + "\";\n");
dot.append(" label=\"\\" + "n").append(ast.getProject()).append("\";\n");
dot.append(" node [fontsize=12];\n")
.append(" node [fontcolor=white,fontname=\"helvetica-bold\"];\n")
.append(" node [shape=Mrecord,width=2.75,style=filled];\n");
Expand Down Expand Up @@ -93,7 +93,7 @@ public void enter(final Checklist checklist) {
hue, quote(checklist.getTitle())
);
dot.append(s);
edges.append(" " + quote(checklist.getTitle()));
edges.append(" ").append(quote(checklist.getTitle()));
int totalChecks = 0;
for (Page page : checklist.getPages())
for (Check check : page.getChecks())
Expand Down Expand Up @@ -126,7 +126,7 @@ public void enter(final Check check) {
index++, escape(check.getItem().getName())
));
for (String value : check.getAdditionalValues())
sb.append("\n" + escape(value));
sb.append("\n").append(escape(value));
sb.append(String.format("|%s}\"];\n",
escape(check.getState().getName())
));
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/flightgear/clgen/backend/PdfVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void enter(final Check check) {
try {
String i = check.getItem() != null ? nvl(check.getItem().getName()) : "";
String s = check.getState() != null ? nvl(check.getState().getName()) : "";
String line = String.format("%s %s %s", i, dots(i, s, textWidth(P) - 2), s);
String line = String.format("%s %s %s", i, dots(i, s, normalTextWidth() - 2), s);
Paragraph p = new Paragraph(line, empty(s) ? B : P);
p.setSpacingBefore(6.0f);
document.add(p);
Expand All @@ -127,9 +127,9 @@ public void enter(final Check check) {

// Other methods

private int textWidth(final Font font) {
BaseFont b = font.getCalculatedBaseFont(false);
float w = b.getWidthPoint(".", font.getSize());
private int normalTextWidth() {
BaseFont b = PdfVisitor.P.getCalculatedBaseFont(false);
float w = b.getWidthPoint(".", PdfVisitor.P.getSize());
return (int)Math.floor((document.getPageSize().getWidth() - MARGIN * 2) / w);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/flightgear/clgen/backend/UsageVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
public class UsageVisitor extends AbstractVisitor {

private class ItemUsage {
public int count = 0;
public final Map<String, Integer> stateUsages = new TreeMap<>();
int count = 0;
final Map<String, Integer> stateUsages = new TreeMap<>();
}

private final Map<String, ItemUsage> itemUsages = new TreeMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.flightgear.clgen.backend;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -55,8 +56,7 @@ public String getXml() {
* @param patterns a variable argument list of patterns
*/
public void addBreakPatterns(final String ... patterns) {
for (String pattern : patterns)
breakPatterns.add(pattern);
Collections.addAll(breakPatterns, patterns);
}

}
Loading

0 comments on commit 9573162

Please sign in to comment.