Skip to content

Commit

Permalink
Merge branch 'dev_tsplugin' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
maybeec committed Sep 14, 2020
2 parents 54cab73 + 7c9768a commit f95dc1f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
8 changes: 4 additions & 4 deletions cobigen/cobigen-tsplugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>tsplugin</artifactId>
<name>CobiGen - TypeScript Plug-in</name>
<version>2.4.4</version>
<version>7.0.0</version>
<packaging>jar</packaging>
<description>CobiGen - TypeScript Plug-in</description>

Expand All @@ -26,12 +26,12 @@
<dependency>
<groupId>com.devonfw.cobigen</groupId>
<artifactId>core-api</artifactId>
<version>[6.1.2,)</version>
<version>[7.0.0,)</version>
</dependency>
<dependency>
<groupId>com.devonfw.cobigen</groupId>
<artifactId>core</artifactId>
<version>[6.1.2,)</version>
<version>[7.0.0,)</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -50,7 +50,7 @@
<dependency>
<groupId>com.devonfw.cobigen</groupId>
<artifactId>core-test</artifactId>
<version>5.0.0</version>
<version>[7.0.0,)</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,35 @@

import java.util.List;

import com.devonfw.cobigen.api.annotation.Activation;
import com.devonfw.cobigen.api.extension.GeneratorPluginActivator;
import com.devonfw.cobigen.api.extension.Merger;
import com.devonfw.cobigen.api.extension.TriggerInterpreter;
import com.devonfw.cobigen.tsplugin.inputreader.TypeScriptInputReader;
import com.devonfw.cobigen.tsplugin.merger.TypeScriptMerger;
import com.google.common.collect.Lists;

/**
* TypeScript Plug-in Activator to be registered in the PluginRegistry of CobiGen.
*/
@Activation(byFileExtension = { TypeScriptInputReader.VALID_EXTENSION },
byMergeStrategy = { TypeScriptPluginActivator.TSMERGE, TypeScriptPluginActivator.TSMERGE_OVERRIDE })
public class TypeScriptPluginActivator implements GeneratorPluginActivator {

/**
* Defines the trigger type
*/

/** Merger type for typescript files (prefer patch) */
static final String TSMERGE_OVERRIDE = "tsmerge_override";

/** Merger type for typescript files (prefer base) */
static final String TSMERGE = "tsmerge";

/** Defines the trigger type */
private static final String TRIGGER_TYPE = "typescript";

@Override
public List<Merger> bindMerger() {
List<Merger> merger = Lists.newLinkedList();
merger.add(new TypeScriptMerger("tsmerge", false));
merger.add(new TypeScriptMerger("tsmerge_override", true));
merger.add(new TypeScriptMerger(TSMERGE, false));
merger.add(new TypeScriptMerger(TSMERGE_OVERRIDE, true));
return merger;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.devonfw.cobigen.tsplugin;

import com.devonfw.cobigen.api.annotation.ReaderPriority;
import com.devonfw.cobigen.api.extension.InputReader;
import com.devonfw.cobigen.api.extension.MatcherInterpreter;
import com.devonfw.cobigen.api.extension.Priority;
import com.devonfw.cobigen.api.extension.TriggerInterpreter;
import com.devonfw.cobigen.tsplugin.inputreader.TypeScriptInputReader;
import com.devonfw.cobigen.tsplugin.matcher.TypeScriptMatcher;

/**
* {@link TriggerInterpreter} implementation of a Swagger Interpreter
*/
@ReaderPriority(Priority.LOW)
public class TypeScriptTriggerInterpreter implements TriggerInterpreter {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
*/
public class TypeScriptInputReader implements InputReader {

/** Valid file extension */
public static final String VALID_EXTENSION = "ts";

/** Logger instance. */
private static final Logger LOG = LoggerFactory.getLogger(TypeScriptInputReader.class);

Expand Down Expand Up @@ -135,9 +138,6 @@ public boolean isValidInput(Object input) {
response = br.readLine();

return Boolean.parseBoolean(response);
} catch (NullPointerException e) {
return false;

} catch (IOException e) {
connectionExc.handle(e);
}
Expand Down Expand Up @@ -282,8 +282,8 @@ public Object read(Path path, Charset inputCharset, Object... additionalArgument
}

@Override
public Boolean isMostLikelyReadable(Path path) {
return isValidInput(path);
public boolean isMostLikelyReadable(Path path) {
return path.toFile().isFile() && path.toString().endsWith("." + VALID_EXTENSION);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion documentation/master-cobigen.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DISCLAIMER: All Cobigen plugins are compatible with the latest release of Devonf
* CobiGen v7.0.0
* CobiGen - Java Plug-in v7.0.0
* CobiGen - XML Plug-in v7.0.0
* CobiGen - TypeScript Plug-in v2.4.4
* CobiGen - TypeScript Plug-in v7.0.0
* CobiGen - Property Plug-in v2.1.0
* CobiGen - Text Merger v2.1.0
* CobiGen - JSON Plug-in v7.0.0
Expand Down

0 comments on commit f95dc1f

Please sign in to comment.