2.0.4 Fixed NullPointerException with Kotlin project.
+ Fixed IllegalArgumentException: No enum constant com.zhaow.restful.method.HttpMethod.HEAD
+ Supported Kotlin 1.2 level.
+
2.0.3 Improvements in navigate service(url), auto pasted copied http url to from clipboard.
+ Bug fixed.
+
2.0.2 Match mapped URLs for Controllers without @RequestMapping annotations;
+ Supported mapped URLs for Controllers extended supper Object with @RequestMapping annotations.
+ Added Popup Menus ( "Copy Full Url", "Jump to Source") for service nodes.
+
2.0.4 Fixed NullPointerException with Kotlin project.
- Fixed IllegalArgumentException: No enum constant com.zhaow.restful.method.HttpMethod.HEAD
- Supported Kotlin 1.2 level.
-
2.0.3 Improvements in navigate service(url), auto pasted copied http url to from clipboard.
- Bug fixed.
-
2.0.2 Match mapped URLs for Controllers without @RequestMapping annotations;
- Supported mapped URLs for Controllers extended supper Object with @RequestMapping annotations.
- Added Popup Menus ( "Copy Full Url", "Jump to Source") for service nodes.
-
- To navigate any rest service in the editor quickly, press &shortcut:GotoService;
- (Navigate | Rest Service)
- and start typing the url of the service. Choose the item from a drop-down list that appears.
-
-
-
-
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..8f458d8
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,2 @@
+rootProject.name = 'RestfulToolkit'
+
diff --git a/src/java/com/zhaow/restful/common/ChineseUtill.java b/src/java/com/zhaow/restful/common/ChineseUtill.java
deleted file mode 100644
index ede117a..0000000
--- a/src/java/com/zhaow/restful/common/ChineseUtill.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.zhaow.restful.common;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class ChineseUtill {
-
- private static boolean isChinese(char c) {
- Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
- if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
- || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
- || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
- || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
- || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
- || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
- return true;
- }
- return false;
- }
-
- public static boolean isMessyCode(String strName) {
- Pattern p = Pattern.compile("\\s*|\t*|\r*|\n*");
- Matcher m = p.matcher(strName);
- String after = m.replaceAll("");
- String temp = after.replaceAll("\\p{P}", "");
- char[] ch = temp.trim().toCharArray();
- float chLength = 0 ;
- float count = 0;
- for (int i = 0; i < ch.length; i++) {
- char c = ch[i];
- if (!Character.isLetterOrDigit(c)) {
- if (!isChinese(c)) {
- count = count + 1;
- }
- chLength++;
- }
- }
- float result = count / chLength ;
- if (result > 0.4) {
- return true;
- } else {
- return false;
- }
- }
-
-
- public static String toChinese(Object msg){
-// String tempMsg = TransformUtils.toString(msg) ;
- String tempMsg = msg.toString() ;
- if(isMessyCode(tempMsg)){
- try {
- return new String(tempMsg.getBytes("ISO8859-1"), "UTF-8");
- } catch (Exception e) {
- }
- }
- return tempMsg ;
- }
-}
\ No newline at end of file
diff --git a/src/java/com/zhaow/restful/common/spring/AntPathMatcher.java b/src/java/com/zhaow/restful/common/spring/AntPathMatcher.java
deleted file mode 100644
index ea8b0a1..0000000
--- a/src/java/com/zhaow/restful/common/spring/AntPathMatcher.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * Copyright 2002-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.zhaow.restful.common.spring;
-
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * {@link PathMatcher} implementation for Ant-style path patterns.
- *
- *
Part of this mapping code has been kindly borrowed from Apache Ant.
- *
- *
The mapping matches URLs using the following rules:
- *
- *
{@code ?} matches one character
- *
{@code *} matches zero or more characters
- *
{@code **} matches zero or more directories in a path
- *
{@code {spring:[a-z]+}} matches the regexp {@code [a-z]+} as a path variable named "spring"
- *
- *
- *
Examples
- *
- *
{@code com/t?st.jsp} — matches {@code com/test.jsp} but also
- * {@code com/tast.jsp} or {@code com/txst.jsp}
- *
{@code com/*.jsp} — matches all {@code .jsp} files in the
- * {@code com} directory
- *
com/**/test.jsp — matches all {@code test.jsp}
- * files underneath the {@code com} path
- *
org/springframework/**/*.jsp — matches all
- * {@code .jsp} files underneath the {@code org/springframework} path
- *
org/**/servlet/bla.jsp — matches
- * {@code org/springframework/servlet/bla.jsp} but also
- * {@code org/springframework/testing/servlet/bla.jsp} and {@code org/servlet/bla.jsp}
- *
{@code com/{filename:\\w+}.jsp} will match {@code com/test.jsp} and assign the value {@code test}
- * to the {@code filename} variable
- *
- *
- *
Note: a pattern and a path must both be absolute or must
- * both be relative in order for the two to match. Therefore it is recommended
- * that users of this implementation to sanitize patterns in order to prefix
- * them with "/" as it makes sense in the context in which they're used.
- *
- * @author Alef Arendsen
- * @author Juergen Hoeller
- * @author Rob Harrop
- * @author Arjen Poutsma
- * @author Rossen Stoyanchev
- * @author Sam Brannen
- * @since 16.07.2003
- */
-public class AntPathMatcher /*implements PathMatcher*/ {
-
- /** Default path separator: "/" */
- public static final String DEFAULT_PATH_SEPARATOR = "/";
-
- private static final int CACHE_TURNOFF_THRESHOLD = 65536;
-
- private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?\\}");
-
- private static final char[] WILDCARD_CHARS = { '*', '?', '{' };
-
- private String pathSeparator;
-
-// private PathSeparatorPatternCache pathSeparatorPatternCache;
-
- private boolean caseSensitive = true;
-
- private boolean trimTokens = false;
-
- private volatile Boolean cachePatterns;
-
- private final Map tokenizedPatternCache = new ConcurrentHashMap(256);
-
- final Map stringMatcherCache = new ConcurrentHashMap(256);
-
-
- /**
- * Create a new instance with the {@link #DEFAULT_PATH_SEPARATOR}.
- */
- public AntPathMatcher() {
- this.pathSeparator = DEFAULT_PATH_SEPARATOR;
-// this.pathSeparatorPatternCache = new PathSeparatorPatternCache(DEFAULT_PATH_SEPARATOR);
- }
- private void deactivatePatternCache() {
- this.cachePatterns = false;
- this.tokenizedPatternCache.clear();
- this.stringMatcherCache.clear();
- }
-
- public boolean match(String pattern, String path) {
- return doMatch(pattern, path, true, null);
- }
-
- /**
- * Actually match the given {@code path} against the given {@code pattern}.
- * @param pattern the pattern to match against
- * @param path the path String to test
- * @param fullMatch whether a full pattern match is required (else a pattern match
- * as far as the given base path goes is sufficient)
- * @return {@code true} if the supplied {@code path} matched, {@code false} if it didn't
- */
- protected boolean doMatch(String pattern, String path, boolean fullMatch, Map uriTemplateVariables) {
- if (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {
- return false;
- }
-
- String[] pattDirs = tokenizePattern(pattern);
- if (fullMatch && this.caseSensitive && !isPotentialMatch(path, pattDirs)) {
- return false;
- }
-
- String[] pathDirs = tokenizePath(path);
-
- int pattIdxStart = 0;
- int pattIdxEnd = pattDirs.length - 1;
- int pathIdxStart = 0;
- int pathIdxEnd = pathDirs.length - 1;
-
- // Match all elements up to the first **
- while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {
- String pattDir = pattDirs[pattIdxStart];
- if ("**".equals(pattDir)) {
- break;
- }
- if (!matchStrings(pattDir, pathDirs[pathIdxStart], uriTemplateVariables)) {
- return false;
- }
- pattIdxStart++;
- pathIdxStart++;
- }
-
- if (pathIdxStart > pathIdxEnd) {
- // Path is exhausted, only match if rest of pattern is * or **'s
- if (pattIdxStart > pattIdxEnd) {
- return (pattern.endsWith(this.pathSeparator) == path.endsWith(this.pathSeparator));
- }
- if (!fullMatch) {
- return true;
- }
- if (pattIdxStart == pattIdxEnd && pattDirs[pattIdxStart].equals("*") && path.endsWith(this.pathSeparator)) {
- return true;
- }
- for (int i = pattIdxStart; i <= pattIdxEnd; i++) {
- if (!pattDirs[i].equals("**")) {
- return false;
- }
- }
- return true;
- }
- else if (pattIdxStart > pattIdxEnd) {
- // String not exhausted, but pattern is. Failure.
- return false;
- }
- else if (!fullMatch && "**".equals(pattDirs[pattIdxStart])) {
- // Path start definitely matches due to "**" part in pattern.
- return true;
- }
-
- // up to last '**'
- while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {
- String pattDir = pattDirs[pattIdxEnd];
- if (pattDir.equals("**")) {
- break;
- }
- if (!matchStrings(pattDir, pathDirs[pathIdxEnd], uriTemplateVariables)) {
- return false;
- }
- pattIdxEnd--;
- pathIdxEnd--;
- }
- if (pathIdxStart > pathIdxEnd) {
- // String is exhausted
- for (int i = pattIdxStart; i <= pattIdxEnd; i++) {
- if (!pattDirs[i].equals("**")) {
- return false;
- }
- }
- return true;
- }
-
- while (pattIdxStart != pattIdxEnd && pathIdxStart <= pathIdxEnd) {
- int patIdxTmp = -1;
- for (int i = pattIdxStart + 1; i <= pattIdxEnd; i++) {
- if (pattDirs[i].equals("**")) {
- patIdxTmp = i;
- break;
- }
- }
- if (patIdxTmp == pattIdxStart + 1) {
- // '**/**' situation, so skip one
- pattIdxStart++;
- continue;
- }
- // Find the pattern between padIdxStart & padIdxTmp in str between
- // strIdxStart & strIdxEnd
- int patLength = (patIdxTmp - pattIdxStart - 1);
- int strLength = (pathIdxEnd - pathIdxStart + 1);
- int foundIdx = -1;
-
- strLoop:
- for (int i = 0; i <= strLength - patLength; i++) {
- for (int j = 0; j < patLength; j++) {
- String subPat = pattDirs[pattIdxStart + j + 1];
- String subStr = pathDirs[pathIdxStart + i + j];
- if (!matchStrings(subPat, subStr, uriTemplateVariables)) {
- continue strLoop;
- }
- }
- foundIdx = pathIdxStart + i;
- break;
- }
-
- if (foundIdx == -1) {
- return false;
- }
-
- pattIdxStart = patIdxTmp;
- pathIdxStart = foundIdx + patLength;
- }
-
- for (int i = pattIdxStart; i <= pattIdxEnd; i++) {
- if (!pattDirs[i].equals("**")) {
- return false;
- }
- }
-
- return true;
- }
-
- private boolean isPotentialMatch(String path, String[] pattDirs) {
- if (!this.trimTokens) {
- int pos = 0;
- for (String pattDir : pattDirs) {
- int skipped = skipSeparator(path, pos, this.pathSeparator);
- pos += skipped;
- skipped = skipSegment(path, pos, pattDir);
- if (skipped < pattDir.length()) {
- return (skipped > 0 || (pattDir.length() > 0 && isWildcardChar(pattDir.charAt(0))));
- }
- pos += skipped;
- }
- }
- return true;
- }
-
- private int skipSegment(String path, int pos, String prefix) {
- int skipped = 0;
- for (int i = 0; i < prefix.length(); i++) {
- char c = prefix.charAt(i);
- if (isWildcardChar(c)) {
- return skipped;
- }
- int currPos = pos + skipped;
- if (currPos >= path.length()) {
- return 0;
- }
- if (c == path.charAt(currPos)) {
- skipped++;
- }
- }
- return skipped;
- }
-
- private int skipSeparator(String path, int pos, String separator) {
- int skipped = 0;
- while (path.startsWith(separator, pos + skipped)) {
- skipped += separator.length();
- }
- return skipped;
- }
-
- private boolean isWildcardChar(char c) {
- for (char candidate : WILDCARD_CHARS) {
- if (c == candidate) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Tokenize the given path pattern into parts, based on this matcher's settings.
- *
Performs caching based on {@link #setCachePatterns}, delegating to
- * {@link #tokenizePath(String)} for the actual tokenization algorithm.
- * @param pattern the pattern to tokenize
- * @return the tokenized pattern parts
- */
- protected String[] tokenizePattern(String pattern) {
- String[] tokenized = null;
- Boolean cachePatterns = this.cachePatterns;
- if (cachePatterns == null || cachePatterns.booleanValue()) {
- tokenized = this.tokenizedPatternCache.get(pattern);
- }
- if (tokenized == null) {
- tokenized = tokenizePath(pattern);
- if (cachePatterns == null && this.tokenizedPatternCache.size() >= CACHE_TURNOFF_THRESHOLD) {
- // Try to adapt to the runtime situation that we're encountering:
- // There are obviously too many different patterns coming in here...
- // So let's turn off the cache since the patterns are unlikely to be reoccurring.
- deactivatePatternCache();
- return tokenized;
- }
- if (cachePatterns == null || cachePatterns.booleanValue()) {
- this.tokenizedPatternCache.put(pattern, tokenized);
- }
- }
- return tokenized;
- }
-
- /**
- * Tokenize the given path String into parts, based on this matcher's settings.
- * @param path the path to tokenize
- * @return the tokenized path parts
- */
- protected String[] tokenizePath(String path) {
- return StringUtils.tokenizeToStringArray(path, this.pathSeparator, this.trimTokens, true);
- }
-
- /**
- * one.Test whether or not a string matches against a pattern.
- * @param pattern the pattern to match against (never {@code null})
- * @param str the String which must be matched against the pattern (never {@code null})
- * @return {@code true} if the string matches against the pattern, or {@code false} otherwise
- */
- private boolean matchStrings(String pattern, String str, Map uriTemplateVariables) {
- return getStringMatcher(pattern).matchStrings(str, uriTemplateVariables);
- }
-
- /**
- * Build or retrieve an {@link AntPathStringMatcher} for the given pattern.
- *
The default implementation checks this AntPathMatcher's internal cache
- * (see {@link #setCachePatterns}), creating a new AntPathStringMatcher instance
- * if no cached copy is found.
- *
When encountering too many patterns to cache at runtime (the threshold is 65536),
- * it turns the default cache off, assuming that arbitrary permutations of patterns
- * are coming in, with little chance for encountering a recurring pattern.
- *
This method may be overridden to implement a custom cache strategy.
- * @param pattern the pattern to match against (never {@code null})
- * @return a corresponding AntPathStringMatcher (never {@code null})
- * @see #setCachePatterns
- */
- protected AntPathStringMatcher getStringMatcher(String pattern) {
- AntPathStringMatcher matcher = null;
- Boolean cachePatterns = this.cachePatterns;
- if (cachePatterns == null || cachePatterns.booleanValue()) {
- matcher = this.stringMatcherCache.get(pattern);
- }
- if (matcher == null) {
- matcher = new AntPathStringMatcher(pattern, this.caseSensitive);
- if (cachePatterns == null && this.stringMatcherCache.size() >= CACHE_TURNOFF_THRESHOLD) {
- // Try to adapt to the runtime situation that we're encountering:
- // There are obviously too many different patterns coming in here...
- // So let's turn off the cache since the patterns are unlikely to be reoccurring.
- deactivatePatternCache();
- return matcher;
- }
- if (cachePatterns == null || cachePatterns.booleanValue()) {
- this.stringMatcherCache.put(pattern, matcher);
- }
- }
- return matcher;
- }
-
- /**
- * Tests whether or not a string matches against a pattern via a {@link Pattern}.
- *
The pattern may contain special characters: '*' means zero or more characters; '?' means one and
- * only one character; '{' and '}' indicate a URI template pattern. For example /users/{user}.
- */
- protected static class AntPathStringMatcher {
-
- private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?\\}|[^/{}]|\\\\[{}])+?)\\}");
-
- private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
-
- private final Pattern pattern;
-
- private final List variableNames = new LinkedList();
-
- public AntPathStringMatcher(String pattern) {
- this(pattern, true);
- }
-
- public AntPathStringMatcher(String pattern, boolean caseSensitive) {
- StringBuilder patternBuilder = new StringBuilder();
- Matcher matcher = GLOB_PATTERN.matcher(pattern);
- int end = 0;
- while (matcher.find()) {
- patternBuilder.append(quote(pattern, end, matcher.start()));
- String match = matcher.group();
- if ("?".equals(match)) {
- patternBuilder.append('.');
- }
- else if ("*".equals(match)) {
- patternBuilder.append(".*");
- }
- else if (match.startsWith("{") && match.endsWith("}")) {
- int colonIdx = match.indexOf(':');
- if (colonIdx == -1) {
- patternBuilder.append(DEFAULT_VARIABLE_PATTERN);
- this.variableNames.add(matcher.group(1));
- }
- else {
- String variablePattern = match.substring(colonIdx + 1, match.length() - 1);
- patternBuilder.append('(');
- patternBuilder.append(variablePattern);
- patternBuilder.append(')');
- String variableName = match.substring(1, colonIdx);
- this.variableNames.add(variableName);
- }
- }
- end = matcher.end();
- }
- patternBuilder.append(quote(pattern, end, pattern.length()));
- this.pattern = (caseSensitive ? Pattern.compile(patternBuilder.toString()) :
- Pattern.compile(patternBuilder.toString(), Pattern.CASE_INSENSITIVE));
- }
-
- private String quote(String s, int start, int end) {
- if (start == end) {
- return "";
- }
- return Pattern.quote(s.substring(start, end));
- }
-
- /**
- * Main entry point.
- * @return {@code true} if the string matches against the pattern, or {@code false} otherwise.
- */
- public boolean matchStrings(String str, Map uriTemplateVariables) {
- Matcher matcher = this.pattern.matcher(str);
- if (matcher.matches()) {
- if (uriTemplateVariables != null) {
- // SPR-8455
- if (this.variableNames.size() != matcher.groupCount()) {
- throw new IllegalArgumentException("The number of capturing groups in the pattern segment " +
- this.pattern + " does not match the number of URI template variables it defines, " +
- "which can occur if capturing groups are used in a URI template regex. " +
- "Use non-capturing groups instead.");
- }
- for (int i = 1; i <= matcher.groupCount(); i++) {
- String name = this.variableNames.get(i - 1);
- String value = matcher.group(i);
- uriTemplateVariables.put(name, value);
- }
- }
- return true;
- }
- else {
- return false;
- }
- }
- }
-
-
- /**
- * The default {@link Comparator} implementation returned by
- * {@link #getPatternComparator(String)}.
- *
In order, the most "generic" pattern is determined by the following:
- *
- *
if it's null or a capture all pattern (i.e. it is equal to "/**")
- *
if the other pattern is an actual match
- *
if it's a catch-all pattern (i.e. it ends with "**"
- *
if it's got more "*" than the other pattern
- *
if it's got more "{foo}" than the other pattern
- *
if it's shorter than the other pattern
- *
- */
- protected static class AntPatternComparator implements Comparator {
-
- private final String path;
-
- public AntPatternComparator(String path) {
- this.path = path;
- }
-
- /**
- * Compare two patterns to determine which should match first, i.e. which
- * is the most specific regarding the current path.
- * @return a negative integer, zero, or a positive integer as pattern1 is
- * more specific, equally specific, or less specific than pattern2.
- */
- @Override
- public int compare(String pattern1, String pattern2) {
- PatternInfo info1 = new PatternInfo(pattern1);
- PatternInfo info2 = new PatternInfo(pattern2);
-
- if (info1.isLeastSpecific() && info2.isLeastSpecific()) {
- return 0;
- }
- else if (info1.isLeastSpecific()) {
- return 1;
- }
- else if (info2.isLeastSpecific()) {
- return -1;
- }
-
- boolean pattern1EqualsPath = pattern1.equals(path);
- boolean pattern2EqualsPath = pattern2.equals(path);
- if (pattern1EqualsPath && pattern2EqualsPath) {
- return 0;
- }
- else if (pattern1EqualsPath) {
- return -1;
- }
- else if (pattern2EqualsPath) {
- return 1;
- }
-
- if (info1.isPrefixPattern() && info2.getDoubleWildcards() == 0) {
- return 1;
- }
- else if (info2.isPrefixPattern() && info1.getDoubleWildcards() == 0) {
- return -1;
- }
-
- if (info1.getTotalCount() != info2.getTotalCount()) {
- return info1.getTotalCount() - info2.getTotalCount();
- }
-
- if (info1.getLength() != info2.getLength()) {
- return info2.getLength() - info1.getLength();
- }
-
- if (info1.getSingleWildcards() < info2.getSingleWildcards()) {
- return -1;
- }
- else if (info2.getSingleWildcards() < info1.getSingleWildcards()) {
- return 1;
- }
-
- if (info1.getUriVars() < info2.getUriVars()) {
- return -1;
- }
- else if (info2.getUriVars() < info1.getUriVars()) {
- return 1;
- }
-
- return 0;
- }
-
-
- /**
- * Value class that holds information about the pattern, e.g. number of
- * occurrences of "*", "**", and "{" pattern elements.
- */
- private static class PatternInfo {
-
- private final String pattern;
-
- private int uriVars;
-
- private int singleWildcards;
-
- private int doubleWildcards;
-
- private boolean catchAllPattern;
-
- private boolean prefixPattern;
-
- private Integer length;
-
- public PatternInfo(String pattern) {
- this.pattern = pattern;
- if (this.pattern != null) {
- initCounters();
- this.catchAllPattern = this.pattern.equals("/**");
- this.prefixPattern = !this.catchAllPattern && this.pattern.endsWith("/**");
- }
- if (this.uriVars == 0) {
- this.length = (this.pattern != null ? this.pattern.length() : 0);
- }
- }
-
- protected void initCounters() {
- int pos = 0;
- while (pos < this.pattern.length()) {
- if (this.pattern.charAt(pos) == '{') {
- this.uriVars++;
- pos++;
- }
- else if (this.pattern.charAt(pos) == '*') {
- if (pos + 1 < this.pattern.length() && this.pattern.charAt(pos + 1) == '*') {
- this.doubleWildcards++;
- pos += 2;
- }
- else if (pos > 0 && !this.pattern.substring(pos - 1).equals(".*")) {
- this.singleWildcards++;
- pos++;
- }
- else {
- pos++;
- }
- }
- else {
- pos++;
- }
- }
- }
-
- public int getUriVars() {
- return this.uriVars;
- }
-
- public int getSingleWildcards() {
- return this.singleWildcards;
- }
-
- public int getDoubleWildcards() {
- return this.doubleWildcards;
- }
-
- public boolean isLeastSpecific() {
- return (this.pattern == null || this.catchAllPattern);
- }
-
- public boolean isPrefixPattern() {
- return this.prefixPattern;
- }
-
- public int getTotalCount() {
- return this.uriVars + this.singleWildcards + (2 * this.doubleWildcards);
- }
-
- /**
- * Returns the length of the given pattern, where template variables are considered to be 1 long.
- */
- public int getLength() {
- if (this.length == null) {
- this.length = VARIABLE_PATTERN.matcher(this.pattern).replaceAll("#").length();
- }
- return this.length;
- }
- }
- }
-
-}
diff --git a/src/java/com/zhaow/restful/common/spring/StringUtils.java b/src/java/com/zhaow/restful/common/spring/StringUtils.java
deleted file mode 100644
index e5013cd..0000000
--- a/src/java/com/zhaow/restful/common/spring/StringUtils.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2002-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.zhaow.restful.common.spring;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * Miscellaneous {@link String} utility methods.
- *
- *
Mainly for internal use within the framework; consider
- * Apache's Commons Lang
- * for a more comprehensive suite of {@code String} utilities.
- *
- *
This class delivers some simple functionality that should really be
- * provided by the core Java {@link String} and {@link StringBuilder}
- * classes. It also provides easy-to-use methods to convert between
- * delimited strings, such as CSV strings, and collections and arrays.
- *
- * @author Rod Johnson
- * @author Juergen Hoeller
- * @author Keith Donald
- * @author Rob Harrop
- * @author Rick Evans
- * @author Arjen Poutsma
- * @author Sam Brannen
- * @author Brian Clozel
- * @since 16 April 2001
- */
-public abstract class StringUtils {
-
- /**
- * Check that the given {@code CharSequence} is neither {@code null} nor
- * of length 0.
- *
Note: this method returns {@code true} for a {@code CharSequence}
- * that purely consists of whitespace.
- *
- * @param str the {@code CharSequence} to check (may be {@code null})
- * @return {@code true} if the {@code CharSequence} is not {@code null} and has length
- * @see #hasText(String)
- */
- public static boolean hasLength(CharSequence str) {
- return (str != null && str.length() > 0);
- }
-
- /**
- * Copy the given {@code Collection} into a {@code String} array.
- *
The {@code Collection} must contain {@code String} elements only.
- * @param collection the {@code Collection} to copy
- * @return the {@code String} array ({@code null} if the supplied
- * {@code Collection} was {@code null})
- */
- public static String[] toStringArray(Collection collection) {
- if (collection == null) {
- return null;
- }
-
- return collection.toArray(new String[collection.size()]);
- }
- /**
- * Tokenize the given {@code String} into a {@code String} array via a
- * {@link StringTokenizer}.
- *
The given {@code delimiters} string can consist of any number of
- * delimiter characters. Each of those characters can be used to separate
- * tokens. A delimiter is always a single character; for multi-character
- * delimiters, consider using {@link #delimitedListToStringArray}.
- * @param str the {@code String} to tokenize
- * @param delimiters the delimiter characters, assembled as a {@code String}
- * (each of the characters is individually considered as a delimiter)
- * @param trimTokens trim the tokens via {@link String#trim()}
- * @param ignoreEmptyTokens omit empty tokens from the result array
- * (only applies to tokens that are empty after trimming; StringTokenizer
- * will not consider subsequent delimiters as token in the first place).
- * @return an array of the tokens ({@code null} if the input {@code String}
- * was {@code null})
- * @see StringTokenizer
- * @see String#trim()
- * @see #delimitedListToStringArray
- */
- public static String[] tokenizeToStringArray(
- String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) {
-
- if (str == null) {
- return null;
- }
-
- StringTokenizer st = new StringTokenizer(str, delimiters);
- List tokens = new ArrayList();
- while (st.hasMoreTokens()) {
- String token = st.nextToken();
- if (trimTokens) {
- token = token.trim();
- }
- if (!ignoreEmptyTokens || token.length() > 0) {
- tokens.add(token);
- }
- }
- return toStringArray(tokens);
- }
-}
diff --git a/src/java/com/zhaow/restful/navigation/action/RestServiceChooseByNamePopup.java b/src/java/com/zhaow/restful/navigation/action/RestServiceChooseByNamePopup.java
deleted file mode 100644
index 0fcf663..0000000
--- a/src/java/com/zhaow/restful/navigation/action/RestServiceChooseByNamePopup.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2000-2017 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.zhaow.restful.navigation.action;
-
-import com.intellij.ide.util.gotoByName.ChooseByNameItemProvider;
-import com.intellij.ide.util.gotoByName.ChooseByNameModel;
-import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.text.StringUtil;
-import com.zhaow.utils.ToolkitUtil;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class RestServiceChooseByNamePopup extends ChooseByNamePopup {
- public static final Key CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY = new Key<>("ChooseByNamePopup");
-
- protected RestServiceChooseByNamePopup(@Nullable Project project, @NotNull ChooseByNameModel model, @NotNull ChooseByNameItemProvider provider, @Nullable ChooseByNamePopup oldPopup, @Nullable String predefinedText, boolean mayRequestOpenInCurrentWindow, int initialIndex) {
- super(project, model, provider, oldPopup, predefinedText, mayRequestOpenInCurrentWindow, initialIndex);
- }
-
- public static RestServiceChooseByNamePopup createPopup(final Project project,
- @NotNull final ChooseByNameModel model,
- @NotNull ChooseByNameItemProvider provider,
- @Nullable final String predefinedText,
- boolean mayRequestOpenInCurrentWindow,
- final int initialIndex) {
- if (!StringUtil.isEmptyOrSpaces(predefinedText)) {
- return new RestServiceChooseByNamePopup(project, model, provider, null, predefinedText, mayRequestOpenInCurrentWindow, initialIndex);
- }
-
- final RestServiceChooseByNamePopup oldPopup = project == null ? null : project.getUserData(CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY);
- if (oldPopup != null) {
- oldPopup.close(false);
- }
- RestServiceChooseByNamePopup newPopup = new RestServiceChooseByNamePopup(project, model, provider, oldPopup, predefinedText, mayRequestOpenInCurrentWindow, initialIndex);
-
- if (project != null) {
- project.putUserData(CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY, newPopup);
- }
- return newPopup;
- }
-
- @Override
- public String transformPattern(String pattern) {
- final ChooseByNameModel model = getModel();
- return getTransformedPattern(pattern, model);
- }
-
-//TODO: resolve PathVariable
- public static String getTransformedPattern(String pattern, ChooseByNameModel model) {
- if (! (model instanceof GotoRequestMappingModel) ) {
- return pattern;
- }
-
- pattern = ToolkitUtil.removeRedundancyMarkup(pattern);;
- return pattern;
- }
-
-
- @Nullable
- public String getMemberPattern() {
- final String enteredText = getTrimmedText();
- final int index = enteredText.lastIndexOf('#');
- if (index == -1) {
- return null;
- }
-
- String name = enteredText.substring(index + 1).trim();
- return StringUtil.isEmptyOrSpaces(name) ? null : name;
- }
-
-/* public void repaintList() {
- myRepaintQueue.cancelAllUpdates();
- myRepaintQueue.queue(new Update(this) {
- @Override
- public void run() {
- RestServiceChooseByNamePopup.this.repaintListImmediate();
- }
- });
- }*/
-
-}
\ No newline at end of file
diff --git a/src/java/com/zhaow/restful/navigator/CopyFullUrlAction.java b/src/java/com/zhaow/restful/navigator/CopyFullUrlAction.java
deleted file mode 100644
index 3ae8398..0000000
--- a/src/java/com/zhaow/restful/navigator/CopyFullUrlAction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.zhaow.restful.navigator;
-
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.Presentation;
-import com.intellij.openapi.ide.CopyPasteManager;
-import com.intellij.openapi.project.DumbAware;
-import com.zhaow.restful.navigation.action.RestServiceItem;
-import com.zhaow.utils.RestServiceDataKeys;
-
-import java.awt.datatransfer.StringSelection;
-import java.util.List;
-
-public class CopyFullUrlAction extends AnAction implements DumbAware {
- @Override
- public void update(AnActionEvent e) {
- super.update(e);
- Presentation p = e.getPresentation();
- p.setEnabled(isAvailable(e));
- p.setVisible(isVisible(e));
- }
-
- @Override
- public void actionPerformed(AnActionEvent e) {
- List serviceItems = RestServiceDataKeys.SERVICE_ITEMS.getData(e.getDataContext());
- StringBuilder sb = new StringBuilder();
- for (RestServiceItem serviceItem : serviceItems) {
- if (sb.length() > 1) {
- sb.append("\n\n");
- }
- sb.append(serviceItem.getFullUrl());
- }
-
- CopyPasteManager.getInstance().setContents(new StringSelection(sb.toString()));
-
-// RestServiceProjectsManager.getInstance(getEventProject(e)).
- /* CopyPasteManager.getInstance().setContents(...);*/
- }
-
- /* getSelectRestServiceNodes */
-
- protected boolean isAvailable(AnActionEvent e) {
- return true;
- }
-
- protected boolean isVisible(AnActionEvent e) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/java/com/zhaow/restful/navigator/EditSourceAction.java b/src/java/com/zhaow/restful/navigator/EditSourceAction.java
deleted file mode 100644
index a85a11b..0000000
--- a/src/java/com/zhaow/restful/navigator/EditSourceAction.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.zhaow.restful.navigator;
-
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.Presentation;
-import com.intellij.openapi.project.DumbAware;
-import com.intellij.util.PsiNavigateUtil;
-import com.zhaow.restful.navigation.action.RestServiceItem;
-import com.zhaow.utils.RestServiceDataKeys;
-
-import java.util.List;
-
-public class EditSourceAction extends AnAction implements DumbAware {
- @Override
- public void update(AnActionEvent e) {
- super.update(e);
- Presentation p = e.getPresentation();
- p.setVisible(isVisible(e));
- }
-
- @Override
- public void actionPerformed(AnActionEvent e) {
- List serviceItems = RestServiceDataKeys.SERVICE_ITEMS.getData(e.getDataContext());
-
- for (RestServiceItem serviceItem : serviceItems) {
- PsiNavigateUtil.navigate(serviceItem.getPsiElement());
- }
-
- }
-
-
- protected boolean isVisible(AnActionEvent e) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/java/com/zhaow/restful/statistics/RestfulToolkitFeaturesProvider.java b/src/java/com/zhaow/restful/statistics/RestfulToolkitFeaturesProvider.java
deleted file mode 100644
index bfc4588..0000000
--- a/src/java/com/zhaow/restful/statistics/RestfulToolkitFeaturesProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.zhaow.restful.statistics;
-
-import com.intellij.featureStatistics.ApplicabilityFilter;
-import com.intellij.featureStatistics.FeatureDescriptor;
-import com.intellij.featureStatistics.GroupDescriptor;
-import com.intellij.featureStatistics.ProductivityFeaturesProvider;
-import com.intellij.remoteServer.util.CloudBundle;
-
-import java.util.Collections;
-
-public class RestfulToolkitFeaturesProvider extends ProductivityFeaturesProvider {
- public static final String CLOUDS_GROUP_ID = "clouds";
- public static final String UPLOAD_SSH_KEY_FEATURE_ID = "upload.ssh.key";
-
- @Override
- public FeatureDescriptor[] getFeatureDescriptors() {
- return new FeatureDescriptor[]{new FeatureDescriptor(UPLOAD_SSH_KEY_FEATURE_ID,
- CLOUDS_GROUP_ID,
- "UploadSshKey.html",
- CloudBundle.getText("upload.ssh.key.display.name"),
- 0,
- 0,
- Collections.emptySet(),
- 0,
- this)};
- }
-
- @Override
- public GroupDescriptor[] getGroupDescriptors()
- {
- return new GroupDescriptor[] {
- new GroupDescriptor(CLOUDS_GROUP_ID, CloudBundle.getText("group.display.name"))
- };
- }
-
- @Override
- public ApplicabilityFilter[] getApplicabilityFilters() {
- return new ApplicabilityFilter[0];
- }
-}
\ No newline at end of file
diff --git a/src/java/com/zhaow/utils/RestfulToolkitBundle.java b/src/java/com/zhaow/utils/RestfulToolkitBundle.java
deleted file mode 100644
index 32a9c39..0000000
--- a/src/java/com/zhaow/utils/RestfulToolkitBundle.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.zhaow.utils;
-
-import com.intellij.CommonBundle;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.PropertyKey;
-
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.util.ResourceBundle;
-
-/**
- * @author zhaow
- */
-public class RestfulToolkitBundle {
-
- private static Reference ourBundle;
-
- @NonNls private static final String BUNDLE = "RestfulToolkitBundle";
-
- private RestfulToolkitBundle() {
-
- }
-
- public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
- return CommonBundle.message(getBundle(), key, params);
- }
-
- private static ResourceBundle getBundle() {
- ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
- if (bundle == null) {
- bundle = ResourceBundle.getBundle(BUNDLE);
- ourBundle = new SoftReference<>(bundle);
- }
- return bundle;
- }
-}
\ No newline at end of file
diff --git a/src/java/com/zhaow/livetemplate/RestToolkitTemplatesProvider.java b/src/main/java/com/zhaow/livetemplate/RestToolkitTemplatesProvider.java
similarity index 57%
rename from src/java/com/zhaow/livetemplate/RestToolkitTemplatesProvider.java
rename to src/main/java/com/zhaow/livetemplate/RestToolkitTemplatesProvider.java
index 20ba828..22ef314 100644
--- a/src/java/com/zhaow/livetemplate/RestToolkitTemplatesProvider.java
+++ b/src/main/java/com/zhaow/livetemplate/RestToolkitTemplatesProvider.java
@@ -3,14 +3,14 @@
import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider;
public class RestToolkitTemplatesProvider implements DefaultLiveTemplatesProvider {
- @Override
- public String[] getDefaultLiveTemplateFiles() {
+ @Override
+ public String[] getDefaultLiveTemplateFiles() {
// return new String[]{"/liveTemplates/RestToolkit"};
- return null;
- }
+ return null;
+ }
- @Override
- public String[] getHiddenLiveTemplateFiles() {
- return null;
- }
+ @Override
+ public String[] getHiddenLiveTemplateFiles() {
+ return null;
+ }
}
\ No newline at end of file
diff --git a/src/java/com/zhaow/restful/action/AbstractBaseAction.java b/src/main/java/com/zhaow/restful/action/AbstractBaseAction.java
similarity index 99%
rename from src/java/com/zhaow/restful/action/AbstractBaseAction.java
rename to src/main/java/com/zhaow/restful/action/AbstractBaseAction.java
index 66413bf..392162e 100644
--- a/src/java/com/zhaow/restful/action/AbstractBaseAction.java
+++ b/src/main/java/com/zhaow/restful/action/AbstractBaseAction.java
@@ -19,6 +19,7 @@ protected Project myProject(AnActionEvent e) {
/**
* 设置触发有效条件
+ *
* @param e
* @param visible
*/
diff --git a/src/java/com/zhaow/restful/action/ConvertClassToJSONAction.java b/src/main/java/com/zhaow/restful/action/ConvertClassToJSONAction.java
similarity index 88%
rename from src/java/com/zhaow/restful/action/ConvertClassToJSONAction.java
rename to src/main/java/com/zhaow/restful/action/ConvertClassToJSONAction.java
index 9f63b7a..36eea1a 100644
--- a/src/java/com/zhaow/restful/action/ConvertClassToJSONAction.java
+++ b/src/main/java/com/zhaow/restful/action/ConvertClassToJSONAction.java
@@ -19,7 +19,7 @@ public void actionPerformed(AnActionEvent e) {
PsiElement psiElement = e.getData(CommonDataKeys.PSI_ELEMENT);
PsiClass psiClass = getPsiClass(psiElement);
- if(psiClass == null) return;
+ if (psiClass == null) return;
String json = PsiClassHelper.create(psiClass).convertClassToJSON(myProject(e), true);
CopyPasteManager.getInstance().setContents(new StringSelection(json));
@@ -31,7 +31,7 @@ protected PsiClass getPsiClass(PsiElement psiElement) {
if (psiElement instanceof PsiClass) {
psiClass = (PsiClass) psiElement;
- }else if (psiElement instanceof KtClassOrObject) {
+ } else if (psiElement instanceof KtClassOrObject) {
if (LightClassUtil.INSTANCE.canGenerateLightClass((KtClassOrObject) psiElement)) {
psiClass = LightClassUtilsKt.toLightClass((KtClassOrObject) psiElement);
}
@@ -42,6 +42,6 @@ protected PsiClass getPsiClass(PsiElement psiElement) {
@Override
public void update(AnActionEvent e) {
PsiElement psiElement = e.getData(CommonDataKeys.PSI_ELEMENT);
- setActionPresentationVisible(e,psiElement instanceof PsiClass || psiElement instanceof KtClassOrObject);
+ setActionPresentationVisible(e, psiElement instanceof PsiClass || psiElement instanceof KtClassOrObject);
}
}
diff --git a/src/java/com/zhaow/restful/action/ConvertClassToJSONCompressedAction.java b/src/main/java/com/zhaow/restful/action/ConvertClassToJSONCompressedAction.java
similarity index 95%
rename from src/java/com/zhaow/restful/action/ConvertClassToJSONCompressedAction.java
rename to src/main/java/com/zhaow/restful/action/ConvertClassToJSONCompressedAction.java
index 42ffd25..fecd89e 100644
--- a/src/java/com/zhaow/restful/action/ConvertClassToJSONCompressedAction.java
+++ b/src/main/java/com/zhaow/restful/action/ConvertClassToJSONCompressedAction.java
@@ -16,7 +16,7 @@ public void actionPerformed(AnActionEvent e) {
PsiElement psiElement = e.getData(CommonDataKeys.PSI_ELEMENT);
PsiClass psiClass = getPsiClass(psiElement);
- if(psiClass == null) return;
+ if (psiClass == null) return;
String json = PsiClassHelper.create(psiClass).convertClassToJSON(myProject(e), false);
CopyPasteManager.getInstance().setContents(new StringSelection(json));
diff --git a/src/java/com/zhaow/restful/action/ConvertKtClassToJSONAction.java b/src/main/java/com/zhaow/restful/action/ConvertKtClassToJSONAction.java
similarity index 92%
rename from src/java/com/zhaow/restful/action/ConvertKtClassToJSONAction.java
rename to src/main/java/com/zhaow/restful/action/ConvertKtClassToJSONAction.java
index 73fac0c..9fc49fb 100644
--- a/src/java/com/zhaow/restful/action/ConvertKtClassToJSONAction.java
+++ b/src/main/java/com/zhaow/restful/action/ConvertKtClassToJSONAction.java
@@ -22,6 +22,6 @@ public void actionPerformed(AnActionEvent e) {
@Override
public void update(AnActionEvent e) {
PsiElement psiElement = e.getData(CommonDataKeys.PSI_ELEMENT);
- setActionPresentationVisible(e,psiElement instanceof KtClass);
+ setActionPresentationVisible(e, psiElement instanceof KtClass);
}
}
diff --git a/src/java/com/zhaow/restful/annotations/BasePathMapping.java b/src/main/java/com/zhaow/restful/annotations/BasePathMapping.java
similarity index 100%
rename from src/java/com/zhaow/restful/annotations/BasePathMapping.java
rename to src/main/java/com/zhaow/restful/annotations/BasePathMapping.java
diff --git a/src/java/com/zhaow/restful/annotations/JaxrsHttpMethodAnnotation.java b/src/main/java/com/zhaow/restful/annotations/JaxrsHttpMethodAnnotation.java
similarity index 81%
rename from src/java/com/zhaow/restful/annotations/JaxrsHttpMethodAnnotation.java
rename to src/main/java/com/zhaow/restful/annotations/JaxrsHttpMethodAnnotation.java
index 9ae8914..609e054 100644
--- a/src/java/com/zhaow/restful/annotations/JaxrsHttpMethodAnnotation.java
+++ b/src/main/java/com/zhaow/restful/annotations/JaxrsHttpMethodAnnotation.java
@@ -3,10 +3,10 @@
public enum JaxrsHttpMethodAnnotation {
GET("javax.ws.rs.GET", "GET"),
- POST( "javax.ws.rs.POST", "POST"),
- PUT( "javax.ws.rs.PUT", "PUT"),
- DELETE( "javax.ws.rs.DELETE", "DELETE"),
- HEAD( "javax.ws.rs.HEAD", "HEAD"),
+ POST("javax.ws.rs.POST", "POST"),
+ PUT("javax.ws.rs.PUT", "PUT"),
+ DELETE("javax.ws.rs.DELETE", "DELETE"),
+ HEAD("javax.ws.rs.HEAD", "HEAD"),
PATCH("javax.ws.rs.PATCH", "PATCH");
JaxrsHttpMethodAnnotation(String qualifiedName, String methodName) {
@@ -17,7 +17,7 @@ public enum JaxrsHttpMethodAnnotation {
private String qualifiedName;
private String methodName;
- public String methodName() {
+ public String methodName() {
return this.methodName;
}
@@ -26,7 +26,7 @@ public String getQualifiedName() {
}
public String getShortName() {
- return qualifiedName.substring(qualifiedName.lastIndexOf(".")-1);
+ return qualifiedName.substring(qualifiedName.lastIndexOf(".") - 1);
}
public static JaxrsHttpMethodAnnotation getByQualifiedName(String qualifiedName) {
@@ -35,7 +35,7 @@ public static JaxrsHttpMethodAnnotation getByQualifiedName(String qualifiedName)
return springRequestAnnotation;
}
}
- return null;
+ return null;
}
}
\ No newline at end of file
diff --git a/src/java/com/zhaow/restful/annotations/JaxrsPathAnnotation.java b/src/main/java/com/zhaow/restful/annotations/JaxrsPathAnnotation.java
similarity index 100%
rename from src/java/com/zhaow/restful/annotations/JaxrsPathAnnotation.java
rename to src/main/java/com/zhaow/restful/annotations/JaxrsPathAnnotation.java
diff --git a/src/java/com/zhaow/restful/annotations/JaxrsRequestAnnotation.java b/src/main/java/com/zhaow/restful/annotations/JaxrsRequestAnnotation.java
similarity index 95%
rename from src/java/com/zhaow/restful/annotations/JaxrsRequestAnnotation.java
rename to src/main/java/com/zhaow/restful/annotations/JaxrsRequestAnnotation.java
index 26538e1..acabb6f 100644
--- a/src/java/com/zhaow/restful/annotations/JaxrsRequestAnnotation.java
+++ b/src/main/java/com/zhaow/restful/annotations/JaxrsRequestAnnotation.java
@@ -15,7 +15,7 @@ public enum JaxrsRequestAnnotation {
private String qualifiedName;
private String methodName;
- public String methodName() {
+ public String methodName() {
return this.methodName;
}
@@ -42,7 +42,7 @@ public static JaxrsRequestAnnotation getByQualifiedName(String qualifiedName) {
return requestAnnotation;
}
}
- return null;
+ return null;
}
}
\ No newline at end of file
diff --git a/src/java/com/zhaow/restful/annotations/JaxrsRequestParamAnnotation.java b/src/main/java/com/zhaow/restful/annotations/JaxrsRequestParamAnnotation.java
similarity index 80%
rename from src/java/com/zhaow/restful/annotations/JaxrsRequestParamAnnotation.java
rename to src/main/java/com/zhaow/restful/annotations/JaxrsRequestParamAnnotation.java
index a00dec8..68c6ed7 100644
--- a/src/java/com/zhaow/restful/annotations/JaxrsRequestParamAnnotation.java
+++ b/src/main/java/com/zhaow/restful/annotations/JaxrsRequestParamAnnotation.java
@@ -2,7 +2,7 @@
public enum JaxrsRequestParamAnnotation {
- QUERY_PARAM("QueryParam","javax.ws.rs.QueryParam"), PATH_PARAM("PathParam","javax.ws.rs.PathParam");
+ QUERY_PARAM("QueryParam", "javax.ws.rs.QueryParam"), PATH_PARAM("PathParam", "javax.ws.rs.PathParam");
JaxrsRequestParamAnnotation(String shortName, String qualifiedName) {
this.shortName = shortName;
diff --git a/src/java/com/zhaow/restful/annotations/PathMappingAnnotation.java b/src/main/java/com/zhaow/restful/annotations/PathMappingAnnotation.java
similarity index 65%
rename from src/java/com/zhaow/restful/annotations/PathMappingAnnotation.java
rename to src/main/java/com/zhaow/restful/annotations/PathMappingAnnotation.java
index 317afdd..17177a3 100644
--- a/src/java/com/zhaow/restful/annotations/PathMappingAnnotation.java
+++ b/src/main/java/com/zhaow/restful/annotations/PathMappingAnnotation.java
@@ -1,8 +1,8 @@
package com.zhaow.restful.annotations;
public interface PathMappingAnnotation {
-// List allPathMappingAnnotations = new ArrayList<>();
- public String getQualifiedName() ;
+ // List allPathMappingAnnotations = new ArrayList<>();
+ public String getQualifiedName();
public String getShortName();
diff --git a/src/java/com/zhaow/restful/annotations/SpringControllerAnnotation.java b/src/main/java/com/zhaow/restful/annotations/SpringControllerAnnotation.java
similarity index 100%
rename from src/java/com/zhaow/restful/annotations/SpringControllerAnnotation.java
rename to src/main/java/com/zhaow/restful/annotations/SpringControllerAnnotation.java
diff --git a/src/java/com/zhaow/restful/annotations/SpringRequestMethodAnnotation.java b/src/main/java/com/zhaow/restful/annotations/SpringRequestMethodAnnotation.java
similarity index 83%
rename from src/java/com/zhaow/restful/annotations/SpringRequestMethodAnnotation.java
rename to src/main/java/com/zhaow/restful/annotations/SpringRequestMethodAnnotation.java
index 5e4fed5..8cad745 100644
--- a/src/java/com/zhaow/restful/annotations/SpringRequestMethodAnnotation.java
+++ b/src/main/java/com/zhaow/restful/annotations/SpringRequestMethodAnnotation.java
@@ -5,9 +5,9 @@ public enum SpringRequestMethodAnnotation {
REQUEST_MAPPING("org.springframework.web.bind.annotation.RequestMapping", null),
GET_MAPPING("org.springframework.web.bind.annotation.GetMapping", "GET"),
- POST_MAPPING( "org.springframework.web.bind.annotation.PostMapping", "POST"),
- PUT_MAPPING( "org.springframework.web.bind.annotation.PutMapping", "PUT"),
- DELETE_MAPPING( "org.springframework.web.bind.annotation.DeleteMapping", "DELETE"),
+ POST_MAPPING("org.springframework.web.bind.annotation.PostMapping", "POST"),
+ PUT_MAPPING("org.springframework.web.bind.annotation.PutMapping", "PUT"),
+ DELETE_MAPPING("org.springframework.web.bind.annotation.DeleteMapping", "DELETE"),
PATCH_MAPPING("org.springframework.web.bind.annotation.PatchMapping", "PATCH");
SpringRequestMethodAnnotation(String qualifiedName, String methodName) {
@@ -18,7 +18,7 @@ public enum SpringRequestMethodAnnotation {
private String qualifiedName;
private String methodName;
- public String methodName() {
+ public String methodName() {
return this.methodName;
}
@@ -27,7 +27,7 @@ public String getQualifiedName() {
}
public String getShortName() {
- return qualifiedName.substring(qualifiedName.lastIndexOf(".")-1);
+ return qualifiedName.substring(qualifiedName.lastIndexOf(".") - 1);
}
public static SpringRequestMethodAnnotation getByQualifiedName(String qualifiedName) {
@@ -36,7 +36,7 @@ public static SpringRequestMethodAnnotation getByQualifiedName(String qualifiedN
return springRequestAnnotation;
}
}
- return null;
+ return null;
}
public static SpringRequestMethodAnnotation getByShortName(String requestMapping) {
diff --git a/src/java/com/zhaow/restful/annotations/SpringRequestParamAnnotations.java b/src/main/java/com/zhaow/restful/annotations/SpringRequestParamAnnotations.java
similarity index 100%
rename from src/java/com/zhaow/restful/annotations/SpringRequestParamAnnotations.java
rename to src/main/java/com/zhaow/restful/annotations/SpringRequestParamAnnotations.java
diff --git a/src/java/com/zhaow/restful/codegen/SpringBootGenerator.java b/src/main/java/com/zhaow/restful/codegen/SpringBootGenerator.java
similarity index 95%
rename from src/java/com/zhaow/restful/codegen/SpringBootGenerator.java
rename to src/main/java/com/zhaow/restful/codegen/SpringBootGenerator.java
index ddeabde..c3f62a0 100644
--- a/src/java/com/zhaow/restful/codegen/SpringBootGenerator.java
+++ b/src/main/java/com/zhaow/restful/codegen/SpringBootGenerator.java
@@ -48,8 +48,6 @@ public void actionPerformed(AnActionEvent e) {
String content = editor.getDocument().getText();
-
-
// createPackage();
// createFile()
@@ -62,7 +60,7 @@ public void actionPerformed(AnActionEvent e) {
}
- public void createFile(String fileName,String content) {
+ public void createFile(String fileName, String content) {
PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText(fileName, FileTypes.PLAIN_TEXT, content);
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
@@ -77,7 +75,7 @@ public void createFile(String fileName,String content) {
}
}
- private String genFromTemplate(String templateName, Map dataMap) {
+ private String genFromTemplate(String templateName, Map dataMap) {
VelocityContext context = new VelocityContext();
@@ -106,7 +104,7 @@ private String genFromTemplate(String templateName, Map dataMap
// 创建目录,文件
private void createController(String basePackage, String path, String modelName) {
- createFile(modelName +"Controller" , genFromTemplate("controller",new HashMap<>())) ;
+ createFile(modelName + "Controller", genFromTemplate("controller", new HashMap<>()));
}
private void refreshProject(AnActionEvent e) {
diff --git a/src/main/java/com/zhaow/restful/common/ChineseUtill.java b/src/main/java/com/zhaow/restful/common/ChineseUtill.java
new file mode 100644
index 0000000..be0d492
--- /dev/null
+++ b/src/main/java/com/zhaow/restful/common/ChineseUtill.java
@@ -0,0 +1,58 @@
+package com.zhaow.restful.common;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ChineseUtill {
+
+ private static boolean isChinese(char c) {
+ Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
+ if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
+ || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
+ || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
+ || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
+ || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
+ || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isMessyCode(String strName) {
+ Pattern p = Pattern.compile("\\s*|\t*|\r*|\n*");
+ Matcher m = p.matcher(strName);
+ String after = m.replaceAll("");
+ String temp = after.replaceAll("\\p{P}", "");
+ char[] ch = temp.trim().toCharArray();
+ float chLength = 0;
+ float count = 0;
+ for (int i = 0; i < ch.length; i++) {
+ char c = ch[i];
+ if (!Character.isLetterOrDigit(c)) {
+ if (!isChinese(c)) {
+ count = count + 1;
+ }
+ chLength++;
+ }
+ }
+ float result = count / chLength;
+ if (result > 0.4) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ public static String toChinese(Object msg) {
+// String tempMsg = TransformUtils.toString(msg) ;
+ String tempMsg = msg.toString();
+ if (isMessyCode(tempMsg)) {
+ try {
+ return new String(tempMsg.getBytes("ISO8859-1"), "UTF-8");
+ } catch (Exception e) {
+ }
+ }
+ return tempMsg;
+ }
+}
\ No newline at end of file
diff --git a/src/java/com/zhaow/restful/common/IntellijUtils.java b/src/main/java/com/zhaow/restful/common/IntellijUtils.java
similarity index 100%
rename from src/java/com/zhaow/restful/common/IntellijUtils.java
rename to src/main/java/com/zhaow/restful/common/IntellijUtils.java
diff --git a/src/java/com/zhaow/restful/common/KtClassHelper.java b/src/main/java/com/zhaow/restful/common/KtClassHelper.java
similarity index 94%
rename from src/java/com/zhaow/restful/common/KtClassHelper.java
rename to src/main/java/com/zhaow/restful/common/KtClassHelper.java
index 169f1de..6365d57 100644
--- a/src/java/com/zhaow/restful/common/KtClassHelper.java
+++ b/src/main/java/com/zhaow/restful/common/KtClassHelper.java
@@ -19,7 +19,7 @@
public class KtClassHelper {
KtClass psiClass;
- private static int autoCorrelationCount=0; //标记实体递归
+ private static int autoCorrelationCount = 0; //标记实体递归
private int listIterateCount = 0; //标记List递归
private Module myModule;
@@ -74,7 +74,7 @@ public KtClassOrObject findOnePsiClassByClassName(String className, Project proj
}
-//PsiShortNamesCache : PsiClass:Demo KtLightClassImpl:data class Greeting(val id: Long, val content: String) { 代码体 }
+ //PsiShortNamesCache : PsiClass:Demo KtLightClassImpl:data class Greeting(val id: Long, val content: String) { 代码体 }
public Collection tryDetectPsiClassByShortClassName(Project project, String shortClassName) {
PsiClass[] psiClasses = PsiShortNamesCache.getInstance(project).getClassesByName(shortClassName, GlobalSearchScope.allScope(project));// 所有的
PsiClass[] classesByName = KotlinShortNamesCache.getInstance(project).getClassesByName(shortClassName, GlobalSearchScope.allScope(project));
@@ -87,7 +87,7 @@ public Collection tryDetectPsiClassByShortClassName(Project pro
if (ktClassOrObjects.size() > 0) {
return ktClassOrObjects;
}
- if(myModule != null) {
+ if (myModule != null) {
ktClassOrObjects = KotlinClassShortNameIndex.getInstance().get(shortClassName, project, GlobalSearchScope.allScope(project));
}
return ktClassOrObjects;
diff --git a/src/java/com/zhaow/restful/common/KtFunctionHelper.java b/src/main/java/com/zhaow/restful/common/KtFunctionHelper.java
similarity index 95%
rename from src/java/com/zhaow/restful/common/KtFunctionHelper.java
rename to src/main/java/com/zhaow/restful/common/KtFunctionHelper.java
index fe02935..efc0058 100644
--- a/src/java/com/zhaow/restful/common/KtFunctionHelper.java
+++ b/src/main/java/com/zhaow/restful/common/KtFunctionHelper.java
@@ -19,7 +19,7 @@ public class KtFunctionHelper extends PsiMethodHelper {
Project myProject;
Module myModule;
- private String pathSeparator= "/";
+ private String pathSeparator = "/";
public static KtFunctionHelper create(@NotNull KtNamedFunction psiMethod) {
return new KtFunctionHelper(psiMethod);
@@ -40,12 +40,13 @@ protected KtFunctionHelper(@NotNull KtNamedFunction ktNamedFunction) {
@NotNull
protected Project getProject() {
- myProject = psiMethod.getProject();
+ myProject = psiMethod.getProject();
return myProject;
}
/**
* 构建URL参数 key value
+ *
* @return
*/
public String buildParamString() {
@@ -60,7 +61,7 @@ public String buildParamString() {
baseTypeParamMap.forEach((s, o) -> param.append(s).append("=").append(o).append("&"));
}
- return param.length() >0 ? param.deleteCharAt(param.length()-1).toString() : "";
+ return param.length() > 0 ? param.deleteCharAt(param.length() - 1).toString() : "";
}
/*获取方法中基础类型(primitive和string、date等以及这些类型数组)*/
@@ -110,7 +111,7 @@ public Map getBaseTypeParameterMap() {
}
}*//*
- *//* if (ktClass instanceof KtClass) {
+ *//* if (ktClass instanceof KtClass) {
List ktProperties = ((KtClass) ktClass).getProperties();
for (KtProperty ktProperty : ktProperties) {
System.out.println(ktProperty);
@@ -124,5 +125,4 @@ public Map getBaseTypeParameterMap() {
}*/
-
}
diff --git a/src/java/com/zhaow/restful/common/PsiAnnotationHelper.java b/src/main/java/com/zhaow/restful/common/PsiAnnotationHelper.java
similarity index 100%
rename from src/java/com/zhaow/restful/common/PsiAnnotationHelper.java
rename to src/main/java/com/zhaow/restful/common/PsiAnnotationHelper.java
diff --git a/src/java/com/zhaow/restful/common/PsiClassHelper.java b/src/main/java/com/zhaow/restful/common/PsiClassHelper.java
similarity index 85%
rename from src/java/com/zhaow/restful/common/PsiClassHelper.java
rename to src/main/java/com/zhaow/restful/common/PsiClassHelper.java
index 21e4680..65a2b2c 100644
--- a/src/java/com/zhaow/restful/common/PsiClassHelper.java
+++ b/src/main/java/com/zhaow/restful/common/PsiClassHelper.java
@@ -15,11 +15,12 @@
import java.math.BigDecimal;
import java.util.*;
+
// 处理 实体自关联,第二层自关联字段
public class PsiClassHelper {
PsiClass psiClass;
- private static int autoCorrelationCount=0; //标记实体递归
+ private static int autoCorrelationCount = 0; //标记实体递归
private int listIterateCount = 0; //标记List递归
private Module myModule;
@@ -43,10 +44,10 @@ public String convertClassToJSON(String className, Project project) {
String queryJson;
if (className.contains("List<")) { //参数为 List
- List