Skip to content

The Unified and Autonomous Development Platform

Integrate with symbolextractor sub project with JavaScript support

robin shine0818ded11326
diff --git a/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/ElementCompletion.java b/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/ElementCompletion.java
index 8e2bc7031e..cc0955643d 100644
--- a/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/ElementCompletion.java
+++ b/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/ElementCompletion.java
@@ -2,7 +2,7 @@ package com.gitplex.commons.antlr.codeassist;
import javax.annotation.Nullable;
-import com.gitplex.commons.util.Range;
+import com.gitplex.symbolextractor.Range;
public class ElementCompletion extends InputCompletion {
diff --git a/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/FenceAware.java b/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/FenceAware.java
index 609a26ae94..53eacecd88 100644
--- a/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/FenceAware.java
+++ b/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/FenceAware.java
@@ -9,7 +9,7 @@ import org.antlr.v4.runtime.Token;
import com.gitplex.commons.antlr.grammar.ElementSpec;
import com.gitplex.commons.antlr.grammar.Grammar;
-import com.gitplex.commons.util.Range;
+import com.gitplex.symbolextractor.Range;
public abstract class FenceAware {
diff --git a/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/InputCompletion.java b/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/InputCompletion.java
index 7affc13690..d3a90de425 100644
--- a/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/InputCompletion.java
+++ b/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/InputCompletion.java
@@ -4,7 +4,7 @@ import java.io.Serializable;
import javax.annotation.Nullable;
-import com.gitplex.commons.util.Range;
+import com.gitplex.symbolextractor.Range;
public class InputCompletion implements Serializable {
diff --git a/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/InputSuggestion.java b/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/InputSuggestion.java
index e121ff525d..0fd30841c8 100644
--- a/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/InputSuggestion.java
+++ b/commons.antlr/src/main/java/com/gitplex/commons/antlr/codeassist/InputSuggestion.java
@@ -2,7 +2,7 @@ package com.gitplex.commons.antlr.codeassist;
import javax.annotation.Nullable;
-import com.gitplex.commons.util.Range;
+import com.gitplex.symbolextractor.Range;
public class InputSuggestion extends InputStatus {
diff --git a/commons.git/pom.xml b/commons.git/pom.xml
index 8a4dc8e7d1..3a4fe82304 100644
--- a/commons.git/pom.xml
+++ b/commons.git/pom.xml
@@ -67,11 +67,6 @@
<artifactId>commons.wicket</artifactId>
<version>1.0-EAP-build18</version>
</dependency>
- <dependency>
- <groupId>com.gitplex</groupId>
- <artifactId>commons.lang</artifactId>
- <version>1.0-EAP-build18</version>
- </dependency>
</dependencies>
<properties>
<jgitVersion>4.4.1.201607150455-r</jgitVersion>
diff --git a/commons.git/src/main/java/com/gitplex/commons/git/Blame.java b/commons.git/src/main/java/com/gitplex/commons/git/Blame.java
index d61f12e1c0..53aac5253e 100644
--- a/commons.git/src/main/java/com/gitplex/commons/git/Blame.java
+++ b/commons.git/src/main/java/com/gitplex/commons/git/Blame.java
@@ -4,7 +4,7 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
-import com.gitplex.commons.util.Range;
+import com.gitplex.symbolextractor.Range;
public class Blame {
diff --git a/commons.git/src/main/java/com/gitplex/commons/git/BlobChange.java b/commons.git/src/main/java/com/gitplex/commons/git/BlobChange.java
index 575ee302a7..3a6e1062ec 100644
--- a/commons.git/src/main/java/com/gitplex/commons/git/BlobChange.java
+++ b/commons.git/src/main/java/com/gitplex/commons/git/BlobChange.java
@@ -11,11 +11,11 @@ import javax.annotation.Nullable;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
-import com.gitplex.commons.lang.diff.DiffBlock;
-import com.gitplex.commons.lang.diff.DiffUtils;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.DiffBlock;
+import com.gitplex.commons.util.diff.DiffUtils;
+import com.gitplex.commons.util.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.DiffMatchPatch.Operation;
import com.gitplex.jsyntax.Token;
-import com.gitplex.commons.lang.diff.DiffMatchPatch.Operation;
import com.google.common.base.Preconditions;
@SuppressWarnings("serial")
diff --git a/commons.git/src/main/java/com/gitplex/commons/git/command/BlameCommand.java b/commons.git/src/main/java/com/gitplex/commons/git/command/BlameCommand.java
index ac6f6610cb..3debb7936c 100644
--- a/commons.git/src/main/java/com/gitplex/commons/git/command/BlameCommand.java
+++ b/commons.git/src/main/java/com/gitplex/commons/git/command/BlameCommand.java
@@ -18,10 +18,10 @@ import org.slf4j.LoggerFactory;
import com.gitplex.commons.git.Blame;
import com.gitplex.commons.git.BriefCommit;
import com.gitplex.commons.git.GitUtils;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.execution.Commandline;
import com.gitplex.commons.util.execution.ExecuteResult;
import com.gitplex.commons.util.execution.LineConsumer;
+import com.gitplex.symbolextractor.Range;
import com.google.common.base.Preconditions;
public class BlameCommand extends GitCommand<Map<String, Blame>> {
@@ -97,7 +97,7 @@ public class BlameCommand extends GitCommand<Map<String, Blame>> {
if (commit != null && !commitBuilder.hash.equals(commit.getHash())) {
Blame blame = blames.get(commit.getHash());
if (blame == null) {
- blame = new Blame(commit, new ArrayList<Range>());
+ blame = new Blame(commit, new ArrayList<>());
blames.put(commit.getHash(), blame);
}
blame.getRanges().add(new Range(beginLine.get(), endLine.get()));
diff --git a/commons.lang/.gitignore b/commons.lang/.gitignore
deleted file mode 100644
index b83d22266a..0000000000
--- a/commons.lang/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/commons.lang/pom.xml b/commons.lang/pom.xml
deleted file mode 100644
index 8d1633f1d5..0000000000
--- a/commons.lang/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>commons.lang</artifactId>
- <parent>
- <groupId>com.gitplex</groupId>
- <artifactId>gitplex</artifactId>
- <version>1.0-EAP-build18</version>
- </parent>
- <build>
- <plugins>
- <plugin>
- <groupId>com.gitplex</groupId>
- <artifactId>plugin.maven</artifactId>
- </plugin>
- <!-- Uncomment below if you'd like to publish an archetype based on your
- plugin -->
- <!--plugin> <artifactId>maven-archetype-plugin</artifactId> </plugin -->
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>com.gitplex</groupId>
- <artifactId>commons.loader</artifactId>
- <version>1.0-EAP-build18</version>
- </dependency>
- <dependency>
- <groupId>com.gitplex</groupId>
- <artifactId>commons.loader</artifactId>
- <version>1.0-EAP-build18</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.gitplex</groupId>
- <artifactId>commons.util</artifactId>
- <version>1.0-EAP-build18</version>
- </dependency>
- <dependency>
- <groupId>com.gitplex</groupId>
- <artifactId>commons.wicket</artifactId>
- <version>1.0-EAP-build18</version>
- </dependency>
- <dependency>
- <groupId>com.gitplex</groupId>
- <artifactId>commons.antlr</artifactId>
- <version>1.0-EAP-build18</version>
- </dependency>
- <dependency>
- <groupId>com.gitplex</groupId>
- <artifactId>jsyntax</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <properties>
- <moduleClass>com.gitplex.commons.lang.LangModule</moduleClass>
- </properties>
-</project>
\ No newline at end of file
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/LangModule.java b/commons.lang/src/main/java/com/gitplex/commons/lang/LangModule.java
deleted file mode 100644
index a63f041107..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/LangModule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.gitplex.commons.lang;
-
-import com.gitplex.commons.lang.extractors.DefaultExtractors;
-import com.gitplex.commons.lang.extractors.Extractor;
-import com.gitplex.commons.lang.extractors.Extractors;
-import com.gitplex.commons.loader.AbstractPluginModule;
-
-/**
- * NOTE: Do not forget to rename moduleClass property defined in the pom if you've renamed this class.
- *
- */
-public class LangModule extends AbstractPluginModule {
-
- @Override
- protected void configure() {
- super.configure();
-
- contributeFromPackage(Extractor.class, Extractor.class);
-
- bind(Extractors.class).to(DefaultExtractors.class);
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/AbstractExtractor.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/AbstractExtractor.java
deleted file mode 100644
index 3802350a9a..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/AbstractExtractor.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import java.util.regex.Pattern;
-
-import com.gitplex.commons.util.StringUtils;
-
-public abstract class AbstractExtractor implements Extractor {
-
- protected boolean acceptExtensions(String fileName, String...exts) {
- String fileExt = StringUtils.substringAfterLast(fileName, ".");
- for (String ext: exts) {
- if (ext.equalsIgnoreCase(fileExt))
- return true;
- }
- return false;
- }
-
- protected boolean acceptPattern(String fileName, Pattern pattern) {
- return pattern.matcher(fileName).matches();
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/DefaultExtractors.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/DefaultExtractors.java
deleted file mode 100644
index 178013d10f..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/DefaultExtractors.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import com.google.common.base.Joiner;
-
-@Singleton
-public class DefaultExtractors implements Extractors {
-
- private final Set<Extractor> extractorSet;
-
- @Inject
- public DefaultExtractors(Set<Extractor> extractorSet) {
- this.extractorSet = extractorSet;
- }
-
- @Override
- public Extractor getExtractor(String fileName) {
- for (Extractor extractor: extractorSet) {
- if (extractor.accept(fileName))
- return extractor;
- }
- return null;
- }
-
- @Override
- public String getVersion() {
- List<String> versions = new ArrayList<>();
-
- for (Extractor extractor: extractorSet)
- versions.add(extractor.getClass().getName() + ":" + extractor.getVersion());
-
- Collections.sort(versions);
- return Joiner.on(",").join(versions);
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/ExtractException.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/ExtractException.java
deleted file mode 100644
index f5a4d99db2..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/ExtractException.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-@SuppressWarnings("serial")
-public class ExtractException extends RuntimeException {
-
- public ExtractException(String message) {
- super(message);
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Extractor.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Extractor.java
deleted file mode 100644
index 0a83af8b6b..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Extractor.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import java.util.List;
-
-public interface Extractor {
-
- List<Symbol> extract(String text) throws ExtractException;
-
- boolean accept(String fileName);
-
- int getVersion();
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Extractors.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Extractors.java
deleted file mode 100644
index b55a22d986..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Extractors.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import javax.annotation.Nullable;
-
-public interface Extractors {
-
- @Nullable Extractor getExtractor(String fileName);
-
- String getVersion();
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Symbol.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Symbol.java
deleted file mode 100644
index ebf4ae01a9..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Symbol.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import java.io.Serializable;
-
-import javax.annotation.Nullable;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.request.resource.ResourceReference;
-
-import com.gitplex.commons.util.Range;
-
-/**
- * Represents a symbol extracted from source file
- *
- * @author robin
- *
- */
-public abstract class Symbol implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private final Symbol parent;
-
- private final String name;
-
- private final TokenPosition pos;
-
- /**
- * Construct a symbol
- *
- * @param parent
- * parent symbol, use <tt>null</tt> if there is no parent
- * @param name
- * name of the symbol to be indexed for search and cross referencing.
- * Use <tt>null</tt> if the symbol is only for outline purpose, and
- * does not need to be indexed for search and cross referenced. For
- * instance a Java package should be displayed in outline, but does
- * not need to be indexed
- * @param pos
- * position of the symbol in source file
- */
- public Symbol(@Nullable Symbol parent, @Nullable String name, TokenPosition pos) {
- this.parent = parent;
- this.name = name;
- this.pos = pos;
- }
-
- public Symbol getParent() {
- return parent;
- }
-
- /**
- * Get name of this symbol.
- *
- * @return
- * name of this symbol for indexing, or <tt>null</tt> if this symbol
- * does not need to be indexed
- */
- @Nullable
- public String getName() {
- return name;
- }
-
- /**
- * Get position of the symbol in source file
- *
- * @return
- * position of the symbol in source file
- */
- public TokenPosition getPos() {
- return pos;
- }
-
- /**
- * Render the symbol in web UI
- *
- * @param componentId
- * wicket component id corresponding to this symbol
- * @param highlightRange
- * range of the name to be highlighted if not <tt>null</tt>. For instance,
- * when user searches for a symbol, this range will be used to highlight
- * the matched search in the symbol name
- *
- * @return
- * a wicket component to be displayed in web UI for the symbol
- */
- public abstract Component render(String componentId, @Nullable Range highlightRange);
-
- /**
- * Get icon of the symbol to be displayed in web UI
- *
- * @return
- * icon of the symbol
- */
- public abstract ResourceReference getIcon();
-
- public int score() {
- int relevance = 1;
- Symbol parent = this.parent;
- while (parent != null) {
- if (parent.getName() != null)
- relevance++;
- parent = parent.parent;
- }
- return relevance*name.length();
- }
-
- /**
- * Get scope of the symbol. Scope is used to show to the user under which scope the
- * symbol is. For instance, A method &quot;sayHello()&quot; defined in Java class
- * &quot;com.example.HelloWorld&quot; will return the scope as
- * &quot;com.example.HelloWorld&quot;. Return <tt>null</tt> if the symbol does not
- * have a scope
- * @return
- */
- @Nullable
- public abstract String getScope();
-
- /**
- * Whether or not this symbol is a primary symbol. Primary symbol will be searched
- * before non-primary symbols. For instance, a Java symbol search will match
- * against type symbols (class, enumeration, interface, annotation etc.) first
- * before matching other symbols such as fields and methods.
- *
- * @return
- * whether or not this symbol is primary
- */
- public abstract boolean isPrimary();
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Token.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Token.java
deleted file mode 100644
index ed6111ec6a..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/Token.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import java.io.Serializable;
-
-import javax.annotation.Nullable;
-
-import com.gitplex.commons.util.Range;
-
-/**
- * A simplified version of ANTLR lexer token
- *
- * @author robin
- *
- */
-public class Token implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final Token EOF = new Token(org.antlr.v4.runtime.Token.EOF, "", null);
-
- private final int type;
-
- private final String text;
-
- private final TokenPosition pos;
-
- /**
- * Constructing the token from ANTLR lexer token
- *
- * @param antlrToken
- * the ANTLR lexer token
- */
- public Token(org.antlr.v4.runtime.Token antlrToken) {
- type = antlrToken.getType();
- text = antlrToken.getText();
- Range range = new Range(antlrToken.getCharPositionInLine(),
- antlrToken.getCharPositionInLine() + text.length());
- pos = new TokenPosition(antlrToken.getLine()-1, range);
- }
-
- /**
- * Construct the token with type, text and position
- *
- * @param type
- * type of the token, normally it uses token type generated by ANTLR lexer
- * @param text
- * text of the token
- * @param pos
- * position of the token, use <tt>null</tt> for EOF token
- */
- public Token(int type, String text, @Nullable TokenPosition pos) {
- this.type = type;
- this.text = text;
- this.pos = pos;
- }
-
- /**
- * Check if this token is of specified type
- *
- * @param type
- * ANTLR lexer token type to check
- * @return
- * whether or not this token is of specifed type
- */
- public boolean is(int type) {
- return this.type == type;
- }
-
- /**
- * Check if this token is of any specified types
- *
- * @param types
- * ANTLR lexer token types to check
- * @return
- * whether or not this token is of specified types
- */
- public boolean is(int...types) {
- for (int type: types) {
- if (this.type == type)
- return true;
- }
- return false;
- }
-
- /**
- * Check if the token text equals specified text
- *
- * @param text
- * text to compare
- * @return
- * whether or not the token text equals specified text
- */
- public boolean is(String text) {
- return text.equals(this.text);
- }
-
- /**
- * Is this token the EOF token
- *
- * @return
- * whether or not the token is EOF token
- */
- public boolean isEof() {
- return type == org.antlr.v4.runtime.Token.EOF;
- }
-
- /**
- * Get ANTLR lexer token type
- *
- * @return
- * ANTLR lexer token type
- */
- public int getType() {
- return type;
- }
-
- /**
- * Get text of the token
- *
- * @return
- * text of the token
- */
- public String getText() {
- return text;
- }
-
- /**
- * Get position of the token in source file
- *
- * @return
- * position of the token in source file
- */
- public TokenPosition getPos() {
- return pos;
- }
-
- /**
- * check if the token is of specified types
- *
- * @return
- * token to be checked
- * @throws
- * UnexpectedTokenException if token is not of expected types
- */
- public Token checkType(int... expectedTypes) {
- if (!is(expectedTypes))
- throw new UnexpectedTokenException(this);
- return this;
- }
-
- /**
- * check if the token text equals specified text
- *
- * @return
- * token to be checked
- * @throws
- * UnexpectedTokenException if token text does not equal to expected text
- */
- public Token checkText(String expectedText) {
- if (!text.equals(expectedText))
- throw new UnexpectedTokenException(this);
- return this;
- }
-
- @Override
- public String toString() {
- return text;
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenFilter.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenFilter.java
deleted file mode 100644
index bf85c9edc7..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenFilter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import org.antlr.v4.runtime.Token;
-
-/**
- * This class represents a ANTLR token filter
- *
- * @author robin
- *
- */
-public interface TokenFilter {
-
- boolean accept(Token token);
-
- public static final TokenFilter ALL = new TokenFilter() {
-
- @Override
- public boolean accept(Token token) {
- return true;
- }
-
- };
-
- public static final TokenFilter DEFAULT_CHANNEL = new TokenFilter() {
-
- @Override
- public boolean accept(Token token) {
- return token.getChannel() == Token.DEFAULT_CHANNEL;
- }
-
- };
-
-}
\ No newline at end of file
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenPosition.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenPosition.java
deleted file mode 100644
index 0c2ae34a58..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenPosition.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import java.io.Serializable;
-
-import javax.annotation.Nullable;
-
-import com.gitplex.commons.util.Range;
-
-/**
- * Represent position of token in source file
- *
- * @author robin
- *
- */
-public class TokenPosition implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private final int line;
-
- private final Range range;
-
- /**
- * Construct with line and range
- *
- * @param line
- * 0-indexed line of the token
- * @param range
- * 0-indexed character position of the token in the line
- */
- public TokenPosition(int line, @Nullable Range range) {
- this.line = line;
- this.range = range;
- }
-
- /**
- * Get line of the token
- *
- * @return
- * 0-indexed line of the token
- */
- public int getLine() {
- return line;
- }
-
- /**
- * Get character position of the token in the line
- *
- * @return
- * 0-indexed character position of the token in the line
- */
- @Nullable
- public Range getRange() {
- return range;
- }
-
-}
\ No newline at end of file
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenStream.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenStream.java
deleted file mode 100644
index 52d98bcd5a..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/TokenStream.java
+++ /dev/null
@@ -1,240 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.antlr.v4.runtime.BaseErrorListener;
-import org.antlr.v4.runtime.Lexer;
-import org.antlr.v4.runtime.RecognitionException;
-import org.antlr.v4.runtime.Recognizer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Token stream holds a list of tokens parsed from source file, and provides various
- * methods to work with these tokens
- *
- * @author robin
- *
- */
-public class TokenStream {
-
- private static final Logger logger = LoggerFactory.getLogger(TokenStream.class);
-
- private final List<Token> tokens;
-
- private int index = -1; // index of current token in stream
-
- public TokenStream(List<Token> tokens) {
- this.tokens = tokens;
- this.tokens.add(Token.EOF);
- }
-
- public TokenStream(Lexer lexer, TokenFilter filter) {
- lexer.removeErrorListeners();
- lexer.addErrorListener(new BaseErrorListener() {
-
- @Override
- public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
- int charPositionInLine, String msg, RecognitionException e) {
- logger.error("Error lexing at position '" + line + ":" + charPositionInLine + "': " + msg);
- }
-
- });
- tokens = new ArrayList<>();
- org.antlr.v4.runtime.Token token = lexer.nextToken();
- while (token.getType() != org.antlr.v4.runtime.Token.EOF) {
- if (filter.accept(token))
- tokens.add(new Token(token));
- token = lexer.nextToken();
- }
- tokens.add(Token.EOF);
- }
-
- /**
- * Get token at specified index in stream
- *
- * @param index
- * index of the token in stream
- * @return
- * token at specified index
- * @throws
- * ExtractException if index is invalid
- */
- public Token at(int index) {
- if (index >=0 && index < tokens.size())
- return tokens.get(index);
- else
- throw new ExtractException("Invalid token position: " + index);
- }
-
- /**
- * Get next token in stream and move index forward
- *
- * @return
- * next token in stream
- * @throws
- * ExtractException if no token at next index
- */
- public Token next() {
- return at(++index);
- }
-
- /**
- * Get next N token in stream without moving index
- *
- * @param ahead
- * number of tokens to look ahead
- * @return
- * next N token in stream
- * @throws
- * ExtractException if no token at specified look ahead index
- */
- public Token lookAhead(int ahead) {
- return at(index+ahead);
- }
-
- /**
- * Get previous N token in stream without moving index
- *
- * @param behind
- * number of tokens to look behind
- * @return
- * previous N token in stream
- * @throws
- * ExtractException if no token at specified look behind index
- */
- public Token lookBehind(int behind) {
- return at(index-behind);
- }
-
- /**
- * Get next token of specified type and move index forward
- *
- * @param type
- * ANTLR lexer token type
- * @return
- * next token of specified type
- * @throws
- * ExtractException if no subsequent token matches specified type
- */
- public Token nextType(int type) {
- Token token = next();
- while(true) {
- if (token.is(type))
- return token;
- token = next();
- }
- }
-
- /**
- * Get next token of specified types and move index forward
- *
- * @param types
- * ANTLR lexer token types
- * @return
- * next token of specified types
- * @throws
- * ExtractException if no subsequent token matches specified types
- */
- public Token nextType(int...types) {
- Token token = next();
- while(true) {
- if (token.is(types))
- return token;
- token = next();
- }
- }
-
- /**
- * Seek to next closed type, with balancing open/close considered, that is, all open/close pair
- * of the same type will be skipped. Below is an example of start position and stop position
- * when calling this method.
- *
- * text { text { text } }
- * ^ ^
- * seek here stop here
- *
- * @param openType
- * open type to seek
- * @param closeType
- * close type to seek
- * @return
- * token at stop position
- * @throws
- * ExtractException if no stop token can be found
- */
- public Token nextClosed(int openType, int closeType) {
- int nestingLevel = 1;
- Token balanced = nextType(openType, closeType);
- while (true) {
- if (balanced.is(closeType)) {
- if (--nestingLevel == 0)
- return balanced;
- } else if (balanced.is(openType)) {
- nestingLevel++;
- }
- balanced = nextType(openType, closeType);
- }
- }
-
- /**
- * Get current index in stream
- *
- * @return
- * current index in stream
- */
- public int index() {
- return index;
- }
-
- /**
- * Set current index in stream
- *
- * @param index
- * index to set
- */
- public void index(int index) {
- this.index = index;
- }
-
- /**
- * Get tokens between a range
- *
- * @param startIndex
- * 0-indexed start index, inclusive
- * @param endIndex
- * 0-indexed end index, inclusive
- * @return
- * list of tokens between specified range
- * @throws
- * ExtractException if no token at specified range
- */
- public List<Token> between(int startIndex, int endIndex) {
- List<Token> tokens = new ArrayList<>();
- for (int i=startIndex; i<=endIndex; i++)
- tokens.add(at(i));
- return tokens;
- }
-
- /**
- * Get token at current index
- *
- * @return
- * token at current index
- */
- public Token current() {
- return at(index);
- }
-
- /**
- * Seek to specified index
- *
- * @param index
- * index to seek to
- */
- public void seek(int index) {
- this.index = index;
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/UnexpectedTokenException.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/UnexpectedTokenException.java
deleted file mode 100644
index b75e20fb4c..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/UnexpectedTokenException.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-
-@SuppressWarnings("serial")
-public class UnexpectedTokenException extends ExtractException {
-
- public UnexpectedTokenException(Token token) {
- super("Unexpected token: " + token);
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/c/C.g4 b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/c/C.g4
deleted file mode 100644
index 82dec7b122..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/c/C.g4
+++ /dev/null
@@ -1,902 +0,0 @@
-/*
- [The "BSD licence"]
- Copyright (c) 2013 Sam Harwell
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/** C 2011 grammar built from the C11 Spec */
-grammar C;
-
-primaryExpression
- : Identifier
- | Constant
- | StringLiteral+
- | '(' expression ')'
- | genericSelection
- | '__extension__'? '(' compoundStatement ')' // Blocks (GCC extension)
- | '__builtin_va_arg' '(' unaryExpression ',' typeName ')'
- | '__builtin_offsetof' '(' typeName ',' unaryExpression ')'
- ;
-
-genericSelection
- : '_Generic' '(' assignmentExpression ',' genericAssocList ')'
- ;
-
-genericAssocList
- : genericAssociation
- | genericAssocList ',' genericAssociation
- ;
-
-genericAssociation
- : typeName ':' assignmentExpression
- | 'default' ':' assignmentExpression
- ;
-
-postfixExpression
- : primaryExpression
- | postfixExpression '[' expression ']'
- | postfixExpression '(' argumentExpressionList? ')'
- | postfixExpression '.' Identifier
- | postfixExpression '->' Identifier
- | postfixExpression '++'
- | postfixExpression '--'
- | '(' typeName ')' '{' initializerList '}'
- | '(' typeName ')' '{' initializerList ',' '}'
- | '__extension__' '(' typeName ')' '{' initializerList '}'
- | '__extension__' '(' typeName ')' '{' initializerList ',' '}'
- ;
-
-argumentExpressionList
- : assignmentExpression
- | argumentExpressionList ',' assignmentExpression
- ;
-
-unaryExpression
- : postfixExpression
- | '++' unaryExpression
- | '--' unaryExpression
- | unaryOperator castExpression
- | 'sizeof' unaryExpression
- | 'sizeof' '(' typeName ')'
- | '_Alignof' '(' typeName ')'
- | '&&' Identifier // GCC extension address of label
- ;
-
-unaryOperator
- : '&' | '*' | '+' | '-' | '~' | '!'
- ;
-
-castExpression
- : unaryExpression
- | '(' typeName ')' castExpression
- | '__extension__' '(' typeName ')' castExpression
- ;
-
-multiplicativeExpression
- : castExpression
- | multiplicativeExpression '*' castExpression
- | multiplicativeExpression '/' castExpression
- | multiplicativeExpression '%' castExpression
- ;
-
-additiveExpression
- : multiplicativeExpression
- | additiveExpression '+' multiplicativeExpression
- | additiveExpression '-' multiplicativeExpression
- ;
-
-shiftExpression
- : additiveExpression
- | shiftExpression '<<' additiveExpression
- | shiftExpression '>>' additiveExpression
- ;
-
-relationalExpression
- : shiftExpression
- | relationalExpression '<' shiftExpression
- | relationalExpression '>' shiftExpression
- | relationalExpression '<=' shiftExpression
- | relationalExpression '>=' shiftExpression
- ;
-
-equalityExpression
- : relationalExpression
- | equalityExpression '==' relationalExpression
- | equalityExpression '!=' relationalExpression
- ;
-
-andExpression
- : equalityExpression
- | andExpression '&' equalityExpression
- ;
-
-exclusiveOrExpression
- : andExpression
- | exclusiveOrExpression '^' andExpression
- ;
-
-inclusiveOrExpression
- : exclusiveOrExpression
- | inclusiveOrExpression '|' exclusiveOrExpression
- ;
-
-logicalAndExpression
- : inclusiveOrExpression
- | logicalAndExpression '&&' inclusiveOrExpression
- ;
-
-logicalOrExpression
- : logicalAndExpression
- | logicalOrExpression '||' logicalAndExpression
- ;
-
-conditionalExpression
- : logicalOrExpression ('?' expression ':' conditionalExpression)?
- ;
-
-assignmentExpression
- : conditionalExpression
- | unaryExpression assignmentOperator assignmentExpression
- ;
-
-assignmentOperator
- : '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|='
- ;
-
-expression
- : assignmentExpression
- | expression ',' assignmentExpression
- ;
-
-constantExpression
- : conditionalExpression
- ;
-
-declaration
- : declarationSpecifiers initDeclaratorList? ';'
- | staticAssertDeclaration
- ;
-
-declarationSpecifiers
- : declarationSpecifier+
- ;
-
-declarationSpecifiers2
- : declarationSpecifier+
- ;
-
-declarationSpecifier
- : storageClassSpecifier
- | typeSpecifier
- | typeQualifier
- | functionSpecifier
- | alignmentSpecifier
- ;
-
-initDeclaratorList
- : initDeclarator
- | initDeclaratorList ',' initDeclarator
- ;
-
-initDeclarator
- : declarator
- | declarator '=' initializer
- ;
-
-storageClassSpecifier
- : 'typedef'
- | 'extern'
- | 'static'
- | '_Thread_local'
- | 'auto'
- | 'register'
- ;
-
-typeSpecifier
- : ('void'
- | 'char'
- | 'short'
- | 'int'
- | 'long'
- | 'float'
- | 'double'
- | 'signed'
- | 'unsigned'
- | '_Bool'
- | '_Complex'
- | '__m128'
- | '__m128d'
- | '__m128i')
- | '__extension__' '(' ('__m128' | '__m128d' | '__m128i') ')'
- | atomicTypeSpecifier
- | structOrUnionSpecifier
- | enumSpecifier
- | typedefName
- | '__typeof__' '(' constantExpression ')' // GCC extension
- ;
-
-structOrUnionSpecifier
- : structOrUnion Identifier? '{' structDeclarationList '}'
- | structOrUnion Identifier
- ;
-
-structOrUnion
- : 'struct'
- | 'union'
- ;
-
-structDeclarationList
- : structDeclaration
- | structDeclarationList structDeclaration
- ;
-
-structDeclaration
- : specifierQualifierList structDeclaratorList? ';'
- | staticAssertDeclaration
- ;
-
-specifierQualifierList
- : typeSpecifier specifierQualifierList?
- | typeQualifier specifierQualifierList?
- ;
-
-structDeclaratorList
- : structDeclarator
- | structDeclaratorList ',' structDeclarator
- ;
-
-structDeclarator
- : declarator
- | declarator? ':' constantExpression
- ;
-
-enumSpecifier
- : 'enum' Identifier? '{' enumeratorList '}'
- | 'enum' Identifier? '{' enumeratorList ',' '}'
- | 'enum' Identifier
- ;
-
-enumeratorList
- : enumerator
- | enumeratorList ',' enumerator
- ;
-
-enumerator
- : enumerationConstant
- | enumerationConstant '=' constantExpression
- ;
-
-enumerationConstant
- : Identifier
- ;
-
-atomicTypeSpecifier
- : '_Atomic' '(' typeName ')'
- ;
-
-typeQualifier
- : 'const'
- | 'restrict'
- | 'volatile'
- | '_Atomic'
- ;
-
-functionSpecifier
- : ('inline'
- | '_Noreturn'
- | '__inline__' // GCC extension
- | '__stdcall')
- | gccAttributeSpecifier
- | '__declspec' '(' Identifier ')'
- ;
-
-alignmentSpecifier
- : '_Alignas' '(' typeName ')'
- | '_Alignas' '(' constantExpression ')'
- ;
-
-declarator
- : pointer? directDeclarator gccDeclaratorExtension*
- ;
-
-directDeclarator
- : Identifier
- | '(' declarator ')'
- | directDeclarator '[' typeQualifierList? assignmentExpression? ']'
- | directDeclarator '[' 'static' typeQualifierList? assignmentExpression ']'
- | directDeclarator '[' typeQualifierList 'static' assignmentExpression ']'
- | directDeclarator '[' typeQualifierList? '*' ']'
- | directDeclarator '(' parameterTypeList ')'
- | directDeclarator '(' identifierList? ')'
- ;
-
-gccDeclaratorExtension
- : '__asm' '(' StringLiteral+ ')'
- | gccAttributeSpecifier
- ;
-
-gccAttributeSpecifier
- : '__attribute__' '(' '(' gccAttributeList ')' ')'
- ;
-
-gccAttributeList
- : gccAttribute (',' gccAttribute)*
- | // empty
- ;
-
-gccAttribute
- : ~(',' | '(' | ')') // relaxed def for "identifier or reserved word"
- ('(' argumentExpressionList? ')')?
- | // empty
- ;
-
-nestedParenthesesBlock
- : ( ~('(' | ')')
- | '(' nestedParenthesesBlock ')'
- )*
- ;
-
-pointer
- : '*' typeQualifierList?
- | '*' typeQualifierList? pointer
- | '^' typeQualifierList? // Blocks language extension
- | '^' typeQualifierList? pointer // Blocks language extension
- ;
-
-typeQualifierList
- : typeQualifier
- | typeQualifierList typeQualifier
- ;
-
-parameterTypeList
- : parameterList
- | parameterList ',' '...'
- ;
-
-parameterList
- : parameterDeclaration
- | parameterList ',' parameterDeclaration
- ;
-
-parameterDeclaration
- : declarationSpecifiers declarator
- | declarationSpecifiers2 abstractDeclarator?
- ;
-
-identifierList
- : Identifier
- | identifierList ',' Identifier
- ;
-
-typeName
- : specifierQualifierList abstractDeclarator?
- ;
-
-abstractDeclarator
- : pointer
- | pointer? directAbstractDeclarator gccDeclaratorExtension*
- ;
-
-directAbstractDeclarator
- : '(' abstractDeclarator ')' gccDeclaratorExtension*
- | '[' typeQualifierList? assignmentExpression? ']'
- | '[' 'static' typeQualifierList? assignmentExpression ']'
- | '[' typeQualifierList 'static' assignmentExpression ']'
- | '[' '*' ']'
- | '(' parameterTypeList? ')' gccDeclaratorExtension*
- | directAbstractDeclarator '[' typeQualifierList? assignmentExpression? ']'
- | directAbstractDeclarator '[' 'static' typeQualifierList? assignmentExpression ']'
- | directAbstractDeclarator '[' typeQualifierList 'static' assignmentExpression ']'
- | directAbstractDeclarator '[' '*' ']'
- | directAbstractDeclarator '(' parameterTypeList? ')' gccDeclaratorExtension*
- ;
-
-typedefName
- : Identifier
- ;
-
-initializer
- : assignmentExpression
- | '{' initializerList '}'
- | '{' initializerList ',' '}'
- ;
-
-initializerList
- : designation? initializer
- | initializerList ',' designation? initializer
- ;
-
-designation
- : designatorList '='
- ;
-
-designatorList
- : designator
- | designatorList designator
- ;
-
-designator
- : '[' constantExpression ']'
- | '.' Identifier
- ;
-
-staticAssertDeclaration
- : '_Static_assert' '(' constantExpression ',' StringLiteral+ ')' ';'
- ;
-
-statement
- : labeledStatement
- | compoundStatement
- | expressionStatement
- | selectionStatement
- | iterationStatement
- | jumpStatement
- | ('__asm' | '__asm__') ('volatile' | '__volatile__') '(' (logicalOrExpression (',' logicalOrExpression)*)? (':' (logicalOrExpression (',' logicalOrExpression)*)?)* ')' ';'
- ;
-
-labeledStatement
- : Identifier ':' statement
- | 'case' constantExpression ':' statement
- | 'default' ':' statement
- ;
-
-compoundStatement
- : '{' blockItemList? '}'
- ;
-
-blockItemList
- : blockItem
- | blockItemList blockItem
- ;
-
-blockItem
- : declaration
- | statement
- ;
-
-expressionStatement
- : expression? ';'
- ;
-
-selectionStatement
- : 'if' '(' expression ')' statement ('else' statement)?
- | 'switch' '(' expression ')' statement
- ;
-
-iterationStatement
- : 'while' '(' expression ')' statement
- | 'do' statement 'while' '(' expression ')' ';'
- | 'for' '(' expression? ';' expression? ';' expression? ')' statement
- | 'for' '(' declaration expression? ';' expression? ')' statement
- ;
-
-jumpStatement
- : 'goto' Identifier ';'
- | 'continue' ';'
- | 'break' ';'
- | 'return' expression? ';'
- | 'goto' unaryExpression ';' // GCC extension
- ;
-
-compilationUnit
- : translationUnit? EOF
- ;
-
-translationUnit
- : externalDeclaration
- | translationUnit externalDeclaration
- ;
-
-externalDeclaration
- : functionDefinition
- | declaration
- | ';' // stray ;
- ;
-
-functionDefinition
- : functionHead compoundStatement
- ;
-
-functionHead
- : declarationSpecifiers? declarator declarationList?
- ;
-
-declarationList
- : declaration
- | declarationList declaration
- ;
-
-Auto : 'auto';
-Break : 'break';
-Case : 'case';
-Char : 'char';
-Const : 'const';
-Continue : 'continue';
-Default : 'default';
-Do : 'do';
-Double : 'double';
-Else : 'else';
-Enum : 'enum';
-Extern : 'extern';
-Float : 'float';
-For : 'for';
-Goto : 'goto';
-If : 'if';
-Inline : 'inline';
-Int : 'int';
-Long : 'long';
-Register : 'register';
-Restrict : 'restrict';
-Return : 'return';
-Short : 'short';
-Signed : 'signed';
-Sizeof : 'sizeof';
-Static : 'static';
-Struct : 'struct';
-Switch : 'switch';
-Typedef : 'typedef';
-Union : 'union';
-Unsigned : 'unsigned';
-Void : 'void';
-Volatile : 'volatile';
-While : 'while';
-
-Alignas : '_Alignas';
-Alignof : '_Alignof';
-Atomic : '_Atomic';
-Bool : '_Bool';
-Complex : '_Complex';
-Generic : '_Generic';
-Imaginary : '_Imaginary';
-Noreturn : '_Noreturn';
-StaticAssert : '_Static_assert';
-ThreadLocal : '_Thread_local';
-
-LeftParen : '(';
-RightParen : ')';
-LeftBracket : '[';
-RightBracket : ']';
-LeftBrace : '{';
-RightBrace : '}';
-
-Less : '<';
-LessEqual : '<=';
-Greater : '>';
-GreaterEqual : '>=';
-LeftShift : '<<';
-RightShift : '>>';
-
-Plus : '+';
-PlusPlus : '++';
-Minus : '-';
-MinusMinus : '--';
-Star : '*';
-Div : '/';
-Mod : '%';
-
-And : '&';
-Or : '|';
-AndAnd : '&&';
-OrOr : '||';
-Caret : '^';
-Not : '!';
-Tilde : '~';
-
-Question : '?';
-Colon : ':';
-Semi : ';';
-Comma : ',';
-
-Assign : '=';
-// '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|='
-StarAssign : '*=';
-DivAssign : '/=';
-ModAssign : '%=';
-PlusAssign : '+=';
-MinusAssign : '-=';
-LeftShiftAssign : '<<=';
-RightShiftAssign : '>>=';
-AndAssign : '&=';
-XorAssign : '^=';
-OrAssign : '|=';
-
-Equal : '==';
-NotEqual : '!=';
-
-Arrow : '->';
-Dot : '.';
-Ellipsis : '...';
-
-Identifier
- : IdentifierNondigit
- ( IdentifierNondigit
- | Digit
- )*
- ;
-
-fragment
-IdentifierNondigit
- : Nondigit
- | UniversalCharacterName
- //| // other implementation-defined characters...
- ;
-
-fragment
-Nondigit
- : [a-zA-Z_]
- ;
-
-fragment
-Digit
- : [0-9]
- ;
-
-fragment
-UniversalCharacterName
- : '\\u' HexQuad
- | '\\U' HexQuad HexQuad
- ;
-
-fragment
-HexQuad
- : HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit
- ;
-
-Constant
- : IntegerConstant
- | FloatingConstant
- //| EnumerationConstant
- | CharacterConstant
- ;
-
-fragment
-IntegerConstant
- : DecimalConstant IntegerSuffix?
- | OctalConstant IntegerSuffix?
- | HexadecimalConstant IntegerSuffix?
- ;
-
-fragment
-DecimalConstant
- : NonzeroDigit Digit*
- ;
-
-fragment
-OctalConstant
- : '0' OctalDigit*
- ;
-
-fragment
-HexadecimalConstant
- : HexadecimalPrefix HexadecimalDigit+
- ;
-
-fragment
-HexadecimalPrefix
- : '0' [xX]
- ;
-
-fragment
-NonzeroDigit
- : [1-9]
- ;
-
-fragment
-OctalDigit
- : [0-7]
- ;
-
-fragment
-HexadecimalDigit
- : [0-9a-fA-F]
- ;
-
-fragment
-IntegerSuffix
- : UnsignedSuffix LongSuffix?
- | UnsignedSuffix LongLongSuffix
- | LongSuffix UnsignedSuffix?
- | LongLongSuffix UnsignedSuffix?
- ;
-
-fragment
-UnsignedSuffix
- : [uU]
- ;
-
-fragment
-LongSuffix
- : [lL]
- ;
-
-fragment
-LongLongSuffix
- : 'll' | 'LL'
- ;
-
-fragment
-FloatingConstant
- : DecimalFloatingConstant
- | HexadecimalFloatingConstant
- ;
-
-fragment
-DecimalFloatingConstant
- : FractionalConstant ExponentPart? FloatingSuffix?
- | DigitSequence ExponentPart FloatingSuffix?
- ;
-
-fragment
-HexadecimalFloatingConstant
- : HexadecimalPrefix HexadecimalFractionalConstant BinaryExponentPart FloatingSuffix?
- | HexadecimalPrefix HexadecimalDigitSequence BinaryExponentPart FloatingSuffix?
- ;
-
-fragment
-FractionalConstant
- : DigitSequence? '.' DigitSequence
- | DigitSequence '.'
- ;
-
-fragment
-ExponentPart
- : 'e' Sign? DigitSequence
- | 'E' Sign? DigitSequence
- ;
-
-fragment
-Sign
- : '+' | '-'
- ;
-
-fragment
-DigitSequence
- : Digit+
- ;
-
-fragment
-HexadecimalFractionalConstant
- : HexadecimalDigitSequence? '.' HexadecimalDigitSequence
- | HexadecimalDigitSequence '.'
- ;
-
-fragment
-BinaryExponentPart
- : 'p' Sign? DigitSequence
- | 'P' Sign? DigitSequence
- ;
-
-fragment
-HexadecimalDigitSequence
- : HexadecimalDigit+
- ;
-
-fragment
-FloatingSuffix
- : 'f' | 'l' | 'F' | 'L'
- ;
-
-fragment
-CharacterConstant
- : '\'' CCharSequence '\''
- | 'L\'' CCharSequence '\''
- | 'u\'' CCharSequence '\''
- | 'U\'' CCharSequence '\''
- ;
-
-fragment
-CCharSequence
- : CChar+
- ;
-
-fragment
-CChar
- : ~['\\\r\n]
- | EscapeSequence
- ;
-
-fragment
-EscapeSequence
- : SimpleEscapeSequence
- | OctalEscapeSequence
- | HexadecimalEscapeSequence
- | UniversalCharacterName
- ;
-
-fragment
-SimpleEscapeSequence
- : '\\' ['"?abfnrtv\\]
- ;
-
-fragment
-OctalEscapeSequence
- : '\\' OctalDigit
- | '\\' OctalDigit OctalDigit
- | '\\' OctalDigit OctalDigit OctalDigit
- ;
-
-fragment
-HexadecimalEscapeSequence
- : '\\x' HexadecimalDigit+
- ;
-
-StringLiteral
- : EncodingPrefix? '"' SCharSequence? '"'
- ;
-
-fragment
-EncodingPrefix
- : 'u8'
- | 'u'
- | 'U'
- | 'L'
- ;
-
-fragment
-SCharSequence
- : SChar+
- ;
-
-fragment
-SChar
- : ~["\\\r\n]
- | EscapeSequence
- ;
-
-LineDirective
- : '#' Whitespace? DecimalConstant Whitespace? StringLiteral ~[\r\n]*
- -> skip
- ;
-
-PragmaDirective
- : '#' Whitespace? 'pragma' Whitespace ~[\r\n]*
- -> skip
- ;
-
-Whitespace
- : [ \t]+
- -> skip
- ;
-
-Newline
- : ( '\r' '\n'?
- | '\n'
- )
- -> skip
- ;
-
-BlockComment
- : '/*' .*? '*/'
- -> skip
- ;
-
-LineComment
- : '//' ~[\r\n]*
- -> skip
- ;
-
-Other
- : . -> skip
- ;
\ No newline at end of file
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/CompilationUnit.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/CompilationUnit.java
deleted file mode 100644
index b8952d810d..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/CompilationUnit.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import javax.annotation.Nullable;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-
-import com.gitplex.commons.lang.extractors.TokenPosition;
-import com.gitplex.commons.lang.extractors.java.icons.Icons;
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.wicket.component.HighlightableLabel;
-
-public class CompilationUnit extends JavaSymbol {
-
- private static final long serialVersionUID = 1L;
-
- private String packageName;
-
- public CompilationUnit(@Nullable String packageName, TokenPosition pos) {
- super(null, null, pos);
-
- this.packageName = packageName;
- }
-
- @Nullable
- public String getPackageName() {
- return packageName;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
- @Override
- public Component render(String componentId, Range matchRange) {
- return new HighlightableLabel(componentId, packageName, matchRange);
- }
-
- @Override
- public ResourceReference getIcon() {
- return new PackageResourceReference(Icons.class, "package_obj.png");
- }
-
- @Override
- public String getScope() {
- return packageName;
- }
-
- @Override
- public boolean isPrimary() {
- return false;
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDef.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDef.java
deleted file mode 100644
index 6bb061cfdd..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDef.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-
-import com.gitplex.commons.lang.extractors.TokenPosition;
-import com.gitplex.commons.lang.extractors.java.icons.Icons;
-import com.gitplex.commons.util.Range;
-
-public class FieldDef extends JavaSymbol {
-
- private static final long serialVersionUID = 1L;
-
- private final String type;
-
- private final List<Modifier> modifiers;
-
- public FieldDef(TypeDef parent, String name, TokenPosition pos,
- @Nullable String type, List<Modifier> modifiers) {
- super(parent, name, pos);
-
- this.type = type;
- this.modifiers = modifiers;
- }
-
- /**
- * Get type of this field.
- *
- * @return
- * type of this field, or <tt>null</tt> for enum constant
- */
- @Nullable
- public String getType() {
- return type;
- }
-
- public List<Modifier> getModifiers() {
- return modifiers;
- }
-
- @Override
- public Component render(String componentId, Range matchRange) {
- return new FieldDefPanel(componentId, this, matchRange);
- }
-
- @Override
- public ResourceReference getIcon() {
- String icon;
- if (modifiers.contains(Modifier.PRIVATE))
- icon = "field_private_obj.png";
- else if (modifiers.contains(Modifier.PROTECTED))
- icon = "field_protected_obj.png";
- else if (modifiers.contains(Modifier.PUBLIC))
- icon = "field_public_obj.png";
- else
- icon = "field_default_obj.png";
- return new PackageResourceReference(Icons.class, icon);
- }
-
- @Override
- public String getScope() {
- String scope = getParent().getScope();
- if (scope != null)
- return scope + "." + getParent().getName();
- else
- return getParent().getName();
- }
-
- @Override
- public boolean isPrimary() {
- return false;
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDefPanel.html b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDefPanel.html
deleted file mode 100644
index d54af539ed..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDefPanel.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<wicket:panel>
- <span wicket:id="name"></span>
- <wicket:enclosure child="type">
- <span style="color: #8C7024;">: <span wicket:id="type"></span></span>
- </wicket:enclosure>
-</wicket:panel>
\ No newline at end of file
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDefPanel.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDefPanel.java
deleted file mode 100644
index beb799e5d0..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/FieldDefPanel.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.panel.Panel;
-
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.wicket.component.HighlightableLabel;
-
-@SuppressWarnings("serial")
-public class FieldDefPanel extends Panel {
-
- private final FieldDef fieldDef;
-
- private final Range matchRange;
-
- public FieldDefPanel(String id, FieldDef fieldDef, Range matchRange) {
- super(id);
- this.fieldDef = fieldDef;
- this.matchRange = matchRange;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- add(new HighlightableLabel("name", fieldDef.getName(), matchRange));
-
- add(new Label("type", fieldDef.getType()).setVisible(fieldDef.getType()!=null));
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/Java.g4 b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/Java.g4
deleted file mode 100644
index 796d4e2b38..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/Java.g4
+++ /dev/null
@@ -1,1780 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * A Java 8 grammar for ANTLR 4 derived from the Java Language Specification
- * chapter 19.
- *
- * NOTE: This grammar results in a generated parser that is much slower
- * than the Java 7 grammar in the grammars-v4/java directory. This
- * one is, however, extremely close to the spec.
- *
- * You can test with
- *
- * $ antlr4 Java8.g4
- * $ javac *.java
- * $ grun Java8 compilationUnit *.java
- *
- * Or,
-~/antlr/code/grammars-v4/java8 $ java Test .
-/Users/parrt/antlr/code/grammars-v4/java8/./Java8BaseListener.java
-/Users/parrt/antlr/code/grammars-v4/java8/./Java8Lexer.java
-/Users/parrt/antlr/code/grammars-v4/java8/./Java8Listener.java
-/Users/parrt/antlr/code/grammars-v4/java8/./Java8Parser.java
-/Users/parrt/antlr/code/grammars-v4/java8/./Test.java
-Total lexer+parser time 30844ms.
- */
-grammar Java;
-
-/*
- * Productions from §3 (Lexical Structure)
- */
-
-literal
- : IntegerLiteral
- | FloatingPointLiteral
- | BooleanLiteral
- | CharacterLiteral
- | StringLiteral
- | NullLiteral
- ;
-
-/*
- * Productions from §4 (Types, Values, and Variables)
- */
-
-
-type
- : primitiveType
- | referenceType
- ;
-
-primitiveType
- : annotation* numericType
- | annotation* 'boolean'
- ;
-
-numericType
- : integralType
- | floatingPointType
- ;
-
-integralType
- : 'byte'
- | 'short'
- | 'int'
- | 'long'
- | 'char'
- ;
-
-floatingPointType
- : 'float'
- | 'double'
- ;
-
-referenceType
- : classOrInterfaceType
- | typeVariable
- | arrayType
- ;
-
-classOrInterfaceType
- : ( classType_lfno_classOrInterfaceType
- | interfaceType_lfno_classOrInterfaceType
- )
- ( classType_lf_classOrInterfaceType
- | interfaceType_lf_classOrInterfaceType
- )*
- ;
-
-classType
- : annotation* Identifier typeArguments?
- | classOrInterfaceType '.' annotation* Identifier typeArguments?
- ;
-
-classType_lf_classOrInterfaceType
- : '.' annotation* Identifier typeArguments?
- ;
-
-classType_lfno_classOrInterfaceType
- : annotation* Identifier typeArguments?
- ;
-
-interfaceType
- : classType
- ;
-
-interfaceType_lf_classOrInterfaceType
- : classType_lf_classOrInterfaceType
- ;
-
-interfaceType_lfno_classOrInterfaceType
- : classType_lfno_classOrInterfaceType
- ;
-
-typeVariable
- : annotation* Identifier
- ;
-
-arrayType
- : primitiveType dims
- | classOrInterfaceType dims
- | typeVariable dims
- ;
-
-dims
- : annotation* '[' ']' (annotation* '[' ']')*
- ;
-
-typeParameter
- : typeParameterModifier* Identifier typeBound?
- ;
-
-typeParameterModifier
- : annotation
- ;
-
-typeBound
- : 'extends' typeVariable
- | 'extends' classOrInterfaceType additionalBound*
- ;
-
-additionalBound
- : '&' interfaceType
- ;
-
-typeArguments
- : '<' typeArgumentList '>'
- ;
-
-typeArgumentList
- : typeArgument (',' typeArgument)*
- ;
-
-typeArgument
- : referenceType
- | wildcard
- ;
-
-wildcard
- : annotation* '?' wildcardBounds?
- ;
-
-wildcardBounds
- : 'extends' referenceType
- | 'super' referenceType
- ;
-
-/*
- * Productions from §6 (Names)
- */
-
-packageName
- : Identifier
- | packageName '.' Identifier
- ;
-
-typeName
- : Identifier
- | packageOrTypeName '.' Identifier
- ;
-
-packageOrTypeName
- : Identifier
- | packageOrTypeName '.' Identifier
- ;
-
-expressionName
- : Identifier
- | ambiguousName '.' Identifier
- ;
-
-methodName
- : Identifier
- ;
-
-ambiguousName
- : Identifier
- | ambiguousName '.' Identifier
- ;
-
-/*
- * Productions from §7 (Packages)
- */
-
-compilationUnit
- : packageDeclaration? importDeclaration* typeDeclaration* EOF
- ;
-
-packageDeclaration
- : packageModifier* 'package' Identifier ('.' Identifier)* ';'
- ;
-
-packageModifier
- : annotation
- ;
-
-importDeclaration
- : singleTypeImportDeclaration
- | typeImportOnDemandDeclaration
- | singleStaticImportDeclaration
- | staticImportOnDemandDeclaration
- ;
-
-singleTypeImportDeclaration
- : 'import' typeName ';'
- ;
-
-typeImportOnDemandDeclaration
- : 'import' packageOrTypeName '.' '*' ';'
- ;
-
-singleStaticImportDeclaration
- : 'import' 'static' typeName '.' Identifier ';'
- ;
-
-staticImportOnDemandDeclaration
- : 'import' 'static' typeName '.' '*' ';'
- ;
-
-typeDeclaration
- : classDeclaration
- | interfaceDeclaration
- | ';'
- ;
-
-/*
- * Productions from §8 (Classes)
- */
-
-classDeclaration
- : normalClassDeclaration
- | enumDeclaration
- ;
-
-normalClassDeclaration
- : classModifier* 'class' Identifier typeParameters? superclass? superinterfaces? classBody
- ;
-
-classModifier
- : annotation
- | 'public'
- | 'protected'
- | 'private'
- | 'abstract'
- | 'static'
- | 'final'
- | 'strictfp'
- ;
-
-typeParameters
- : '<' typeParameterList '>'
- ;
-
-typeParameterList
- : typeParameter (',' typeParameter)*
- ;
-
-superclass
- : 'extends' classType
- ;
-
-superinterfaces
- : 'implements' interfaceTypeList
- ;
-
-interfaceTypeList
- : interfaceType (',' interfaceType)*
- ;
-
-classBody
- : '{' classBodyDeclaration* '}'
- ;
-
-classBodyDeclaration
- : classMemberDeclaration
- | instanceInitializer
- | staticInitializer
- | constructorDeclaration
- ;
-
-classMemberDeclaration
- : fieldDeclaration
- | methodDeclaration
- | classDeclaration
- | interfaceDeclaration
- | ';'
- ;
-
-fieldDeclaration
- : fieldModifier* unannType variableDeclaratorList ';'
- ;
-
-fieldModifier
- : annotation
- | 'public'
- | 'protected'
- | 'private'
- | 'static'
- | 'final'
- | 'transient'
- | 'volatile'
- ;
-
-variableDeclaratorList
- : variableDeclarator (',' variableDeclarator)*
- ;
-
-variableDeclarator
- : variableDeclaratorId ('=' variableInitializer)?
- ;
-
-variableDeclaratorId
- : Identifier dims?
- ;
-
-variableInitializer
- : expression
- | arrayInitializer
- ;
-
-unannType
- : unannPrimitiveType
- | unannReferenceType
- ;
-
-unannPrimitiveType
- : numericType
- | 'boolean'
- ;
-
-unannReferenceType
- : unannClassOrInterfaceType
- | unannTypeVariable
- | unannArrayType
- ;
-
-unannClassOrInterfaceType
- : ( unannClassType_lfno_unannClassOrInterfaceType
- | unannInterfaceType_lfno_unannClassOrInterfaceType
- )
- ( unannClassType_lf_unannClassOrInterfaceType
- | unannInterfaceType_lf_unannClassOrInterfaceType
- )*
- ;
-
-unannClassType
- : Identifier typeArguments?
- | unannClassOrInterfaceType '.' annotation* Identifier typeArguments?
- ;
-
-unannClassType_lf_unannClassOrInterfaceType
- : '.' annotation* Identifier typeArguments?
- ;
-
-unannClassType_lfno_unannClassOrInterfaceType
- : Identifier typeArguments?
- ;
-
-unannInterfaceType
- : unannClassType
- ;
-
-unannInterfaceType_lf_unannClassOrInterfaceType
- : unannClassType_lf_unannClassOrInterfaceType
- ;
-
-unannInterfaceType_lfno_unannClassOrInterfaceType
- : unannClassType_lfno_unannClassOrInterfaceType
- ;
-
-unannTypeVariable
- : Identifier
- ;
-
-unannArrayType
- : unannPrimitiveType dims
- | unannClassOrInterfaceType dims
- | unannTypeVariable dims
- ;
-
-methodDeclaration
- : methodModifier* methodHeader methodBody
- ;
-
-methodModifier
- : annotation
- | 'public'
- | 'protected'
- | 'private'
- | 'abstract'
- | 'static'
- | 'final'
- | 'synchronized'
- | 'native'
- | 'strictfp'
- ;
-
-methodHeader
- : result methodDeclarator throws_?
- | typeParameters annotation* result methodDeclarator throws_?
- ;
-
-result
- : unannType
- | 'void'
- ;
-
-methodDeclarator
- : Identifier '(' formalParameterList? ')' dims?
- ;
-
-formalParameterList
- : formalParameters ',' lastFormalParameter
- | lastFormalParameter
- ;
-
-formalParameters
- : formalParameter (',' formalParameter)*
- | receiverParameter (',' formalParameter)*
- ;
-
-formalParameter
- : variableModifier* unannType variableDeclaratorId
- ;
-
-variableModifier
- : annotation
- | 'final'
- ;
-
-lastFormalParameter
- : variableModifier* unannType annotation* '...' variableDeclaratorId
- | formalParameter
- ;
-
-receiverParameter
- : annotation* unannType (Identifier '.')? 'this'
- ;
-
-throws_
- : 'throws' exceptionTypeList
- ;
-
-exceptionTypeList
- : exceptionType (',' exceptionType)*
- ;
-
-exceptionType
- : classType
- | typeVariable
- ;
-
-methodBody
- : block
- | ';'
- ;
-
-instanceInitializer
- : block
- ;
-
-staticInitializer
- : 'static' block
- ;
-
-constructorDeclaration
- : constructorModifier* constructorDeclarator throws_? constructorBody
- ;
-
-constructorModifier
- : annotation
- | 'public'
- | 'protected'
- | 'private'
- ;
-
-constructorDeclarator
- : typeParameters? simpleTypeName '(' formalParameterList? ')'
- ;
-
-simpleTypeName
- : Identifier
- ;
-
-constructorBody
- : '{' explicitConstructorInvocation? blockStatements? '}'
- ;
-
-explicitConstructorInvocation
- : typeArguments? 'this' '(' argumentList? ')' ';'
- | typeArguments? 'super' '(' argumentList? ')' ';'
- | expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';'
- | primary '.' typeArguments? 'super' '(' argumentList? ')' ';'
- ;
-
-enumDeclaration
- : classModifier* 'enum' Identifier superinterfaces? enumBody
- ;
-
-enumBody
- : '{' enumConstantList? ','? enumBodyDeclarations? '}'
- ;
-
-enumConstantList
- : enumConstant (',' enumConstant)*
- ;
-
-enumConstant
- : enumConstantModifier* Identifier ('(' argumentList? ')')? classBody?
- ;
-
-enumConstantModifier
- : annotation
- ;
-
-enumBodyDeclarations
- : ';' classBodyDeclaration*
- ;
-
-/*
- * Productions from §9 (Interfaces)
- */
-
-interfaceDeclaration
- : normalInterfaceDeclaration
- | annotationTypeDeclaration
- ;
-
-normalInterfaceDeclaration
- : interfaceModifier* 'interface' Identifier typeParameters? extendsInterfaces? interfaceBody
- ;
-
-interfaceModifier
- : annotation
- | 'public'
- | 'protected'
- | 'private'
- | 'abstract'
- | 'static'
- | 'strictfp'
- ;
-
-extendsInterfaces
- : 'extends' interfaceTypeList
- ;
-
-interfaceBody
- : '{' interfaceMemberDeclaration* '}'
- ;
-
-interfaceMemberDeclaration
- : constantDeclaration
- | interfaceMethodDeclaration
- | classDeclaration
- | interfaceDeclaration
- | ';'
- ;
-
-constantDeclaration
- : constantModifier* unannType variableDeclaratorList ';'
- ;
-
-constantModifier
- : annotation
- | 'public'
- | 'static'
- | 'final'
- ;
-
-interfaceMethodDeclaration
- : interfaceMethodModifier* methodHeader methodBody
- ;
-
-interfaceMethodModifier
- : annotation
- | 'public'
- | 'abstract'
- | 'default'
- | 'static'
- | 'strictfp'
- ;
-
-annotationTypeDeclaration
- : interfaceModifier* '@' 'interface' Identifier annotationTypeBody
- ;
-
-annotationTypeBody
- : '{' annotationTypeMemberDeclaration* '}'
- ;
-
-annotationTypeMemberDeclaration
- : annotationTypeElementDeclaration
- | constantDeclaration
- | classDeclaration
- | interfaceDeclaration
- | ';'
- ;
-
-annotationTypeElementDeclaration
- : annotationTypeElementModifier* unannType Identifier '(' ')' dims? defaultValue? ';'
- ;
-
-annotationTypeElementModifier
- : annotation
- | 'public'
- | 'abstract'
- ;
-
-defaultValue
- : 'default' elementValue
- ;
-
-annotation
- : normalAnnotation
- | markerAnnotation
- | singleElementAnnotation
- ;
-
-normalAnnotation
- : '@' typeName '(' elementValuePairList? ')'
- ;
-
-elementValuePairList
- : elementValuePair (',' elementValuePair)*
- ;
-
-elementValuePair
- : Identifier '=' elementValue
- ;
-
-elementValue
- : conditionalExpression
- | elementValueArrayInitializer
- | annotation
- ;
-
-elementValueArrayInitializer
- : '{' elementValueList? ','? '}'
- ;
-
-elementValueList
- : elementValue (',' elementValue)*
- ;
-
-markerAnnotation
- : '@' typeName
- ;
-
-singleElementAnnotation
- : '@' typeName '(' elementValue ')'
- ;
-
-/*
- * Productions from §10 (Arrays)
- */
-
-arrayInitializer
- : '{' variableInitializerList? ','? '}'
- ;
-
-variableInitializerList
- : variableInitializer (',' variableInitializer)*
- ;
-
-/*
- * Productions from §14 (Blocks and Statements)
- */
-
-block
- : '{' blockStatements? '}'
- ;
-
-blockStatements
- : blockStatement blockStatement*
- ;
-
-blockStatement
- : localVariableDeclarationStatement
- | classDeclaration
- | statement
- ;
-
-localVariableDeclarationStatement
- : localVariableDeclaration ';'
- ;
-
-localVariableDeclaration
- : variableModifier* unannType variableDeclaratorList
- ;
-
-statement
- : statementWithoutTrailingSubstatement
- | labeledStatement
- | ifThenStatement
- | ifThenElseStatement
- | whileStatement
- | forStatement
- ;
-
-statementNoShortIf
- : statementWithoutTrailingSubstatement
- | labeledStatementNoShortIf
- | ifThenElseStatementNoShortIf
- | whileStatementNoShortIf
- | forStatementNoShortIf
- ;
-
-statementWithoutTrailingSubstatement
- : block
- | emptyStatement
- | expressionStatement
- | assertStatement
- | switchStatement
- | doStatement
- | breakStatement
- | continueStatement
- | returnStatement
- | synchronizedStatement
- | throwStatement
- | tryStatement
- ;
-
-emptyStatement
- : ';'
- ;
-
-labeledStatement
- : Identifier ':' statement
- ;
-
-labeledStatementNoShortIf
- : Identifier ':' statementNoShortIf
- ;
-
-expressionStatement
- : statementExpression ';'
- ;
-
-statementExpression
- : assignment
- | preIncrementExpression
- | preDecrementExpression
- | postIncrementExpression
- | postDecrementExpression
- | methodInvocation
- | classInstanceCreationExpression
- ;
-
-ifThenStatement
- : 'if' '(' expression ')' statement
- ;
-
-ifThenElseStatement
- : 'if' '(' expression ')' statementNoShortIf 'else' statement
- ;
-
-ifThenElseStatementNoShortIf
- : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf
- ;
-
-assertStatement
- : 'assert' expression ';'
- | 'assert' expression ':' expression ';'
- ;
-
-switchStatement
- : 'switch' '(' expression ')' switchBlock
- ;
-
-switchBlock
- : '{' switchBlockStatementGroup* switchLabel* '}'
- ;
-
-switchBlockStatementGroup
- : switchLabels blockStatements
- ;
-
-switchLabels
- : switchLabel switchLabel*
- ;
-
-switchLabel
- : 'case' constantExpression ':'
- | 'case' enumConstantName ':'
- | 'default' ':'
- ;
-
-enumConstantName
- : Identifier
- ;
-
-whileStatement
- : 'while' '(' expression ')' statement
- ;
-
-whileStatementNoShortIf
- : 'while' '(' expression ')' statementNoShortIf
- ;
-
-doStatement
- : 'do' statement 'while' '(' expression ')' ';'
- ;
-
-forStatement
- : basicForStatement
- | enhancedForStatement
- ;
-
-forStatementNoShortIf
- : basicForStatementNoShortIf
- | enhancedForStatementNoShortIf
- ;
-
-basicForStatement
- : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement
- ;
-
-basicForStatementNoShortIf
- : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf
- ;
-
-forInit
- : statementExpressionList
- | localVariableDeclaration
- ;
-
-forUpdate
- : statementExpressionList
- ;
-
-statementExpressionList
- : statementExpression (',' statementExpression)*
- ;
-
-enhancedForStatement
- : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement
- ;
-
-enhancedForStatementNoShortIf
- : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf
- ;
-
-breakStatement
- : 'break' Identifier? ';'
- ;
-
-continueStatement
- : 'continue' Identifier? ';'
- ;
-
-returnStatement
- : 'return' expression? ';'
- ;
-
-throwStatement
- : 'throw' expression ';'
- ;
-
-synchronizedStatement
- : 'synchronized' '(' expression ')' block
- ;
-
-tryStatement
- : 'try' block catches
- | 'try' block catches? finally_
- | tryWithResourcesStatement
- ;
-
-catches
- : catchClause catchClause*
- ;
-
-catchClause
- : 'catch' '(' catchFormalParameter ')' block
- ;
-
-catchFormalParameter
- : variableModifier* catchType variableDeclaratorId
- ;
-
-catchType
- : unannClassType ('|' classType)*
- ;
-
-finally_
- : 'finally' block
- ;
-
-tryWithResourcesStatement
- : 'try' resourceSpecification block catches? finally_?
- ;
-
-resourceSpecification
- : '(' resourceList ';'? ')'
- ;
-
-resourceList
- : resource (';' resource)*
- ;
-
-resource
- : variableModifier* unannType variableDeclaratorId '=' expression
- ;
-
-/*
- * Productions from §15 (Expressions)
- */
-
-primary
- : ( primaryNoNewArray_lfno_primary
- | arrayCreationExpression
- )
- ( primaryNoNewArray_lf_primary
- )*
- ;
-
-primaryNoNewArray
- : literal
- | typeName ('[' ']')* '.' 'class'
- | 'void' '.' 'class'
- | 'this'
- | typeName '.' 'this'
- | '(' expression ')'
- | classInstanceCreationExpression
- | fieldAccess
- | arrayAccess
- | methodInvocation
- | methodReference
- ;
-
-primaryNoNewArray_lf_arrayAccess
- :
- ;
-
-primaryNoNewArray_lfno_arrayAccess
- : literal
- | typeName ('[' ']')* '.' 'class'
- | 'void' '.' 'class'
- | 'this'
- | typeName '.' 'this'
- | '(' expression ')'
- | classInstanceCreationExpression
- | fieldAccess
- | methodInvocation
- | methodReference
- ;
-
-primaryNoNewArray_lf_primary
- : classInstanceCreationExpression_lf_primary
- | fieldAccess_lf_primary
- | arrayAccess_lf_primary
- | methodInvocation_lf_primary
- | methodReference_lf_primary
- ;
-
-primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary
- :
- ;
-
-primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary
- : classInstanceCreationExpression_lf_primary
- | fieldAccess_lf_primary
- | methodInvocation_lf_primary
- | methodReference_lf_primary
- ;
-
-primaryNoNewArray_lfno_primary
- : literal
- | typeName ('[' ']')* '.' 'class'
- | unannPrimitiveType ('[' ']')* '.' 'class'
- | 'void' '.' 'class'
- | 'this'
- | typeName '.' 'this'
- | '(' expression ')'
- | classInstanceCreationExpression_lfno_primary
- | fieldAccess_lfno_primary
- | arrayAccess_lfno_primary
- | methodInvocation_lfno_primary
- | methodReference_lfno_primary
- ;
-
-primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary
- :
- ;
-
-primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary
- : literal
- | typeName ('[' ']')* '.' 'class'
- | unannPrimitiveType ('[' ']')* '.' 'class'
- | 'void' '.' 'class'
- | 'this'
- | typeName '.' 'this'
- | '(' expression ')'
- | classInstanceCreationExpression_lfno_primary
- | fieldAccess_lfno_primary
- | methodInvocation_lfno_primary
- | methodReference_lfno_primary
- ;
-
-classInstanceCreationExpression
- : 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
- | expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
- | primary '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
- ;
-
-classInstanceCreationExpression_lf_primary
- : '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
- ;
-
-classInstanceCreationExpression_lfno_primary
- : 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
- | expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
- ;
-
-typeArgumentsOrDiamond
- : typeArguments
- | '<' '>'
- ;
-
-fieldAccess
- : primary '.' Identifier
- | 'super' '.' Identifier
- | typeName '.' 'super' '.' Identifier
- ;
-
-fieldAccess_lf_primary
- : '.' Identifier
- ;
-
-fieldAccess_lfno_primary
- : 'super' '.' Identifier
- | typeName '.' 'super' '.' Identifier
- ;
-
-arrayAccess
- : ( expressionName '[' expression ']'
- | primaryNoNewArray_lfno_arrayAccess '[' expression ']'
- )
- ( primaryNoNewArray_lf_arrayAccess '[' expression ']'
- )*
- ;
-
-arrayAccess_lf_primary
- : ( primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']'
- )
- ( primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']'
- )*
- ;
-
-arrayAccess_lfno_primary
- : ( expressionName '[' expression ']'
- | primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']'
- )
- ( primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']'
- )*
- ;
-
-methodInvocation
- : methodName '(' argumentList? ')'
- | typeName '.' typeArguments? Identifier '(' argumentList? ')'
- | expressionName '.' typeArguments? Identifier '(' argumentList? ')'
- | primary '.' typeArguments? Identifier '(' argumentList? ')'
- | 'super' '.' typeArguments? Identifier '(' argumentList? ')'
- | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')'
- ;
-
-methodInvocation_lf_primary
- : '.' typeArguments? Identifier '(' argumentList? ')'
- ;
-
-methodInvocation_lfno_primary
- : methodName '(' argumentList? ')'
- | typeName '.' typeArguments? Identifier '(' argumentList? ')'
- | expressionName '.' typeArguments? Identifier '(' argumentList? ')'
- | 'super' '.' typeArguments? Identifier '(' argumentList? ')'
- | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')'
- ;
-
-argumentList
- : expression (',' expression)*
- ;
-
-methodReference
- : expressionName '::' typeArguments? Identifier
- | referenceType '::' typeArguments? Identifier
- | primary '::' typeArguments? Identifier
- | 'super' '::' typeArguments? Identifier
- | typeName '.' 'super' '::' typeArguments? Identifier
- | classType '::' typeArguments? 'new'
- | arrayType '::' 'new'
- ;
-
-methodReference_lf_primary
- : '::' typeArguments? Identifier
- ;
-
-methodReference_lfno_primary
- : expressionName '::' typeArguments? Identifier
- | referenceType '::' typeArguments? Identifier
- | 'super' '::' typeArguments? Identifier
- | typeName '.' 'super' '::' typeArguments? Identifier
- | classType '::' typeArguments? 'new'
- | arrayType '::' 'new'
- ;
-
-arrayCreationExpression
- : 'new' primitiveType dimExprs dims?
- | 'new' classOrInterfaceType dimExprs dims?
- | 'new' primitiveType dims arrayInitializer
- | 'new' classOrInterfaceType dims arrayInitializer
- ;
-
-dimExprs
- : dimExpr dimExpr*
- ;
-
-dimExpr
- : annotation* '[' expression ']'
- ;
-
-constantExpression
- : expression
- ;
-
-expression
- : lambdaExpression
- | assignmentExpression
- ;
-
-lambdaExpression
- : lambdaParameters '->' lambdaBody
- ;
-
-lambdaParameters
- : Identifier
- | '(' formalParameterList? ')'
- | '(' inferredFormalParameterList ')'
- ;
-
-inferredFormalParameterList
- : Identifier (',' Identifier)*
- ;
-
-lambdaBody
- : expression
- | block
- ;
-
-assignmentExpression
- : conditionalExpression
- | assignment
- ;
-
-assignment
- : leftHandSide assignmentOperator expression
- ;
-
-leftHandSide
- : expressionName
- | fieldAccess
- | arrayAccess
- ;
-
-assignmentOperator
- : '='
- | '*='
- | '/='
- | '%='
- | '+='
- | '-='
- | '<<='
- | '>>='
- | '>>>='
- | '&='
- | '^='
- | '|='
- ;
-
-conditionalExpression
- : conditionalOrExpression
- | conditionalOrExpression '?' expression ':' conditionalExpression
- ;
-
-conditionalOrExpression
- : conditionalAndExpression
- | conditionalOrExpression '||' conditionalAndExpression
- ;
-
-conditionalAndExpression
- : inclusiveOrExpression
- | conditionalAndExpression '&&' inclusiveOrExpression
- ;
-
-inclusiveOrExpression
- : exclusiveOrExpression
- | inclusiveOrExpression '|' exclusiveOrExpression
- ;
-
-exclusiveOrExpression
- : andExpression
- | exclusiveOrExpression '^' andExpression
- ;
-
-andExpression
- : equalityExpression
- | andExpression '&' equalityExpression
- ;
-
-equalityExpression
- : relationalExpression
- | equalityExpression '==' relationalExpression
- | equalityExpression '!=' relationalExpression
- ;
-
-relationalExpression
- : shiftExpression
- | relationalExpression '<' shiftExpression
- | relationalExpression '>' shiftExpression
- | relationalExpression '<=' shiftExpression
- | relationalExpression '>=' shiftExpression
- | relationalExpression 'instanceof' referenceType
- ;
-
-shiftExpression
- : additiveExpression
- | shiftExpression '<' '<' additiveExpression
- | shiftExpression '>' '>' additiveExpression
- | shiftExpression '>' '>' '>' additiveExpression
- ;
-
-additiveExpression
- : multiplicativeExpression
- | additiveExpression '+' multiplicativeExpression
- | additiveExpression '-' multiplicativeExpression
- ;
-
-multiplicativeExpression
- : unaryExpression
- | multiplicativeExpression '*' unaryExpression
- | multiplicativeExpression '/' unaryExpression
- | multiplicativeExpression '%' unaryExpression
- ;
-
-unaryExpression
- : preIncrementExpression
- | preDecrementExpression
- | '+' unaryExpression
- | '-' unaryExpression
- | unaryExpressionNotPlusMinus
- ;
-
-preIncrementExpression
- : '++' unaryExpression
- ;
-
-preDecrementExpression
- : '--' unaryExpression
- ;
-
-unaryExpressionNotPlusMinus
- : postfixExpression
- | '~' unaryExpression
- | '!' unaryExpression
- | castExpression
- ;
-
-postfixExpression
- : ( primary
- | expressionName
- )
- ( postIncrementExpression_lf_postfixExpression
- | postDecrementExpression_lf_postfixExpression
- )*
- ;
-
-postIncrementExpression
- : postfixExpression '++'
- ;
-
-postIncrementExpression_lf_postfixExpression
- : '++'
- ;
-
-postDecrementExpression
- : postfixExpression '--'
- ;
-
-postDecrementExpression_lf_postfixExpression
- : '--'
- ;
-
-castExpression
- : '(' primitiveType ')' unaryExpression
- | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus
- | '(' referenceType additionalBound* ')' lambdaExpression
- ;
-
-// LEXER
-
-// §3.9 Keywords
-
-ABSTRACT : 'abstract';
-ASSERT : 'assert';
-BOOLEAN : 'boolean';
-BREAK : 'break';
-BYTE : 'byte';
-CASE : 'case';
-CATCH : 'catch';
-CHAR : 'char';
-CLASS : 'class';
-CONST : 'const';
-CONTINUE : 'continue';
-DEFAULT : 'default';
-DO : 'do';
-DOUBLE : 'double';
-ELSE : 'else';
-ENUM : 'enum';
-EXTENDS : 'extends';
-FINAL : 'final';
-FINALLY : 'finally';
-FLOAT : 'float';
-FOR : 'for';
-IF : 'if';
-GOTO : 'goto';
-IMPLEMENTS : 'implements';
-IMPORT : 'import';
-INSTANCEOF : 'instanceof';
-INT : 'int';
-INTERFACE : 'interface';
-LONG : 'long';
-NATIVE : 'native';
-NEW : 'new';
-PACKAGE : 'package';
-PRIVATE : 'private';
-PROTECTED : 'protected';
-PUBLIC : 'public';
-RETURN : 'return';
-SHORT : 'short';
-STATIC : 'static';
-STRICTFP : 'strictfp';
-SUPER : 'super';
-SWITCH : 'switch';
-SYNCHRONIZED : 'synchronized';
-THIS : 'this';
-THROW : 'throw';
-THROWS : 'throws';
-TRANSIENT : 'transient';
-TRY : 'try';
-VOID : 'void';
-VOLATILE : 'volatile';
-WHILE : 'while';
-
-// §3.10.1 Integer Literals
-
-IntegerLiteral
- : DecimalIntegerLiteral
- | HexIntegerLiteral
- | OctalIntegerLiteral
- | BinaryIntegerLiteral
- ;
-
-fragment
-DecimalIntegerLiteral
- : DecimalNumeral IntegerTypeSuffix?
- ;
-
-fragment
-HexIntegerLiteral
- : HexNumeral IntegerTypeSuffix?
- ;
-
-fragment
-OctalIntegerLiteral
- : OctalNumeral IntegerTypeSuffix?
- ;
-
-fragment
-BinaryIntegerLiteral
- : BinaryNumeral IntegerTypeSuffix?
- ;
-
-fragment
-IntegerTypeSuffix
- : [lL]
- ;
-
-fragment
-DecimalNumeral
- : '0'
- | NonZeroDigit (Digits? | Underscores Digits)
- ;
-
-fragment
-Digits
- : Digit (DigitsAndUnderscores? Digit)?
- ;
-
-fragment
-Digit
- : '0'
- | NonZeroDigit
- ;
-
-fragment
-NonZeroDigit
- : [1-9]
- ;
-
-fragment
-DigitsAndUnderscores
- : DigitOrUnderscore+
- ;
-
-fragment
-DigitOrUnderscore
- : Digit
- | '_'
- ;
-
-fragment
-Underscores
- : '_'+
- ;
-
-fragment
-HexNumeral
- : '0' [xX] HexDigits
- ;
-
-fragment
-HexDigits
- : HexDigit (HexDigitsAndUnderscores? HexDigit)?
- ;
-
-fragment
-HexDigit
- : [0-9a-fA-F]
- ;
-
-fragment
-HexDigitsAndUnderscores
- : HexDigitOrUnderscore+
- ;
-
-fragment
-HexDigitOrUnderscore
- : HexDigit
- | '_'
- ;
-
-fragment
-OctalNumeral
- : '0' Underscores? OctalDigits
- ;
-
-fragment
-OctalDigits
- : OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?
- ;
-
-fragment
-OctalDigit
- : [0-7]
- ;
-
-fragment
-OctalDigitsAndUnderscores
- : OctalDigitOrUnderscore+
- ;
-
-fragment
-OctalDigitOrUnderscore
- : OctalDigit
- | '_'
- ;
-
-fragment
-BinaryNumeral
- : '0' [bB] BinaryDigits
- ;
-
-fragment
-BinaryDigits
- : BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?
- ;
-
-fragment
-BinaryDigit
- : [01]
- ;
-
-fragment
-BinaryDigitsAndUnderscores
- : BinaryDigitOrUnderscore+
- ;
-
-fragment
-BinaryDigitOrUnderscore
- : BinaryDigit
- | '_'
- ;
-
-// §3.10.2 Floating-Point Literals
-
-FloatingPointLiteral
- : DecimalFloatingPointLiteral
- | HexadecimalFloatingPointLiteral
- ;
-
-fragment
-DecimalFloatingPointLiteral
- : Digits '.' Digits? ExponentPart? FloatTypeSuffix?
- | '.' Digits ExponentPart? FloatTypeSuffix?
- | Digits ExponentPart FloatTypeSuffix?
- | Digits FloatTypeSuffix
- ;
-
-fragment
-ExponentPart
- : ExponentIndicator SignedInteger
- ;
-
-fragment
-ExponentIndicator
- : [eE]
- ;
-
-fragment
-SignedInteger
- : Sign? Digits
- ;
-
-fragment
-Sign
- : [+-]
- ;
-
-fragment
-FloatTypeSuffix
- : [fFdD]
- ;
-
-fragment
-HexadecimalFloatingPointLiteral
- : HexSignificand BinaryExponent FloatTypeSuffix?
- ;
-
-fragment
-HexSignificand
- : HexNumeral '.'?
- | '0' [xX] HexDigits? '.' HexDigits
- ;
-
-fragment
-BinaryExponent
- : BinaryExponentIndicator SignedInteger
- ;
-
-fragment
-BinaryExponentIndicator
- : [pP]
- ;
-
-// §3.10.3 Boolean Literals
-
-BooleanLiteral
- : 'true'
- | 'false'
- ;
-
-// §3.10.4 Character Literals
-
-CharacterLiteral
- : '\'' SingleCharacter '\''
- | '\'' EscapeSequence '\''
- ;
-
-fragment
-SingleCharacter
- : ~['\\]
- ;
-
-// §3.10.5 String Literals
-
-StringLiteral
- : '"' StringCharacters? '"'
- ;
-
-fragment
-StringCharacters
- : StringCharacter+
- ;
-
-fragment
-StringCharacter
- : ~["\\]
- | EscapeSequence
- ;
-
-// §3.10.6 Escape Sequences for Character and String Literals
-
-fragment
-EscapeSequence
- : '\\' [btnfr"'\\]
- | OctalEscape
- | UnicodeEscape // This is not in the spec but prevents having to preprocess the input
- ;
-
-fragment
-OctalEscape
- : '\\' OctalDigit
- | '\\' OctalDigit OctalDigit
- | '\\' ZeroToThree OctalDigit OctalDigit
- ;
-
-fragment
-ZeroToThree
- : [0-3]
- ;
-
-// This is not in the spec but prevents having to preprocess the input
-fragment
-UnicodeEscape
- : '\\' 'u' HexDigit HexDigit HexDigit HexDigit
- ;
-
-// §3.10.7 The Null Literal
-
-NullLiteral
- : 'null'
- ;
-
-// §3.11 Separators
-
-LPAREN : '(';
-RPAREN : ')';
-LBRACE : '{';
-RBRACE : '}';
-LBRACK : '[';
-RBRACK : ']';
-SEMI : ';';
-COMMA : ',';
-DOT : '.';
-
-// §3.12 Operators
-
-ASSIGN : '=';
-GT : '>';
-LT : '<';
-BANG : '!';
-TILDE : '~';
-QUESTION : '?';
-COLON : ':';
-EQUAL : '==';
-LE : '<=';
-GE : '>=';
-NOTEQUAL : '!=';
-AND : '&&';
-OR : '||';
-INC : '++';
-DEC : '--';
-ADD : '+';
-SUB : '-';
-MUL : '*';
-DIV : '/';
-BITAND : '&';
-BITOR : '|';
-CARET : '^';
-MOD : '%';
-ARROW : '->';
-COLONCOLON : '::';
-
-ADD_ASSIGN : '+=';
-SUB_ASSIGN : '-=';
-MUL_ASSIGN : '*=';
-DIV_ASSIGN : '/=';
-AND_ASSIGN : '&=';
-OR_ASSIGN : '|=';
-XOR_ASSIGN : '^=';
-MOD_ASSIGN : '%=';
-LSHIFT_ASSIGN : '<<=';
-RSHIFT_ASSIGN : '>>=';
-URSHIFT_ASSIGN : '>>>=';
-
-// §3.8 Identifiers (must appear after all keywords in the grammar)
-
-Identifier
- : JavaLetter JavaLetterOrDigit*
- ;
-
-fragment
-JavaLetter
- : [a-zA-Z$_] // these are the "java letters" below 0xFF
- | // covers all characters above 0xFF which are not a surrogate
- ~[\u0000-\u00FF\uD800-\uDBFF]
- {Character.isJavaIdentifierStart(_input.LA(-1))}?
- | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
- [\uD800-\uDBFF] [\uDC00-\uDFFF]
- {Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
- ;
-
-fragment
-JavaLetterOrDigit
- : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0xFF
- | // covers all characters above 0xFF which are not a surrogate
- ~[\u0000-\u00FF\uD800-\uDBFF]
- {Character.isJavaIdentifierPart(_input.LA(-1))}?
- | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
- [\uD800-\uDBFF] [\uDC00-\uDFFF]
- {Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
- ;
-
-//
-// Additional symbols not defined in the lexical specification
-//
-
-AT : '@';
-ELLIPSIS : '...';
-
-//
-// Whitespace and comments
-//
-
-WS : [ \t\r\n\u000C]+ -> channel(HIDDEN)
- ;
-
-COMMENT
- : '/*' .*? '*/' -> channel(HIDDEN)
- ;
-
-LINE_COMMENT
- : '//' ~[\r\n]* -> channel(HIDDEN)
- ;
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/JavaExtractor.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/JavaExtractor.java
deleted file mode 100644
index 898dbb21ff..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/JavaExtractor.java
+++ /dev/null
@@ -1,590 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import static com.gitplex.commons.lang.extractors.java.JavaLexer.*;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Nullable;
-
-import org.antlr.v4.runtime.ANTLRInputStream;
-
-import com.gitplex.commons.lang.extractors.AbstractExtractor;
-import com.gitplex.commons.lang.extractors.TokenStream;
-import com.gitplex.commons.lang.extractors.Token;
-import com.gitplex.commons.lang.extractors.Symbol;
-import com.gitplex.commons.lang.extractors.TokenFilter;
-import com.gitplex.commons.lang.extractors.TokenPosition;
-import com.gitplex.commons.util.Pair;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.gitplex.commons.lang.extractors.java.JavaLexer;
-
-public class JavaExtractor extends AbstractExtractor {
-
- private static final int[] PRIMITIVES = new int[]{
- FLOAT, INT, LONG, BOOLEAN, CHAR, BYTE, SHORT, DOUBLE, VOID};
-
- private static final Map<Integer, Integer> CLOSED_TYPES =
- ImmutableMap.of(LBRACE, RBRACE, LBRACK, RBRACK, LPAREN, RPAREN, LT, GT);
-
- /*
- * Analyze specified text.
- *
- * @before-token: start of file
- * @after-token: EOF
- *
- */
- public List<Symbol> extract(String text) {
- TokenStream stream = new TokenStream(
- new JavaLexer(new ANTLRInputStream(text)), TokenFilter.DEFAULT_CHANNEL);
-
- List<Symbol> symbols = new ArrayList<>();
-
- Token token = stream.next();
-
- while (token.is(AT) && !stream.lookAhead(1).is(INTERFACE)) {
- skipAnnotation(stream);
- token = stream.current();
- }
-
- CompilationUnit compilationUnit;
- if (token.is(PACKAGE)) {
- TokenPosition pos = token.getPos();
- token = stream.next();
- String packageName = skipTypeName(stream);
- compilationUnit = new CompilationUnit(packageName, pos);
- token = stream.next();
- } else {
- compilationUnit = new CompilationUnit(null, null);
- }
-
- symbols.add(compilationUnit);
-
- while (token.is(IMPORT)) {
- token = stream.nextType(SEMI);
- token = stream.next();
- }
-
- while(true) {
- while (token.is(SEMI))
- token = stream.next();
- if (!token.isEof()) {
- List<Modifier> modifiers = skipModifiers(stream);
- defineType(stream, symbols, null, compilationUnit.getPackageName(), modifiers);
- token = stream.next();
- } else {
- break;
- }
- }
-
- return symbols;
- }
-
- /*
- * Populate typeDef with various members in the type and then skip to end of the body.
- *
- * @before-token: '{' or ';' (';' occurs inside of a enum definition)
- * @after-token: '}'
- */
- private void defineTypeBody(TokenStream stream, List<Symbol> symbols, TypeDef parent, String packageName) {
- Token token = stream.next();
- while(true) {
- while (token.is(SEMI))
- token = stream.next();
- if (token.is(LBRACE)) { // instance initializer
- stream.nextClosed(LBRACE, RBRACE);
- token = stream.next();
- } else if (token.is(STATIC) && stream.lookAhead(1).is(LBRACE)) { // static initializer
- stream.next();
- stream.nextClosed(LBRACE, RBRACE);
- token = stream.next();
- } else if (token.is(RBRACE)) {
- break;
- } else {
- List<Modifier> modifiers = skipModifiers(stream);
- token = stream.current();
- if (token.is(LT)) { // skip type params of constructor or method
- stream.nextClosed(LT, GT);
- token = stream.next();
- }
- if (token.is(CLASS, INTERFACE, ENUM) || token.is(AT) && stream.lookAhead(1).is(INTERFACE)) {
- defineType(stream, symbols, parent, packageName, modifiers);
- } else {
- skipModifiers(stream); // skip annotations applied to method return type
- token = stream.current();
- if (token.getText().equals(parent.getName()) && stream.lookAhead(1).is(LPAREN)) {
- // this is a constructor
- defineMethod(stream, symbols, parent, modifiers, null);
- } else {
- String typeRef = skipTypeRef(stream);
- token = stream.current();
- if (token.is(Identifier) && stream.lookAhead(1).is(LPAREN))
- defineMethod(stream, symbols, parent, modifiers, typeRef);
- else
- defineFields(stream, symbols, parent, modifiers, typeRef);
- }
- }
- token = stream.next();
- }
- }
-
- }
-
- /*
- * Skip value assigned to a field. We either need to skip to next ';' (end of current statement)
- * or ',' (separator of field declaration). After stripping all top scopes ('[...]', '{...}',
- * '(...)') before encountering ',' or ';', we can guarantee that ';' will not be contained in value,
- * however ',' can still appear in value in below form:
- * ...new HashMap<String, String>...
- * Also we can not strip scope '<...>' to remove this possibility as '<' '>' can also be used as
- * conditional operators in value expression (for instance: 2>1?a:b). So we assume encountered ','
- * as field separator first, and continue with our analyzing until our assumption is proved to be
- * true or false. True assumption will result in over skipping and it will return a list of
- * subsequent encountered field names, while false assumption does no harm, as we simply move on
- * to next comma in the loop.
- *
- * @before-token: start of value
- * @after-token: next token after value
- *
- * @return
- * list of subsequent field names if skipping value caused multiple
- * fields to be consumed
- *
- */
- private List<Pair<Token, String>> skipValue(TokenStream stream) {
- List<Pair<Token, String>> fieldInfos = new ArrayList<>();
- Token token = stream.current();
- if (token.is(LBRACE)) { // array value
- stream.nextClosed(LBRACE, RBRACE);
- stream.next();
- return fieldInfos;
- } else {
- while (true) {
- token = stream.nextType(COMMA, SEMI, LBRACE, LBRACK, LPAREN);
- if (token.is(LBRACE, LBRACK, LPAREN)) {
- // skip scopes and the only case for comma inside a value is inside type arguments like below:
- // ... new HashMap<String, String>...
- stream.nextClosed(token.getType(), CLOSED_TYPES.get(token.getType()));
- } else if (token.is(SEMI)) {
- break;
- } else { // token is ','
- token.checkType(COMMA);
- List<Pair<Token, String>> subsequentFieldTokens = assumeFieldSeparator(stream);
- if (subsequentFieldTokens != null) { // assumption is correct
- fieldInfos.addAll(subsequentFieldTokens);
- break;
- }
- }
- }
- return fieldInfos;
- }
- }
-
- /*
- * Assume current token is field separator and continue to analyze the stream. Upon
- * analyzing surprise, we return a null value to indicate the assumption is incorrect.
- *
- * @before-token: ','
- * @after-token: next field separator (',') or ';' if assumption is
- * correct; or any position in middle of value if
- * assumption is incorrect
- *
- * @return
- * list of encountered subsequent field tokens and array indicators if assumption is correct, or
- * null if assumption is incorrect
- *
- */
- private List<Pair<Token, String>> assumeFieldSeparator(TokenStream stream) {
- while (true) {
- Token token = stream.next();
- if (token.is(Identifier)) {
- List<Pair<Token, String>> fieldInfos = new ArrayList<>();
- stream.next();
- fieldInfos.add(new Pair<Token, String>(token, skipDims(stream)));
- token = stream.current();
- if (token.is(ASSIGN)) { // assumption convinced
- stream.next();
- fieldInfos.addAll(skipValue(stream));
- return fieldInfos;
- } else if (token.is(SEMI)) { // assumption convinced
- return fieldInfos;
- } else if (token.is(COMMA)) { // assumption still not convinced
- List<Pair<Token, String>> subsequentFieldInfos = assumeFieldSeparator(stream);
- if (subsequentFieldInfos != null) {
- fieldInfos.addAll(subsequentFieldInfos);
- return fieldInfos;
- } else {
- return null;
- }
- } else { // assumption is incorrect
- return null;
- }
- } else { // assumption is incorrect
- return null;
- }
- }
- }
-
- /*
- * Skip possible dims.
- *
- * @before-token: start of possible dims
- * @after-token: next token after dims, or remain unchanged if no dims
- */
- private String skipDims(TokenStream stream) {
- String dims = "";
- while (true) {
- skipAnnotations(stream);
- Token token = stream.current();
- if (token.is(LBRACK)) {
- dims += "[]";
- stream.nextClosed(LBRACK, RBRACK);
- stream.next();
- } else {
- break;
- }
- }
- return dims;
- }
-
- /*
- * Skip type reference.
- *
- * @before-token: start of type ref
- * @after-token: next token after type ref
- */
- private String skipTypeRef(TokenStream stream) {
- Token token = stream.current();
- String typeRef = token.getText();
- if (token.is(PRIMITIVES)) {
- stream.next();
- } else {
- typeRef = skipTypeRefSegment(stream);
- token = stream.current();
- while (token.is(DOT)) {
- typeRef += ".";
- stream.next();
- typeRef += skipTypeRefSegment(stream);
- token = stream.current();
- }
- }
- typeRef += skipDims(stream);
- return typeRef;
- }
-
- /*
- * Skip type ref segment.
- *
- * @begin-token: start of a type ref segment including possible annotations
- * @end-token: next token after type ref segment
- */
- private String skipTypeRefSegment(TokenStream stream) {
- skipModifiers(stream);
- String identifier = stream.current().getText();
- Token token = stream.next();
- if (token.is(LT)) {
- int tokenPos = stream.index();
- stream.nextClosed(LT, GT);
- TokenStream typeArgStream = new TokenStream(stream.between(tokenPos, stream.index()));
- token = typeArgStream.next();
- while (true) {
- skipModifiers(typeArgStream);
- token = typeArgStream.current();
- if (token.isEof())
- break;
- else
- identifier += token.getText();
- token = typeArgStream.next();
- }
- stream.next();
- }
- return identifier;
- }
-
- /*
- * Define a method or constructor.
- *
- * @before-token: identifier of the method
- * @after-token: '}' for class method, ';' for interface method or annotation attribute
- */
- private void defineMethod(TokenStream stream, List<Symbol> symbols, TypeDef parent,
- List<Modifier> modifiers, @Nullable String typeRef) {
- Token token = stream.current();
- String name = token.getText();
- TokenPosition pos = token.getPos();
- String params = null;
- String type = null;
-
- stream.next().checkType(LPAREN); // '('
- token = stream.next();
- while (!token.is(RPAREN)) {
- skipModifiers(stream);
- String paramType = skipTypeRef(stream);
- skipModifiers(stream); // skip possible annotation applied to '...'
- token = stream.current();
- if (token.is(ELLIPSIS)) { // varargs
- paramType += "...";
- token = stream.next();
- if (token.is(Identifier))
- token = stream.next();
- } else if (token.is(THIS)) { // Receiver parameter
- token = stream.next();
- paramType = null;
- } else if (token.is(Identifier) && stream.lookAhead(1).is(DOT)) { // Receiver parameter
- stream.next().checkType(DOT); // '.'
- stream.next().checkType(THIS); // 'this'
- token = stream.next();
- paramType = null;
- } else if (token.is(Identifier)) {
- token = stream.next();
- paramType += skipDims(stream);
- token = stream.current();
- } else { // No identifier, this is toString() version of MethodDef
-
- }
- if (paramType != null) {
- if (params != null)
- params += ", " + paramType;
- else
- params = paramType;
- }
- if (token.is(COMMA))
- token = stream.next();
- }
- token = stream.next();
- if (typeRef != null)
- type = typeRef + skipDims(stream);
-
- token = stream.current();
- if (token.is(THROWS)) {
- while (true) {
- token = stream.nextType(SEMI, LBRACE, LPAREN);
- if (token.is(LPAREN)) {
- stream.nextClosed(LPAREN, RPAREN);
- token = stream.next();
- } else {
- break;
- }
- }
- } else if (token.is(DEFAULT)) {
- stream.nextType(SEMI);
- }
-
- token = stream.current();
-
- if (token.is(LBRACE))
- stream.nextClosed(LBRACE, RBRACE);
-
- symbols.add(new MethodDef(parent, name, pos, type, params, modifiers));
- }
-
- /*
- * Define fields declared in a single statement.
- *
- * @before-token: identifier of field declaration statement
- * @after-token: end of fields declaration statement, which is ';'
- */
- private void defineFields(TokenStream stream, List<Symbol> symbols, TypeDef parent,
- List<Modifier> modifiers, String typeRef) {
- Token token = stream.current();
- while (!token.is(SEMI)) {
- stream.next();
- symbols.add(new FieldDef(parent, token.getText(), token.getPos(), typeRef + skipDims(stream), modifiers));
- token = stream.current();
- if (token.is(ASSIGN)) {
- stream.next();
- for (Pair<Token, String> fieldInfo: skipValue(stream)) {
- symbols.add(new FieldDef(parent, fieldInfo.getFirst().getText(), fieldInfo.getFirst().getPos(),
- typeRef + fieldInfo.getSecond(), modifiers));
- }
- token = stream.current();
- }
- if (token.is(COMMA))
- token = stream.next();
- }
- }
-
- /*
- * Define a type.
- *
- * @before-token: 'class', 'interface', 'enum', or '@interface'
- * @after-token: '}'
- */
- private void defineType(TokenStream stream, List<Symbol> symbols, Symbol parent, String packageName, List<Modifier> modifiers) {
- Token token = stream.current();
- if (token.is(AT) && stream.lookAhead(1).is(INTERFACE)) {
- stream.next().checkType(INTERFACE); // 'interface'
- stream.next().checkType(Identifier); // identifier
- token = defineTypeHead(stream);
- TypeDef typeDef = new TypeDef(parent, packageName, token.getText(), token.getPos(), TypeDef.Kind.ANNOTATION, modifiers);
- symbols.add(typeDef);
- defineTypeBody(stream, symbols, typeDef, packageName);
- } else if (token.is(CLASS)) {
- stream.next().checkType(Identifier); // identifier
- token = defineTypeHead(stream);
- TypeDef typeDef = new TypeDef(parent, packageName, token.getText(), token.getPos(), TypeDef.Kind.CLASS, modifiers);
- symbols.add(typeDef);
- defineTypeBody(stream, symbols, typeDef, packageName);
- } else if (token.is(INTERFACE)) {
- stream.next().checkType(Identifier); // identifier
- token = defineTypeHead(stream);
- TypeDef typeDef = new TypeDef(parent, packageName, token.getText(), token.getPos(), TypeDef.Kind.INTERFACE, modifiers);
- symbols.add(typeDef);
- defineTypeBody(stream, symbols, typeDef, packageName);
- } else {
- stream.next().checkType(Identifier); // identifier
- token = defineTypeHead(stream);
- TypeDef typeDef = new TypeDef(parent, packageName, token.getText(), token.getPos(), TypeDef.Kind.ENUM, modifiers);
- symbols.add(typeDef);
-
- // process enum constants
- token = stream.next();
- while (true) {
- if (token.is(SEMI, RBRACE)) {
- break;
- } else if (token.is(COMMA)) {
- token = stream.next();
- } else {
- skipModifiers(stream); // skip annotations
-
- symbols.add(new FieldDef(typeDef, stream.current().getText(), stream.current().getPos(),
- null, Lists.newArrayList(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)));
- token = stream.next();
- if (token.is(LPAREN)) { // enum constant arguments
- stream.nextClosed(LPAREN, RPAREN);
- token = stream.next();
- }
- if (token.is(LBRACE)) { // enum constant class body
- stream.nextClosed(LBRACE, RBRACE);
- token = stream.next();
- }
- }
- }
-
- if (token.is(SEMI))
- defineTypeBody(stream, symbols, typeDef, packageName);
- }
- }
-
- /*
- * Populate typeDef with identifier and then skip to type body.
- *
- * @before-token: type identifier
- * @after-token: start of type body which is '{'
- */
- private Token defineTypeHead(TokenStream stream) {
- Token typeHeadToken = stream.current();
-
- while (true) {
- Token token = stream.nextType(LBRACE, LPAREN);
- if (token.is(LPAREN)) {
- stream.nextClosed(LPAREN, RPAREN);
- token = stream.next();
- } else {
- break;
- }
- }
-
- return typeHeadToken;
- }
-
- /*
- * This method skips possible modifiers from current stream position.
- *
- * @before-token: possible start of modifiers
- * @after-token: remain unchanged or token after the modifiers if there are modifiers
- */
- private List<Modifier> skipModifiers(TokenStream stream) {
- List<Modifier> modifiers = new ArrayList<>();
- Token token = stream.current();
- while (true) {
- if (token.is(AT) && !stream.lookAhead(1).is(INTERFACE)) {
- skipAnnotation(stream);
- token = stream.current();
- } else if (!token.is(StringLiteral)) {
- Modifier modifier = null;
- for (Modifier each: Modifier.values()) {
- if (each.name().toLowerCase().equals(token.getText())) {
- modifier = each;
- break;
- }
- }
- if (modifier != null) {
- modifiers.add(modifier);
- token = stream.next();
- } else {
- break;
- }
- } else {
- break;
- }
- }
- return modifiers;
- }
-
- /*
- * This method skips possible annotations from current stream position.
- *
- * @before-token: possible start of annotations
- * @after-token: remain unchanged or token after the annotations if there are annotations
- */
- private void skipAnnotations(TokenStream stream) {
- Token token = stream.current();
- while (true) {
- if (token.is(AT) && !stream.lookAhead(1).is(INTERFACE)) {
- skipAnnotation(stream);
- token = stream.current();
- } else {
- break;
- }
- }
- }
-
- /*
- * Skip a single annotation.
- *
- * @before-token: '@'
- * @after-token: token after the annotation
- */
- private void skipAnnotation(TokenStream stream) {
- stream.next();
- skipTypeName(stream);
- Token token = stream.current();
- if (token.is(LPAREN)) {
- token = stream.nextClosed(LPAREN, RPAREN);
- token = stream.next();
- }
- }
-
- /*
- * Skip type name sections.
- *
- * @before-token: first section of type name
- * @after-token: token after type name
- */
- private String skipTypeName(TokenStream stream) {
- String typeName = stream.current().getText();
- Token token = stream.next();
- while (token.is(DOT)) {
- typeName += ".";
- token = stream.next();
- typeName += token.getText();
- token = stream.next();
- }
- return typeName;
- }
-
- @Override
- public int getVersion() {
- return 1;
- }
-
- @Override
- public boolean accept(String fileName) {
- return acceptExtensions(fileName, "java");
- }
-
-}
-
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/JavaSymbol.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/JavaSymbol.java
deleted file mode 100644
index 3006464623..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/JavaSymbol.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import com.gitplex.commons.lang.extractors.Symbol;
-import com.gitplex.commons.lang.extractors.TokenPosition;
-
-public abstract class JavaSymbol extends Symbol {
-
- private static final long serialVersionUID = 1L;
-
- public JavaSymbol(Symbol parent, String name, TokenPosition pos) {
- super(parent, name, pos);
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDef.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDef.java
deleted file mode 100644
index 8fc103169f..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDef.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-
-import com.gitplex.commons.lang.extractors.TokenPosition;
-import com.gitplex.commons.lang.extractors.java.icons.Icons;
-import com.gitplex.commons.util.Range;
-
-public class MethodDef extends JavaSymbol {
-
- private static final long serialVersionUID = 1L;
-
- private final String type;
-
- private final String params;
-
- private final List<Modifier> modifiers;
-
- public MethodDef(TypeDef parent, String name, TokenPosition pos,
- @Nullable String type, @Nullable String params, List<Modifier> modifiers) {
- super(parent, name, pos);
-
- this.type = type;
- this.params = params;
- this.modifiers = modifiers;
- }
-
- /**
- * Get type of this method.
- *
- * @return
- * type of this method, or <tt>null</tt> for constructor
- */
- @Nullable
- public String getType() {
- return type;
- }
-
- /**
- * Get params of this method.
- *
- * @return
- * params of this method, or <tt>null</tt> if no params
- */
- @Nullable
- public String getParams() {
- return params;
- }
-
- public List<Modifier> getModifiers() {
- return modifiers;
- }
-
- @Override
- public Component render(String componentId, Range matchRange) {
- return new MethodDefPanel(componentId, this, matchRange);
- }
-
- @Override
- public ResourceReference getIcon() {
- String icon;
- if (modifiers.contains(Modifier.PRIVATE))
- icon = "methpri_obj.png";
- else if (modifiers.contains(Modifier.PROTECTED))
- icon = "methpro_obj.png";
- else if (modifiers.contains(Modifier.PUBLIC))
- icon = "methpub_obj.png";
- else
- icon = "methdef_obj.png";
- return new PackageResourceReference(Icons.class, icon);
- }
-
- @Override
- public String getScope() {
- String scope = getParent().getScope();
- if (scope != null)
- return scope + "." + getParent().getName();
- else
- return getParent().getName();
- }
-
- @Override
- public boolean isPrimary() {
- return false;
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDefPanel.html b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDefPanel.html
deleted file mode 100644
index d5c2533d65..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDefPanel.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<wicket:panel>
- <span wicket:id="name"></span>(<span wicket:id="params"></span>)
- <wicket:enclosure child="type">
- <span style="color: #8C7024;">: <span wicket:id="type"></span></span>
- </wicket:enclosure>
-</wicket:panel>
\ No newline at end of file
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDefPanel.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDefPanel.java
deleted file mode 100644
index 3bb572114d..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/MethodDefPanel.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.panel.Panel;
-
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.wicket.component.HighlightableLabel;
-
-@SuppressWarnings("serial")
-public class MethodDefPanel extends Panel {
-
- private final MethodDef methodDef;
-
- private final Range matchRange;
-
- public MethodDefPanel(String id, MethodDef methodDef, Range matchRange) {
- super(id);
- this.methodDef = methodDef;
- this.matchRange = matchRange;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- add(new HighlightableLabel("name", methodDef.getName(), matchRange));
- add(new Label("params", methodDef.getParams()));
- add(new Label("type", methodDef.getType()).setVisible(methodDef.getType()!=null));
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/Modifier.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/Modifier.java
deleted file mode 100644
index a239230e64..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/Modifier.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-public enum Modifier {
- PUBLIC, PRIVATE, PROTECTED, STATIC, ABSTRACT, STRICTFP, FINAL,
- SYNCHRONIZED, NATIVE, TRANSIENT, VOLATILE, DEFAULT;
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/TypeDef.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/TypeDef.java
deleted file mode 100644
index b00eb5cf4a..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/TypeDef.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-
-import com.gitplex.commons.lang.extractors.Symbol;
-import com.gitplex.commons.lang.extractors.TokenPosition;
-import com.gitplex.commons.lang.extractors.java.icons.Icons;
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.wicket.component.HighlightableLabel;
-
-public class TypeDef extends JavaSymbol {
-
- private static final long serialVersionUID = 1L;
-
- public enum Kind {CLASS, INTERFACE, ANNOTATION, ENUM};
-
- private final Kind kind;
-
- private final String packageName;
-
- private final List<Modifier> modifiers;
-
- public TypeDef(@Nullable Symbol parent, @Nullable String packageName,
- String name, TokenPosition pos, Kind kind, List<Modifier> modifiers) {
- super(parent, name, pos);
-
- this.packageName = packageName;
- this.kind = kind;
- this.modifiers = modifiers;
- }
-
- public Kind getKind() {
- return kind;
- }
-
- public List<Modifier> getModifiers() {
- return modifiers;
- }
-
- @Override
- public Component render(String componentId, Range matchRange) {
- return new HighlightableLabel(componentId, getName(), matchRange);
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- @Override
- public String getScope() {
- if (getParent() != null) {
- String scope = getParent().getScope();
- if (scope != null)
- return scope + "." + getParent().getName();
- else
- return getParent().getName();
- } else {
- if (packageName != null)
- return packageName;
- else
- return null;
- }
- }
-
- @Override
- public ResourceReference getIcon() {
- String icon;
- switch (kind) {
- case ENUM:
- icon = "enum_obj.png";
- break;
- case INTERFACE:
- icon = "int_obj.png";
- break;
- case ANNOTATION:
- icon = "annotation_obj.png";
- break;
- case CLASS:
- if (modifiers.contains(Modifier.PRIVATE))
- icon = "innerclass_private_obj.png";
- else if (modifiers.contains(Modifier.PROTECTED))
- icon = "innerclass_protected_obj.png";
- else if (modifiers.contains(Modifier.PUBLIC))
- icon = "class_obj.png";
- else
- icon = "class_default_obj.png";
- break;
- default:
- throw new IllegalStateException();
- }
- return new PackageResourceReference(Icons.class, icon);
- }
-
- @Override
- public boolean isPrimary() {
- return true;
- }
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/Icons.java b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/Icons.java
deleted file mode 100644
index 7f73915ef1..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/Icons.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.gitplex.commons.lang.extractors.java.icons;
-
-public class Icons {
-
-}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/annotation_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/annotation_obj.png
deleted file mode 100644
index e1b272b2ee..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/annotation_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/class_default_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/class_default_obj.png
deleted file mode 100644
index af7e9df277..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/class_default_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/class_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/class_obj.png
deleted file mode 100644
index c57c2d00f3..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/class_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/enum_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/enum_obj.png
deleted file mode 100644
index 5e96f5e393..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/enum_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_default_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_default_obj.png
deleted file mode 100644
index becfe6b118..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_default_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_private_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_private_obj.png
deleted file mode 100644
index d3fa87ddd8..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_private_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_protected_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_protected_obj.png
deleted file mode 100644
index dc80489bc4..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_protected_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_public_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_public_obj.png
deleted file mode 100644
index 40a5ef1c8e..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/field_public_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/innerclass_private_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/innerclass_private_obj.png
deleted file mode 100644
index 3fbcbe916d..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/innerclass_private_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/innerclass_protected_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/innerclass_protected_obj.png
deleted file mode 100644
index 9a668e4256..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/innerclass_protected_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/int_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/int_obj.png
deleted file mode 100644
index 31caf5a711..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/int_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methdef_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methdef_obj.png
deleted file mode 100644
index a4131b9ba8..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methdef_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpri_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpri_obj.png
deleted file mode 100644
index 57dbb76913..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpri_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpro_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpro_obj.png
deleted file mode 100644
index 3e4c0d7853..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpro_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpub_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpub_obj.png
deleted file mode 100644
index 3004195286..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/methpub_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/package_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/package_obj.png
deleted file mode 100644
index 0afea5b863..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/package_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/packd_obj.png b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/packd_obj.png
deleted file mode 100644
index 61eabf56c0..0000000000
Binary files a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/java/icons/packd_obj.png and /dev/null differ
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/python/Python3.g4 b/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/python/Python3.g4
deleted file mode 100644
index 7cd4fb482a..0000000000
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/extractors/python/Python3.g4
+++ /dev/null
@@ -1,1557 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 by Bart Kiers
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Project : python3-parser; an ANTLR4 grammar for Python 3
- * https://github.com/bkiers/python3-parser
- * Developed by : Bart Kiers, [email protected]
- */
-grammar Python3;
-
-// All comments that start with "///" are copy-pasted from
-// The Python Language Reference: https://docs.python.org/3.3/reference/grammar.html
-
-tokens { INDENT, DEDENT }
-
-@lexer::members {
-
- // A queue where extra tokens are pushed on (see the NEWLINE lexer rule).
- private java.util.LinkedList<Token> tokens = new java.util.LinkedList<>();
-
- // The stack that keeps track of the indentation level.
- private java.util.Stack<Integer> indents = new java.util.Stack<>();
-
- // The amount of opened braces, brackets and parenthesis.
- private int opened = 0;
-
- // The most recently produced token.
- private Token lastToken = null;
-
- @Override
- public void emit(Token t) {
- super.setToken(t);
- tokens.offer(t);
- }
-
- @Override
- public Token nextToken() {
-
- // Check if the end-of-file is ahead and there are still some DEDENTS expected.
- if (_input.LA(1) == EOF && !this.indents.isEmpty()) {
-
- // Remove any trailing EOF tokens from our buffer.
- for (int i = tokens.size() - 1; i >= 0; i--) {
- if (tokens.get(i).getType() == EOF) {
- tokens.remove(i);
- }
- }
-
- // First emit an extra line break that serves as the end of the statement.
- this.emit(commonToken(Python3Parser.NEWLINE, "\n"));
-
- // Now emit as much DEDENT tokens as needed.
- while (!indents.isEmpty()) {
- this.emit(createDedent());
- indents.pop();
- }
-
- // Put the EOF back on the token stream.
- this.emit(commonToken(Python3Parser.EOF, "<EOF>"));
- }
-
- Token next = super.nextToken();
-
- if (next.getChannel() == Token.DEFAULT_CHANNEL) {
- // Keep track of the last token on the default channel.
- this.lastToken = next;
- }
-
- return tokens.isEmpty() ? next : tokens.poll();
- }
-
- private Token createDedent() {
- CommonToken dedent = commonToken(Python3Parser.DEDENT, "");
- dedent.setLine(this.lastToken.getLine());
- return dedent;
- }
-
- private CommonToken commonToken(int type, String text) {
- int stop = this.getCharIndex() - 1;
- int start = text.isEmpty() ? stop : stop - text.length() + 1;
- return new CommonToken(this._tokenFactorySourcePair, type, DEFAULT_TOKEN_CHANNEL, start, stop);
- }
-
- // Calculates the indentation of the provided spaces, taking the
- // following rules into account:
- //
- // "Tabs are replaced (from left to right) by one to eight spaces
- // such that the total number of characters up to and including
- // the replacement is a multiple of eight [...]"
- //
- // -- https://docs.python.org/3.1/reference/lexical_analysis.html#indentation
- static int getIndentationCount(String spaces) {
-
- int count = 0;
-
- for (char ch : spaces.toCharArray()) {
- switch (ch) {
- case '\t':
- count += 8 - (count % 8);
- break;
- default:
- // A normal space char.
- count++;
- }
- }
-
- return count;
- }
-
- boolean atStartOfInput() {
- return super.getCharPositionInLine() == 0 && super.getLine() == 1;
- }
-}
-
-/*
- * parser rules
- */
-
-/// single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
-single_input
- : NEWLINE
- | simple_stmt
- | compound_stmt NEWLINE
- ;
-
-/// file_input: (NEWLINE | stmt)* ENDMARKER
-file_input
- : ( NEWLINE | stmt )* EOF
- ;
-
-/// eval_input: testlist NEWLINE* ENDMARKER
-eval_input
- : testlist NEWLINE* EOF
- ;
-
-/// decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
-decorator
- : '@' dotted_name ( '(' arglist? ')' )? NEWLINE
- ;
-
-/// decorators: decorator+
-decorators
- : decorator+
- ;
-
-/// decorated: decorators (classdef | funcdef)
-decorated
- : decorators ( classdef | funcdef )
- ;
-
-/// funcdef: 'def' NAME parameters ['->' test] ':' suite
-funcdef
- : DEF NAME parameters ( '->' test )? ':' suite
- ;
-
-/// parameters: '(' [typedargslist] ')'
-parameters
- : '(' typedargslist? ')'
- ;
-
-/// typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [','
-/// ['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]]
-/// | '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef)
-typedargslist
- : tfpdef ( '=' test )? ( ',' tfpdef ( '=' test )? )* ( ',' ( '*' tfpdef? ( ',' tfpdef ( '=' test )? )* ( ',' '**' tfpdef )?
- | '**' tfpdef
- )?
- )?
- | '*' tfpdef? ( ',' tfpdef ( '=' test )? )* ( ',' '**' tfpdef )?
- | '**' tfpdef
- ;
-
-/// tfpdef: NAME [':' test]
-tfpdef
- : NAME ( ':' test )?
- ;
-
-/// varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [','
-/// ['*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef]]
-/// | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef)
-varargslist
- : vfpdef ( '=' test )? ( ',' vfpdef ( '=' test )? )* ( ',' ( '*' vfpdef? ( ',' vfpdef ( '=' test )? )* ( ',' '**' vfpdef )?
- | '**' vfpdef
- )?
- )?
- | '*' vfpdef? ( ',' vfpdef ( '=' test )? )* ( ',' '**' vfpdef )?
- | '**' vfpdef
- ;
-
-/// vfpdef: NAME
-vfpdef
- : NAME
- ;
-
-/// stmt: simple_stmt | compound_stmt
-stmt
- : simple_stmt
- | compound_stmt
- ;
-
-/// simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
-simple_stmt
- : small_stmt ( ';' small_stmt )* ';'? NEWLINE
- ;
-
-/// small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |
-/// import_stmt | global_stmt | nonlocal_stmt | assert_stmt)
-small_stmt
- : expr_stmt
- | del_stmt
- | pass_stmt
- | flow_stmt
- | import_stmt
- | global_stmt
- | nonlocal_stmt
- | assert_stmt
- ;
-
-/// expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) |
-/// ('=' (yield_expr|testlist_star_expr))*)
-expr_stmt
- : testlist_star_expr ( augassign ( yield_expr | testlist)
- | ( '=' ( yield_expr| testlist_star_expr ) )*
- )
- ;
-
-/// testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
-testlist_star_expr
- : ( test | star_expr ) ( ',' ( test | star_expr ) )* ','?
- ;
-
-/// augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
-/// '<<=' | '>>=' | '**=' | '//=')
-augassign
- : '+='
- | '-='
- | '*='
- | '@=' // PEP 465
- | '/='
- | '%='
- | '&='
- | '|='
- | '^='
- | '<<='
- | '>>='
- | '**='
- | '//='
- ;
-
-/// del_stmt: 'del' exprlist
-del_stmt
- : DEL exprlist
- ;
-
-/// pass_stmt: 'pass'
-pass_stmt
- : PASS
- ;
-
-/// flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt
-flow_stmt
- : break_stmt
- | continue_stmt
- | return_stmt
- | raise_stmt
- | yield_stmt
- ;
-
-/// break_stmt: 'break'
-break_stmt
- : BREAK
- ;
-
-/// continue_stmt: 'continue'
-continue_stmt
- : CONTINUE
- ;
-
-/// return_stmt: 'return' [testlist]
-return_stmt
- : RETURN testlist?
- ;
-
-/// yield_stmt: yield_expr
-yield_stmt
- : yield_expr
- ;
-
-/// raise_stmt: 'raise' [test ['from' test]]
-raise_stmt
- : RAISE ( test ( FROM test )? )?
- ;
-
-/// import_stmt: import_name | import_from
-import_stmt
- : import_name
- | import_from
- ;
-
-/// import_name: 'import' dotted_as_names
-import_name
- : IMPORT dotted_as_names
- ;
-
-/// # note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
-/// import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
-/// 'import' ('*' | '(' import_as_names ')' | import_as_names))
-import_from
- : FROM ( ( '.' | '...' )* dotted_name
- | ('.' | '...')+
- )
- IMPORT ( '*'
- | '(' import_as_names ')'
- | import_as_names
- )
- ;
-
-/// import_as_name: NAME ['as' NAME]
-import_as_name
- : NAME ( AS NAME )?
- ;
-
-/// dotted_as_name: dotted_name ['as' NAME]
-dotted_as_name
- : dotted_name ( AS NAME )?
- ;
-
-/// import_as_names: import_as_name (',' import_as_name)* [',']
-import_as_names
- : import_as_name ( ',' import_as_name )* ','?
- ;
-
-/// dotted_as_names: dotted_as_name (',' dotted_as_name)*
-dotted_as_names
- : dotted_as_name ( ',' dotted_as_name )*
- ;
-
-/// dotted_name: NAME ('.' NAME)*
-dotted_name
- : NAME ( '.' NAME )*
- ;
-
-/// global_stmt: 'global' NAME (',' NAME)*
-global_stmt
- : GLOBAL NAME ( ',' NAME )*
- ;
-
-/// nonlocal_stmt: 'nonlocal' NAME (',' NAME)*
-nonlocal_stmt
- : NONLOCAL NAME ( ',' NAME )*
- ;
-
-/// assert_stmt: 'assert' test [',' test]
-assert_stmt
- : ASSERT test ( ',' test )?
- ;
-
-/// compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
-compound_stmt
- : if_stmt
- | while_stmt
- | for_stmt
- | try_stmt
- | with_stmt
- | funcdef
- | classdef
- | decorated
- ;
-
-/// if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
-if_stmt
- : IF test ':' suite ( ELIF test ':' suite )* ( ELSE ':' suite )?
- ;
-
-/// while_stmt: 'while' test ':' suite ['else' ':' suite]
-while_stmt
- : WHILE test ':' suite ( ELSE ':' suite )?
- ;
-
-/// for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
-for_stmt
- : FOR exprlist IN testlist ':' suite ( ELSE ':' suite )?
- ;
-
-/// try_stmt: ('try' ':' suite
-/// ((except_clause ':' suite)+
-/// ['else' ':' suite]
-/// ['finally' ':' suite] |
-/// 'finally' ':' suite))
-try_stmt
- : TRY ':' suite ( ( except_clause ':' suite )+
- ( ELSE ':' suite )?
- ( FINALLY ':' suite )?
- | FINALLY ':' suite
- )
- ;
-
-/// with_stmt: 'with' with_item (',' with_item)* ':' suite
-with_stmt
- : WITH with_item ( ',' with_item )* ':' suite
- ;
-
-/// with_item: test ['as' expr]
-with_item
- : test ( AS expr )?
- ;
-
-/// # NB compile.c makes sure that the default except clause is last
-/// except_clause: 'except' [test ['as' NAME]]
-except_clause
- : EXCEPT ( test ( AS NAME )? )?
- ;
-
-/// suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
-suite
- : simple_stmt
- | NEWLINE INDENT stmt+ DEDENT
- ;
-
-/// test: or_test ['if' or_test 'else' test] | lambdef
-test
- : or_test ( IF or_test ELSE test )?
- | lambdef
- ;
-
-/// test_nocond: or_test | lambdef_nocond
-test_nocond
- : or_test
- | lambdef_nocond
- ;
-
-/// lambdef: 'lambda' [varargslist] ':' test
-lambdef
- : LAMBDA varargslist? ':' test
- ;
-
-/// lambdef_nocond: 'lambda' [varargslist] ':' test_nocond
-lambdef_nocond
- : LAMBDA varargslist? ':' test_nocond
- ;
-
-/// or_test: and_test ('or' and_test)*
-or_test
- : and_test ( OR and_test )*
- ;
-
-/// and_test: not_test ('and' not_test)*
-and_test
- : not_test ( AND not_test )*
- ;
-
-/// not_test: 'not' not_test | comparison
-not_test
- : NOT not_test
- | comparison
- ;
-
-/// comparison: star_expr (comp_op star_expr)*
-comparison
- : star_expr ( comp_op star_expr )*
- ;
-
-/// # <> isn't actually a valid comparison operator in Python. It's here for the
-/// # sake of a __future__ import described in PEP 401
-/// comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
-comp_op
- : '<'
- | '>'
- | '=='
- | '>='
- | '<='
- | '<>'
- | '!='
- | IN
- | NOT IN
- | IS
- | IS NOT
- ;
-
-/// star_expr: ['*'] expr
-star_expr
- : '*'? expr
- ;
-
-/// expr: xor_expr ('|' xor_expr)*
-expr
- : xor_expr ( '|' xor_expr )*
- ;
-
-/// xor_expr: and_expr ('^' and_expr)*
-xor_expr
- : and_expr ( '^' and_expr )*
- ;
-
-/// and_expr: shift_expr ('&' shift_expr)*
-and_expr
- : shift_expr ( '&' shift_expr )*
- ;
-
-/// shift_expr: arith_expr (('<<'|'>>') arith_expr)*
-shift_expr
- : arith_expr ( '<<' arith_expr
- | '>>' arith_expr
- )*
- ;
-
-/// arith_expr: term (('+'|'-') term)*
-arith_expr
- : term ( '+' term
- | '-' term
- )*
- ;
-
-/// term: factor (('*'|'/'|'%'|'//') factor)*
-term
- : factor ( '*' factor
- | '/' factor
- | '%' factor
- | '//' factor
- | '@' factor // PEP 465
- )*
- ;
-
-/// factor: ('+'|'-'|'~') factor | power
-factor
- : '+' factor
- | '-' factor
- | '~' factor
- | power
- ;
-
-/// power: atom trailer* ['**' factor]
-power
- : atom trailer* ( '**' factor )?
- ;
-
-/// atom: ('(' [yield_expr|testlist_comp] ')' |
-/// '[' [testlist_comp] ']' |
-/// '{' [dictorsetmaker] '}' |
-/// NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')
-atom
- : '(' ( yield_expr | testlist_comp )? ')'
- | '[' testlist_comp? ']'
- | '{' dictorsetmaker? '}'
- | NAME
- | number
- | string+
- | '...'
- | NONE
- | TRUE
- | FALSE
- ;
-
-/// testlist_comp: test ( comp_for | (',' test)* [','] )
-testlist_comp
- : test ( comp_for
- | ( ',' test )* ','?
- )
- ;
-
-/// trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
-trailer
- : '(' arglist? ')'
- | '[' subscriptlist ']'
- | '.' NAME
- ;
-
-/// subscriptlist: subscript (',' subscript)* [',']
-subscriptlist
- : subscript ( ',' subscript )* ','?
- ;
-
-/// subscript: test | [test] ':' [test] [sliceop]
-subscript
- : test
- | test? ':' test? sliceop?
- ;
-
-/// sliceop: ':' [test]
-sliceop
- : ':' test?
- ;
-
-/// exprlist: star_expr (',' star_expr)* [',']
-exprlist
- : star_expr ( ',' star_expr )* ','?
- ;
-
-/// testlist: test (',' test)* [',']
-testlist
- : test ( ',' test )* ','?
- ;
-
-/// dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |
-/// (test (comp_for | (',' test)* [','])) )
-dictorsetmaker
- : test ':' test ( comp_for
- | ( ',' test ':' test )* ','?
- )
- | test ( comp_for
- | ( ',' test )* ','?
- )
- ;
-
-/// classdef: 'class' NAME ['(' [arglist] ')'] ':' suite
-classdef
- : CLASS NAME ( '(' arglist? ')' )? ':' suite
- ;
-
-/// arglist: (argument ',')* (argument [',']
-/// |'*' test (',' argument)* [',' '**' test]
-/// |'**' test)
-arglist
- : ( argument ',' )* ( argument ','?
- | '*' test ( ',' argument )* ( ',' '**' test )?
- | '**' test
- )
- ;
-
-/// # The reason that keywords are test nodes instead of NAME is that using NAME
-/// # results in an ambiguity. ast.c makes sure it's a NAME.
-/// argument: test [comp_for] | test '=' test # Really [keyword '='] test
-argument
- : test comp_for?
- | test '=' test
- ;
-
-/// comp_iter: comp_for | comp_if
-comp_iter
- : comp_for
- | comp_if
- ;
-
-/// comp_for: 'for' exprlist 'in' or_test [comp_iter]
-comp_for
- : FOR exprlist IN or_test comp_iter?
- ;
-
-/// comp_if: 'if' test_nocond [comp_iter]
-comp_if
- : IF test_nocond comp_iter?
- ;
-
-/// yield_expr: 'yield' [testlist]
-yield_expr
- : YIELD yield_arg?
- ;
-
-/// yield_arg: 'from' test | testlist
-yield_arg
- : FROM test
- | testlist
- ;
-
-string
- : STRING_LITERAL
- | BYTES_LITERAL
- ;
-
-number
- : integer
- | FLOAT_NUMBER
- | IMAG_NUMBER
- ;
-
-/// integer ::= decimalinteger | octinteger | hexinteger | bininteger
-integer
- : DECIMAL_INTEGER
- | OCT_INTEGER
- | HEX_INTEGER
- | BIN_INTEGER
- ;
-
-/*
- * lexer rules
- */
-
-DEF : 'def';
-RETURN : 'return';
-RAISE : 'raise';
-FROM : 'from';
-IMPORT : 'import';
-AS : 'as';
-GLOBAL : 'global';
-NONLOCAL : 'nonlocal';
-ASSERT : 'assert';
-IF : 'if';
-ELIF : 'elif';
-ELSE : 'else';
-WHILE : 'while';
-FOR : 'for';
-IN : 'in';
-TRY : 'try';
-FINALLY : 'finally';
-WITH : 'with';
-EXCEPT : 'except';
-LAMBDA : 'lambda';
-OR : 'or';
-AND : 'and';
-NOT : 'not';
-IS : 'is';
-NONE : 'None';
-TRUE : 'True';
-FALSE : 'False';
-CLASS : 'class';
-YIELD : 'yield';
-DEL : 'del';
-PASS : 'pass';
-CONTINUE : 'continue';
-BREAK : 'break';
-
-NEWLINE
- : ( {atStartOfInput()}? SPACES
- | ( '\r'? '\n' | '\r' ) SPACES?
- )
- {
- String newLine = getText().replaceAll("[^\r\n]+", "");
- String spaces = getText().replaceAll("[\r\n]+", "");
- int next = _input.LA(1);
-
- if (opened > 0 || next == '\r' || next == '\n' || next == '#') {
- // If we're inside a list or on a blank line, ignore all indents,
- // dedents and line breaks.
- skip();
- }
- else {
- emit(commonToken(NEWLINE, newLine));
-
- int indent = getIndentationCount(spaces);
- int previous = indents.isEmpty() ? 0 : indents.peek();
-
- if (indent == previous) {
- // skip indents of the same size as the present indent-size
- skip();
- }
- else if (indent > previous) {
- indents.push(indent);
- emit(commonToken(Python3Parser.INDENT, spaces));
- }
- else {
- // Possibly emit more than 1 DEDENT token.
- while(!indents.isEmpty() && indents.peek() > indent) {
- this.emit(createDedent());
- indents.pop();
- }
- }
- }
- }
- ;
-
-/// identifier ::= id_start id_continue*
-NAME
- : ID_START ID_CONTINUE*
- ;
-
-/// stringliteral ::= [stringprefix](shortstring | longstring)
-/// stringprefix ::= "r" | "R"
-STRING_LITERAL
- : [uU]? [rR]? ( SHORT_STRING | LONG_STRING )
- ;
-
-/// bytesliteral ::= bytesprefix(shortbytes | longbytes)
-/// bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR"
-BYTES_LITERAL
- : [bB] [rR]? ( SHORT_BYTES | LONG_BYTES )
- ;
-
-/// decimalinteger ::= nonzerodigit digit* | "0"+
-DECIMAL_INTEGER
- : NON_ZERO_DIGIT DIGIT*
- | '0'+
- ;
-
-/// octinteger ::= "0" ("o" | "O") octdigit+
-OCT_INTEGER
- : '0' [oO] OCT_DIGIT+
- ;
-
-/// hexinteger ::= "0" ("x" | "X") hexdigit+
-HEX_INTEGER
- : '0' [xX] HEX_DIGIT+
- ;
-
-/// bininteger ::= "0" ("b" | "B") bindigit+
-BIN_INTEGER
- : '0' [bB] BIN_DIGIT+
- ;
-
-/// floatnumber ::= pointfloat | exponentfloat
-FLOAT_NUMBER
- : POINT_FLOAT
- | EXPONENT_FLOAT
- ;
-
-/// imagnumber ::= (floatnumber | intpart) ("j" | "J")
-IMAG_NUMBER
- : ( FLOAT_NUMBER | INT_PART ) [jJ]
- ;
-
-DOT : '.';
-ELLIPSIS : '...';
-STAR : '*';
-OPEN_PAREN : '(' {opened++;};
-CLOSE_PAREN : ')' {opened--;};
-COMMA : ',';
-COLON : ':';
-SEMI_COLON : ';';
-POWER : '**';
-ASSIGN : '=';
-OPEN_BRACK : '[' {opened++;};
-CLOSE_BRACK : ']' {opened--;};
-OR_OP : '|';
-XOR : '^';
-AND_OP : '&';
-LEFT_SHIFT : '<<';
-RIGHT_SHIFT : '>>';
-ADD : '+';
-MINUS : '-';
-DIV : '/';
-MOD : '%';
-IDIV : '//';
-NOT_OP : '~';
-OPEN_BRACE : '{' {opened++;};
-CLOSE_BRACE : '}' {opened--;};
-LESS_THAN : '<';
-GREATER_THAN : '>';
-EQUALS : '==';
-GT_EQ : '>=';
-LT_EQ : '<=';
-NOT_EQ_1 : '<>';
-NOT_EQ_2 : '!=';
-AT : '@';
-ARROW : '->';
-ADD_ASSIGN : '+=';
-SUB_ASSIGN : '-=';
-MULT_ASSIGN : '*=';
-AT_ASSIGN : '@=';
-DIV_ASSIGN : '/=';
-MOD_ASSIGN : '%=';
-AND_ASSIGN : '&=';
-OR_ASSIGN : '|=';
-XOR_ASSIGN : '^=';
-LEFT_SHIFT_ASSIGN : '<<=';
-RIGHT_SHIFT_ASSIGN : '>>=';
-POWER_ASSIGN : '**=';
-IDIV_ASSIGN : '//=';
-
-SKIP_
- : ( SPACES | COMMENT | LINE_JOINING ) -> skip
- ;
-
-UNKNOWN_CHAR
- : .
- ;
-
-/*
- * fragments
- */
-
-/// shortstring ::= "'" shortstringitem* "'" | '"' shortstringitem* '"'
-/// shortstringitem ::= shortstringchar | stringescapeseq
-/// shortstringchar ::= <any source character except "\" or newline or the quote>
-fragment SHORT_STRING
- : '\'' ( STRING_ESCAPE_SEQ | ~[\\\r\n'] )* '\''
- | '"' ( STRING_ESCAPE_SEQ | ~[\\\r\n"] )* '"'
- ;
-
-/// longstring ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
-fragment LONG_STRING
- : '\'\'\'' LONG_STRING_ITEM*? '\'\'\''
- | '"""' LONG_STRING_ITEM*? '"""'
- ;
-
-/// longstringitem ::= longstringchar | stringescapeseq
-fragment LONG_STRING_ITEM
- : LONG_STRING_CHAR
- | STRING_ESCAPE_SEQ
- ;
-
-/// longstringchar ::= <any source character except "\">
-fragment LONG_STRING_CHAR
- : ~'\\'
- ;
-
-/// stringescapeseq ::= "\" <any source character>
-fragment STRING_ESCAPE_SEQ
- : '\\' .
- ;
-
-/// nonzerodigit ::= "1"..."9"
-fragment NON_ZERO_DIGIT
- : [1-9]
- ;
-
-/// digit ::= "0"..."9"
-fragment DIGIT
- : [0-9]
- ;
-
-/// octdigit ::= "0"..."7"
-fragment OCT_DIGIT
- : [0-7]
- ;
-
-/// hexdigit ::= digit | "a"..."f" | "A"..."F"
-fragment HEX_DIGIT
- : [0-9a-fA-F]
- ;
-
-/// bindigit ::= "0" | "1"
-fragment BIN_DIGIT
- : [01]
- ;
-
-/// pointfloat ::= [intpart] fraction | intpart "."
-fragment POINT_FLOAT
- : INT_PART? FRACTION
- | INT_PART '.'
- ;
-
-/// exponentfloat ::= (intpart | pointfloat) exponent
-fragment EXPONENT_FLOAT
- : ( INT_PART | POINT_FLOAT ) EXPONENT
- ;
-
-/// intpart ::= digit+
-fragment INT_PART
- : DIGIT+
- ;
-
-/// fraction ::= "." digit+
-fragment FRACTION
- : '.' DIGIT+
- ;
-
-/// exponent ::= ("e" | "E") ["+" | "-"] digit+
-fragment EXPONENT
- : [eE] [+-]? DIGIT+
- ;
-
-/// shortbytes ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
-/// shortbytesitem ::= shortbyteschar | bytesescapeseq
-fragment SHORT_BYTES
- : '\'' ( SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ )* '\''
- | '"' ( SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ )* '"'
- ;
-
-/// longbytes ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
-fragment LONG_BYTES
- : '\'\'\'' LONG_BYTES_ITEM*? '\'\'\''
- | '"""' LONG_BYTES_ITEM*? '"""'
- ;
-
-/// longbytesitem ::= longbyteschar | bytesescapeseq
-fragment LONG_BYTES_ITEM
- : LONG_BYTES_CHAR
- | BYTES_ESCAPE_SEQ
- ;
-
-/// shortbyteschar ::= <any ASCII character except "\" or newline or the quote>
-fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE
- : [\u0000-\u0009]
- | [\u000B-\u000C]
- | [\u000E-\u0026]
- | [\u0028-\u005B]
- | [\u005D-\u007F]
- ;
-
-fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE
- : [\u0000-\u0009]
- | [\u000B-\u000C]
- | [\u000E-\u0021]
- | [\u0023-\u005B]
- | [\u005D-\u007F]
- ;
-
-/// longbyteschar ::= <any ASCII character except "\">
-fragment LONG_BYTES_CHAR
- : [\u0000-\u005B]
- | [\u005D-\u007F]
- ;
-
-/// bytesescapeseq ::= "\" <any ASCII character>
-fragment BYTES_ESCAPE_SEQ
- : '\\' [\u0000-\u007F]
- ;
-
-fragment SPACES
- : [ \t]+
- ;
-
-fragment COMMENT
- : '#' ~[\r\n]*
- ;
-
-fragment LINE_JOINING
- : '\\' SPACES? ( '\r'? '\n' | '\r' )
- ;
-
-/// id_start ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
-fragment ID_START
- : '_'
- | [A-Z]
- | [a-z]
- | '\u00AA'
- | '\u00B5'
- | '\u00BA'
- | [\u00C0-\u00D6]
- | [\u00D8-\u00F6]
- | [\u00F8-\u01BA]
- | '\u01BB'
- | [\u01BC-\u01BF]
- | [\u01C0-\u01C3]
- | [\u01C4-\u0241]
- | [\u0250-\u02AF]
- | [\u02B0-\u02C1]
- | [\u02C6-\u02D1]
- | [\u02E0-\u02E4]
- | '\u02EE'
- | '\u037A'
- | '\u0386'
- | [\u0388-\u038A]
- | '\u038C'
- | [\u038E-\u03A1]
- | [\u03A3-\u03CE]
- | [\u03D0-\u03F5]
- | [\u03F7-\u0481]
- | [\u048A-\u04CE]
- | [\u04D0-\u04F9]
- | [\u0500-\u050F]
- | [\u0531-\u0556]
- | '\u0559'
- | [\u0561-\u0587]
- | [\u05D0-\u05EA]
- | [\u05F0-\u05F2]
- | [\u0621-\u063A]
- | '\u0640'
- | [\u0641-\u064A]
- | [\u066E-\u066F]
- | [\u0671-\u06D3]
- | '\u06D5'
- | [\u06E5-\u06E6]
- | [\u06EE-\u06EF]
- | [\u06FA-\u06FC]
- | '\u06FF'
- | '\u0710'
- | [\u0712-\u072F]
- | [\u074D-\u076D]
- | [\u0780-\u07A5]
- | '\u07B1'
- | [\u0904-\u0939]
- | '\u093D'
- | '\u0950'
- | [\u0958-\u0961]
- | '\u097D'
- | [\u0985-\u098C]
- | [\u098F-\u0990]
- | [\u0993-\u09A8]
- | [\u09AA-\u09B0]
- | '\u09B2'
- | [\u09B6-\u09B9]
- | '\u09BD'
- | '\u09CE'
- | [\u09DC-\u09DD]
- | [\u09DF-\u09E1]
- | [\u09F0-\u09F1]
- | [\u0A05-\u0A0A]
- | [\u0A0F-\u0A10]
- | [\u0A13-\u0A28]
- | [\u0A2A-\u0A30]
- | [\u0A32-\u0A33]
- | [\u0A35-\u0A36]
- | [\u0A38-\u0A39]
- | [\u0A59-\u0A5C]
- | '\u0A5E'
- | [\u0A72-\u0A74]
- | [\u0A85-\u0A8D]
- | [\u0A8F-\u0A91]
- | [\u0A93-\u0AA8]
- | [\u0AAA-\u0AB0]
- | [\u0AB2-\u0AB3]
- | [\u0AB5-\u0AB9]
- | '\u0ABD'
- | '\u0AD0'
- | [\u0AE0-\u0AE1]
- | [\u0B05-\u0B0C]
- | [\u0B0F-\u0B10]
- | [\u0B13-\u0B28]
- | [\u0B2A-\u0B30]
- | [\u0B32-\u0B33]
- | [\u0B35-\u0B39]
- | '\u0B3D'
- | [\u0B5C-\u0B5D]
- | [\u0B5F-\u0B61]
- | '\u0B71'
- | '\u0B83'
- | [\u0B85-\u0B8A]
- | [\u0B8E-\u0B90]
- | [\u0B92-\u0B95]
- | [\u0B99-\u0B9A]
- | '\u0B9C'
- | [\u0B9E-\u0B9F]
- | [\u0BA3-\u0BA4]
- | [\u0BA8-\u0BAA]
- | [\u0BAE-\u0BB9]
- | [\u0C05-\u0C0C]
- | [\u0C0E-\u0C10]
- | [\u0C12-\u0C28]
- | [\u0C2A-\u0C33]
- | [\u0C35-\u0C39]
- | [\u0C60-\u0C61]
- | [\u0C85-\u0C8C]
- | [\u0C8E-\u0C90]
- | [\u0C92-\u0CA8]
- | [\u0CAA-\u0CB3]
- | [\u0CB5-\u0CB9]
- | '\u0CBD'
- | '\u0CDE'
- | [\u0CE0-\u0CE1]
- | [\u0D05-\u0D0C]
- | [\u0D0E-\u0D10]
- | [\u0D12-\u0D28]
- | [\u0D2A-\u0D39]
- | [\u0D60-\u0D61]
- | [\u0D85-\u0D96]
- | [\u0D9A-\u0DB1]
- | [\u0DB3-\u0DBB]
- | '\u0DBD'
- | [\u0DC0-\u0DC6]
- | [\u0E01-\u0E30]
- | [\u0E32-\u0E33]
- | [\u0E40-\u0E45]
- | '\u0E46'
- | [\u0E81-\u0E82]
- | '\u0E84'
- | [\u0E87-\u0E88]
- | '\u0E8A'
- | '\u0E8D'
- | [\u0E94-\u0E97]
- | [\u0E99-\u0E9F]
- | [\u0EA1-\u0EA3]
- | '\u0EA5'
- | '\u0EA7'
- | [\u0EAA-\u0EAB]
- | [\u0EAD-\u0EB0]
- | [\u0EB2-\u0EB3]
- | '\u0EBD'
- | [\u0EC0-\u0EC4]
- | '\u0EC6'
- | [\u0EDC-\u0EDD]
- | '\u0F00'
- | [\u0F40-\u0F47]
- | [\u0F49-\u0F6A]
- | [\u0F88-\u0F8B]
- | [\u1000-\u1021]
- | [\u1023-\u1027]
- | [\u1029-\u102A]
- | [\u1050-\u1055]
- | [\u10A0-\u10C5]
- | [\u10D0-\u10FA]
- | '\u10FC'
- | [\u1100-\u1159]
- | [\u115F-\u11A2]
- | [\u11A8-\u11F9]
- | [\u1200-\u1248]
- | [\u124A-\u124D]
- | [\u1250-\u1256]
- | '\u1258'
- | [\u125A-\u125D]
- | [\u1260-\u1288]
- | [\u128A-\u128D]
- | [\u1290-\u12B0]
- | [\u12B2-\u12B5]
- | [\u12B8-\u12BE]
- | '\u12C0'
- | [\u12C2-\u12C5]
- | [\u12C8-\u12D6]
- | [\u12D8-\u1310]
- | [\u1312-\u1315]
- | [\u1318-\u135A]
- | [\u1380-\u138F]
- | [\u13A0-\u13F4]
- | [\u1401-\u166C]
- | [\u166F-\u1676]
- | [\u1681-\u169A]
- | [\u16A0-\u16EA]
- | [\u16EE-\u16F0]
- | [\u1700-\u170C]
- | [\u170E-\u1711]
- | [\u1720-\u1731]
- | [\u1740-\u1751]
- | [\u1760-\u176C]
- | [\u176E-\u1770]
- | [\u1780-\u17B3]
- | '\u17D7'
- | '\u17DC'
- | [\u1820-\u1842]
- | '\u1843'
- | [\u1844-\u1877]
- | [\u1880-\u18A8]
- | [\u1900-\u191C]
- | [\u1950-\u196D]
- | [\u1970-\u1974]
- | [\u1980-\u19A9]
- | [\u19C1-\u19C7]
- | [\u1A00-\u1A16]
- | [\u1D00-\u1D2B]
- | [\u1D2C-\u1D61]
- | [\u1D62-\u1D77]
- | '\u1D78'
- | [\u1D79-\u1D9A]
- | [\u1D9B-\u1DBF]
- | [\u1E00-\u1E9B]
- | [\u1EA0-\u1EF9]
- | [\u1F00-\u1F15]
- | [\u1F18-\u1F1D]
- | [\u1F20-\u1F45]
- | [\u1F48-\u1F4D]
- | [\u1F50-\u1F57]
- | '\u1F59'
- | '\u1F5B'
- | '\u1F5D'
- | [\u1F5F-\u1F7D]
- | [\u1F80-\u1FB4]
- | [\u1FB6-\u1FBC]
- | '\u1FBE'
- | [\u1FC2-\u1FC4]
- | [\u1FC6-\u1FCC]
- | [\u1FD0-\u1FD3]
- | [\u1FD6-\u1FDB]
- | [\u1FE0-\u1FEC]
- | [\u1FF2-\u1FF4]
- | [\u1FF6-\u1FFC]
- | '\u2071'
- | '\u207F'
- | [\u2090-\u2094]
- | '\u2102'
- | '\u2107'
- | [\u210A-\u2113]
- | '\u2115'
- | '\u2118'
- | [\u2119-\u211D]
- | '\u2124'
- | '\u2126'
- | '\u2128'
- | [\u212A-\u212D]
- | '\u212E'
- | [\u212F-\u2131]
- | [\u2133-\u2134]
- | [\u2135-\u2138]
- | '\u2139'
- | [\u213C-\u213F]
- | [\u2145-\u2149]
- | [\u2160-\u2183]
- | [\u2C00-\u2C2E]
- | [\u2C30-\u2C5E]
- | [\u2C80-\u2CE4]
- | [\u2D00-\u2D25]
- | [\u2D30-\u2D65]
- | '\u2D6F'
- | [\u2D80-\u2D96]
- | [\u2DA0-\u2DA6]
- | [\u2DA8-\u2DAE]
- | [\u2DB0-\u2DB6]
- | [\u2DB8-\u2DBE]
- | [\u2DC0-\u2DC6]
- | [\u2DC8-\u2DCE]
- | [\u2DD0-\u2DD6]
- | [\u2DD8-\u2DDE]
- | '\u3005'
- | '\u3006'
- | '\u3007'
- | [\u3021-\u3029]
- | [\u3031-\u3035]
- | [\u3038-\u303A]
- | '\u303B'
- | '\u303C'
- | [\u3041-\u3096]
- | [\u309B-\u309C]
- | [\u309D-\u309E]
- | '\u309F'
- | [\u30A1-\u30FA]
- | [\u30FC-\u30FE]
- | '\u30FF'
- | [\u3105-\u312C]
- | [\u3131-\u318E]
- | [\u31A0-\u31B7]
- | [\u31F0-\u31FF]
- | [\u3400-\u4DB5]
- | [\u4E00-\u9FBB]
- | [\uA000-\uA014]
- | '\uA015'
- | [\uA016-\uA48C]
- | [\uA800-\uA801]
- | [\uA803-\uA805]
- | [\uA807-\uA80A]
- | [\uA80C-\uA822]
- | [\uAC00-\uD7A3]
- | [\uF900-\uFA2D]
- | [\uFA30-\uFA6A]
- | [\uFA70-\uFAD9]
- | [\uFB00-\uFB06]
- | [\uFB13-\uFB17]
- | '\uFB1D'
- | [\uFB1F-\uFB28]
- | [\uFB2A-\uFB36]
- | [\uFB38-\uFB3C]
- | '\uFB3E'
- | [\uFB40-\uFB41]
- | [\uFB43-\uFB44]
- | [\uFB46-\uFBB1]
- | [\uFBD3-\uFD3D]
- | [\uFD50-\uFD8F]
- | [\uFD92-\uFDC7]
- | [\uFDF0-\uFDFB]
- | [\uFE70-\uFE74]
- | [\uFE76-\uFEFC]
- | [\uFF21-\uFF3A]
- | [\uFF41-\uFF5A]
- | [\uFF66-\uFF6F]
- | '\uFF70'
- | [\uFF71-\uFF9D]
- | [\uFF9E-\uFF9F]
- | [\uFFA0-\uFFBE]
- | [\uFFC2-\uFFC7]
- | [\uFFCA-\uFFCF]
- | [\uFFD2-\uFFD7]
- | [\uFFDA-\uFFDC]
- ;
-
-/// id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
-fragment ID_CONTINUE
- : ID_START
- | [0-9]
- | [\u0300-\u036F]
- | [\u0483-\u0486]
- | [\u0591-\u05B9]
- | [\u05BB-\u05BD]
- | '\u05BF'
- | [\u05C1-\u05C2]
- | [\u05C4-\u05C5]
- | '\u05C7'
- | [\u0610-\u0615]
- | [\u064B-\u065E]
- | [\u0660-\u0669]
- | '\u0670'
- | [\u06D6-\u06DC]
- | [\u06DF-\u06E4]
- | [\u06E7-\u06E8]
- | [\u06EA-\u06ED]
- | [\u06F0-\u06F9]
- | '\u0711'
- | [\u0730-\u074A]
- | [\u07A6-\u07B0]
- | [\u0901-\u0902]
- | '\u0903'
- | '\u093C'
- | [\u093E-\u0940]
- | [\u0941-\u0948]
- | [\u0949-\u094C]
- | '\u094D'
- | [\u0951-\u0954]
- | [\u0962-\u0963]
- | [\u0966-\u096F]
- | '\u0981'
- | [\u0982-\u0983]
- | '\u09BC'
- | [\u09BE-\u09C0]
- | [\u09C1-\u09C4]
- | [\u09C7-\u09C8]
- | [\u09CB-\u09CC]
- | '\u09CD'
- | '\u09D7'
- | [\u09E2-\u09E3]
- | [\u09E6-\u09EF]
- | [\u0A01-\u0A02]
- | '\u0A03'
- | '\u0A3C'
- | [\u0A3E-\u0A40]
- | [\u0A41-\u0A42]
- | [\u0A47-\u0A48]
- | [\u0A4B-\u0A4D]
- | [\u0A66-\u0A6F]
- | [\u0A70-\u0A71]
- | [\u0A81-\u0A82]
- | '\u0A83'
- | '\u0ABC'
- | [\u0ABE-\u0AC0]
- | [\u0AC1-\u0AC5]
- | [\u0AC7-\u0AC8]
- | '\u0AC9'
- | [\u0ACB-\u0ACC]
- | '\u0ACD'
- | [\u0AE2-\u0AE3]
- | [\u0AE6-\u0AEF]
- | '\u0B01'
- | [\u0B02-\u0B03]
- | '\u0B3C'
- | '\u0B3E'
- | '\u0B3F'
- | '\u0B40'
- | [\u0B41-\u0B43]
- | [\u0B47-\u0B48]
- | [\u0B4B-\u0B4C]
- | '\u0B4D'
- | '\u0B56'
- | '\u0B57'
- | [\u0B66-\u0B6F]
- | '\u0B82'
- | [\u0BBE-\u0BBF]
- | '\u0BC0'
- | [\u0BC1-\u0BC2]
- | [\u0BC6-\u0BC8]
- | [\u0BCA-\u0BCC]
- | '\u0BCD'
- | '\u0BD7'
- | [\u0BE6-\u0BEF]
- | [\u0C01-\u0C03]
- | [\u0C3E-\u0C40]
- | [\u0C41-\u0C44]
- | [\u0C46-\u0C48]
- | [\u0C4A-\u0C4D]
- | [\u0C55-\u0C56]
- | [\u0C66-\u0C6F]
- | [\u0C82-\u0C83]
- | '\u0CBC'
- | '\u0CBE'
- | '\u0CBF'
- | [\u0CC0-\u0CC4]
- | '\u0CC6'
- | [\u0CC7-\u0CC8]
- | [\u0CCA-\u0CCB]
- | [\u0CCC-\u0CCD]
- | [\u0CD5-\u0CD6]
- | [\u0CE6-\u0CEF]
- | [\u0D02-\u0D03]
- | [\u0D3E-\u0D40]
- | [\u0D41-\u0D43]
- | [\u0D46-\u0D48]
- | [\u0D4A-\u0D4C]
- | '\u0D4D'
- | '\u0D57'
- | [\u0D66-\u0D6F]
- | [\u0D82-\u0D83]
- | '\u0DCA'
- | [\u0DCF-\u0DD1]
- | [\u0DD2-\u0DD4]
- | '\u0DD6'
- | [\u0DD8-\u0DDF]
- | [\u0DF2-\u0DF3]
- | '\u0E31'
- | [\u0E34-\u0E3A]
- | [\u0E47-\u0E4E]
- | [\u0E50-\u0E59]
- | '\u0EB1'
- | [\u0EB4-\u0EB9]
- | [\u0EBB-\u0EBC]
- | [\u0EC8-\u0ECD]
- | [\u0ED0-\u0ED9]
- | [\u0F18-\u0F19]
- | [\u0F20-\u0F29]
- | '\u0F35'
- | '\u0F37'
- | '\u0F39'
- | [\u0F3E-\u0F3F]
- | [\u0F71-\u0F7E]
- | '\u0F7F'
- | [\u0F80-\u0F84]
- | [\u0F86-\u0F87]
- | [\u0F90-\u0F97]
- | [\u0F99-\u0FBC]
- | '\u0FC6'
- | '\u102C'
- | [\u102D-\u1030]
- | '\u1031'
- | '\u1032'
- | [\u1036-\u1037]
- | '\u1038'
- | '\u1039'
- | [\u1040-\u1049]
- | [\u1056-\u1057]
- | [\u1058-\u1059]
- | '\u135F'
- | [\u1369-\u1371]
- | [\u1712-\u1714]
- | [\u1732-\u1734]
- | [\u1752-\u1753]
- | [\u1772-\u1773]
- | '\u17B6'
- | [\u17B7-\u17BD]
- | [\u17BE-\u17C5]
- | '\u17C6'
- | [\u17C7-\u17C8]
- | [\u17C9-\u17D3]
- | '\u17DD'
- | [\u17E0-\u17E9]
- | [\u180B-\u180D]
- | [\u1810-\u1819]
- | '\u18A9'
- | [\u1920-\u1922]
- | [\u1923-\u1926]
- | [\u1927-\u1928]
- | [\u1929-\u192B]
- | [\u1930-\u1931]
- | '\u1932'
- | [\u1933-\u1938]
- | [\u1939-\u193B]
- | [\u1946-\u194F]
- | [\u19B0-\u19C0]
- | [\u19C8-\u19C9]
- | [\u19D0-\u19D9]
- | [\u1A17-\u1A18]
- | [\u1A19-\u1A1B]
- | [\u1DC0-\u1DC3]
- | [\u203F-\u2040]
- | '\u2054'
- | [\u20D0-\u20DC]
- | '\u20E1'
- | [\u20E5-\u20EB]
- | [\u302A-\u302F]
- | [\u3099-\u309A]
- | '\uA802'
- | '\uA806'
- | '\uA80B'
- | [\uA823-\uA824]
- | [\uA825-\uA826]
- | '\uA827'
- | '\uFB1E'
- | [\uFE00-\uFE0F]
- | [\uFE20-\uFE23]
- | [\uFE33-\uFE34]
- | [\uFE4D-\uFE4F]
- | [\uFF10-\uFF19]
- | '\uFF3F'
- ;
diff --git a/commons.lang/src/main/resources/META-INF/maven/archetype-metadata.xml b/commons.lang/src/main/resources/META-INF/maven/archetype-metadata.xml
deleted file mode 100644
index 904fb7a4bb..0000000000
--- a/commons.lang/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<archetype-descriptor name="archetype.plugin">
- <fileSets>
- <fileSet filtered="true" packaged="true">
- <directory>src/main/java</directory>
- </fileSet>
- <fileSet filtered="false" packaged="false">
- <directory>src/main/resources</directory>
- </fileSet>
- <fileSet filtered="false" packaged="false">
- <directory>src/test/java</directory>
- </fileSet>
- <fileSet filtered="false" packaged="false">
- <directory>src/test/resources</directory>
- </fileSet>
- </fileSets>
-</archetype-descriptor>
\ No newline at end of file
diff --git a/commons.lang/src/main/resources/archetype-resource/pom.xml b/commons.lang/src/main/resources/archetype-resource/pom.xml
deleted file mode 100644
index 8bc790b336..0000000000
--- a/commons.lang/src/main/resources/archetype-resource/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-#if (\${groupId} != "com.gitplex")
- <groupId>\${groupId}</groupId>
-#end
- <artifactId>\${artifactId}</artifactId>
- <version>\${version}</version>
- <parent>
- <groupId>com.gitplex</groupId>
- <artifactId>parent.general</artifactId>
- <version>1.0.0</version>
- </parent>
-
- <build>
- <plugins>
- <plugin>
- <groupId>com.gitplex</groupId>
- <artifactId>plugin.maven</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>${project.artifactId}</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>pmeaseRepo</id>
- <name>PMEase Repository</name>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <url>http://artifact.pmease.com/</url>
- </repository>
- </repositories>
-
- <properties>
- <moduleClass>\${package}.PluginModule</moduleClass>
- </properties>
-
-</project>
diff --git a/commons.lang/src/main/resources/archetype-resource/src/main/java/PluginModule.java b/commons.lang/src/main/resources/archetype-resource/src/main/java/PluginModule.java
deleted file mode 100644
index 7531161203..0000000000
--- a/commons.lang/src/main/resources/archetype-resource/src/main/java/PluginModule.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package ${package};
-
-import com.gitplex.commons.loader.AbstractPlugin;
-import com.gitplex.commons.loader.AbstractPluginModule;
-
-/**
- * NOTE: Do not forget to rename moduleClass property defined in the pom if you've renamed this class.
- *
- */
-public class PluginModule extends AbstractPluginModule {
-
- @Override
- protected void configure() {
- super.configure();
-
- // put your guice bindings here
- }
-
-}
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/diff/DiffUtilsTest.java b/commons.lang/src/test/java/com/gitplex/commons/lang/diff/DiffUtilsTest.java
deleted file mode 100644
index 1baed2d66f..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/diff/DiffUtilsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.gitplex.commons.lang.diff;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-
-import com.gitplex.commons.lang.diff.DiffMatchPatch.Operation;
-import com.gitplex.jsyntax.Token;
-import com.google.common.collect.Lists;
-
-public class DiffUtilsTest {
-
- private String toString(DiffBlock<List<Token>> block) {
- StringBuffer buffer = new StringBuffer();
- for (List<Token> line: block.getUnits()) {
- if (block.getOperation() == Operation.INSERT)
- buffer.append("+");
- else if (block.getOperation() == Operation.DELETE)
- buffer.append("-");
- else
- buffer.append(" ");
- for (Token token: line)
- buffer.append(token.getText());
- buffer.append("\n");
- }
- return buffer.toString();
- }
-
- @Test
- public void testDiff() {
- List<String> oldLines = Lists.newArrayList(
- "public class HelloRobin {",
- " public static void main(String[] args) {",
- " System.out.println(\"hello robin\");",
- " }",
- "}");
- List<String> newLines = Lists.newArrayList(
- "package test;",
- "public class HelloTim {",
- " public static void main(String[] args) {",
- " System.out.println(\"hello tim\");",
- " }",
- "}");
- List<DiffBlock<List<Token>>> diffBlocks = DiffUtils.diff(
- oldLines, "test.java",
- newLines, "test.java",
- WhitespaceOption.DEFAULT);
- assertEquals(""
- + "-public class HelloRobin {\n", toString(diffBlocks.get(0)));
- assertEquals(""
- + "+package test;\n"
- + "+public class HelloTim {\n", toString(diffBlocks.get(1)));
- assertEquals(""
- + " public static void main(String[] args) {\n", toString(diffBlocks.get(2)));
- assertEquals(""
- + "- System.out.println(\"hello robin\");\n", toString(diffBlocks.get(3)));
- assertEquals(""
- + "+ System.out.println(\"hello tim\");\n", toString(diffBlocks.get(4)));
- assertEquals(""
- + " }\n"
- + " }\n", toString(diffBlocks.get(5)));
- assertEquals(0, diffBlocks.get(0).getOldStart());
- assertEquals(0, diffBlocks.get(0).getNewStart());
- assertEquals(1, diffBlocks.get(1).getOldStart());
- assertEquals(0, diffBlocks.get(1).getNewStart());
- assertEquals(1, diffBlocks.get(2).getOldStart());
- assertEquals(2, diffBlocks.get(2).getNewStart());
- assertEquals(2, diffBlocks.get(3).getOldStart());
- assertEquals(3, diffBlocks.get(3).getNewStart());
- assertEquals(3, diffBlocks.get(4).getOldStart());
- assertEquals(3, diffBlocks.get(4).getNewStart());
- assertEquals(3, diffBlocks.get(5).getOldStart());
- assertEquals(4, diffBlocks.get(5).getNewStart());
- }
-
- @Test
- public void testMapLines() {
- List<String> oldLines = Lists.newArrayList(
- "line 1",
- "line 2",
- "line 3",
- "line 4",
- "line 5",
- "line 6"
- );
- List<String> newLines = Lists.newArrayList(
- "line 1",
- "line second",
- "line 3",
- "line 3.1",
- "line 4",
- "line 5",
- "line 6"
- );
- Map<Integer, Integer> map = DiffUtils.mapLines(oldLines, newLines);
- assertTrue(map.get(0) == 0);
- assertTrue(map.get(1) == null);
- assertTrue(map.get(2) == 2);
- assertTrue(map.get(3) == 4);
- assertTrue(map.get(4) == 5);
- assertTrue(map.get(5) == 6);
- }
-
-}
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/ExtractorTest.java b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/ExtractorTest.java
deleted file mode 100644
index 587b23cecb..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/ExtractorTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
-
-import com.gitplex.commons.lang.extractors.Symbol;
-import com.google.common.io.Resources;
-
-public abstract class ExtractorTest {
-
- /**
- * Describe specified symbol in specified context
- *
- * @param context
- * context to describe the symbol in. Non-leaf symbols will use context to describe
- * itself and all its child symbols. For instance, a Java class symbol description
- * contains not only the class definition, but also all declaration symbols inside
- * the class including fields and methods. In this case, it will look inside the
- * context for symbols with parent pointing to it
- * @param symbol
- * symbol to be described. Non-leaf symbol should also describe its child symbols
- *
- * @return
- * Description of the symbol
- */
- protected abstract String describe(List<Symbol> context, Symbol symbol);
-
- /**
- * This method describes the list of symbols into a string and compares it with expected string
- */
- protected void assertSymbol(String expected, List<Symbol> symbols) {
- StringBuilder builder = new StringBuilder();
- for (Symbol symbol: symbols) {
- if (symbol.getParent() == null)
- builder.append(describe(symbols, symbol));
- }
-
- Assert.assertEquals(StringUtils.replace(expected, "\r", "").trim(), builder.toString().toString().trim());
- }
-
- protected String readFile(String fileName) {
- try {
- return Resources.toString(Resources.getResource(getClass(), fileName), Charset.forName("UTF8"));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/TokenStreamTest.java b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/TokenStreamTest.java
deleted file mode 100644
index 16dbaa048b..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/TokenStreamTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.gitplex.commons.lang.extractors;
-
-import static org.junit.Assert.fail;
-
-import org.antlr.v4.runtime.ANTLRInputStream;
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.gitplex.commons.lang.extractors.ExtractException;
-import com.gitplex.commons.lang.extractors.TokenStream;
-import com.gitplex.commons.lang.extractors.TokenFilter;
-import com.gitplex.commons.lang.extractors.java.JavaLexer;
-
-public class TokenStreamTest {
-
- @Test
- public void testBalanced() {
- String text = "public class MyClass {"
- + " public void sayHello() {System.out.println(\"hello\");}"
- + "}";
-
- TokenStream extractStream = new TokenStream(
- new JavaLexer(new ANTLRInputStream(text)), TokenFilter.DEFAULT_CHANNEL);
-
- extractStream.nextType(JavaLexer.LBRACE);
- Assert.assertEquals("}", extractStream.nextClosed(JavaLexer.LBRACE, JavaLexer.RBRACE).getText());
- }
-
- @Test
- public void testNonBalanced() {
- String text = "public class MyClass {"
- + " public void sayHello() {System.out.println(\"hello\");}";
-
- TokenStream extractStream = new TokenStream(
- new JavaLexer(new ANTLRInputStream(text)), TokenFilter.DEFAULT_CHANNEL);
- extractStream.nextType(JavaLexer.LBRACE);
- try {
- extractStream.nextClosed(JavaLexer.LBRACE, JavaLexer.RBRACE);
- fail();
- } catch (ExtractException e) {
- }
- }
-
-}
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/JavaExtractorTest.java b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/JavaExtractorTest.java
deleted file mode 100644
index 11c5f11088..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/JavaExtractorTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.gitplex.commons.lang.extractors.java;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.gitplex.commons.lang.extractors.ExtractorTest;
-import com.gitplex.commons.lang.extractors.Symbol;
-import com.gitplex.commons.lang.extractors.java.JavaExtractor;
-import com.gitplex.commons.lang.extractors.java.TypeDef.Kind;
-import com.google.common.base.Joiner;
-import com.google.common.base.Splitter;
-
-public class JavaExtractorTest extends ExtractorTest {
-
- @Test
- public void testComposite() {
- assertSymbol(readFile("composite.syms"),
- new JavaExtractor().extract(readFile("composite.src")));
- }
-
- @Test
- public void testPackageInfo() {
- assertSymbol(readFile("package-info.syms"),
- new JavaExtractor().extract(readFile("package-info.src")));
- }
-
- @Test
- public void testLCount() {
- assertSymbol(readFile("LCount.syms"),
- new JavaExtractor().extract(readFile("LCount.src")));
- }
-
- @Test
- public void testResource() {
- assertSymbol(readFile("Resource.syms"),
- new JavaExtractor().extract(readFile("Resource.src")));
- }
-
- @Override
- protected String describe(List<Symbol> context, Symbol symbol) {
- if (symbol instanceof CompilationUnit) {
- CompilationUnit compilationUnit = (CompilationUnit) symbol;
- StringBuilder builder = new StringBuilder();
- if (compilationUnit.getPackageName() != null)
- builder.append("package ").append(compilationUnit.getPackageName()).append(";\n\n");
-
- return builder.toString();
- } else if (symbol instanceof TypeDef) {
- TypeDef typeDef = (TypeDef) symbol;
- StringBuilder builder = new StringBuilder();
- for (Modifier modifier: typeDef.getModifiers())
- builder.append(modifier.name().toLowerCase()).append(" ");
-
- if (typeDef.getKind() == Kind.ANNOTATION)
- builder.append("@interface").append(" ");
- else
- builder.append(typeDef.getKind().toString().toLowerCase()).append(" ");
- builder.append(typeDef.getName()).append(" {\n\n");
-
- List<String> enumConstants = new ArrayList<>();
- for (Symbol each: context) {
- if (each.getParent() == symbol && (each instanceof FieldDef)) {
- FieldDef fieldDef = (FieldDef) each;
- if (fieldDef.getType() == null)
- enumConstants.add(fieldDef.getName());
- }
- }
- if (!enumConstants.isEmpty())
- builder.append(" ").append(Joiner.on(", ").join(enumConstants)).append(";\n\n");
- else if (typeDef.getKind() == Kind.ENUM)
- builder.append(" ;\n\n");
-
- for (Symbol each: context) {
- if (each.getParent() == symbol && (each instanceof FieldDef)) {
- FieldDef fieldDef = (FieldDef) each;
- if (fieldDef.getType() != null)
- builder.append(" ").append(describe(context, fieldDef)).append("\n\n");
- }
- }
-
- for (Symbol each: context) {
- if (each.getParent() == symbol && (each instanceof MethodDef)) {
- MethodDef methodDef = (MethodDef) each;
- builder.append(" ").append(describe(context, methodDef)).append("\n\n");
- }
- }
-
- for (Symbol each: context) {
- if (each.getParent() == symbol && (each instanceof TypeDef)) {
- TypeDef subTypeDef = (TypeDef) each;
- for (String line: Splitter.on('\n').omitEmptyStrings().split(describe(context, subTypeDef)))
- builder.append(" ").append(line).append("\n\n");
- }
- }
-
- builder.append("}\n\n");
-
- return builder.toString();
- } else if (symbol instanceof FieldDef) {
- FieldDef fieldDef = (FieldDef) symbol;
- StringBuilder builder = new StringBuilder();
- for (Modifier modifier: fieldDef.getModifiers())
- builder.append(modifier.name().toLowerCase()).append(" ");
- if (fieldDef.getType() != null)
- builder.append(fieldDef.getType()).append(" ");
- builder.append(fieldDef.getName()).append(";");
- return builder.toString();
- } else if (symbol instanceof MethodDef) {
- MethodDef methodDef = (MethodDef) symbol;
- StringBuilder builder = new StringBuilder();
- for (Modifier modifier: methodDef.getModifiers())
- builder.append(modifier.name().toLowerCase()).append(" ");
- if (methodDef.getType() != null)
- builder.append(methodDef.getType()).append(" ");
- builder.append(methodDef.getName());
- if (methodDef.getParams() != null)
- builder.append("(").append(methodDef.getParams()).append(");");
- else
- builder.append("();");
- return builder.toString();
- } else {
- throw new RuntimeException("Unexpected symbol type: " + symbol.getClass());
- }
- }
-
-}
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/LCount.src b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/LCount.src
deleted file mode 100644
index 7de16a9a73..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/LCount.src
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.sun.org.apache.xerces.internal.dom;
-
-class LCount
-{
- static java.util.Hashtable lCounts=new java.util.Hashtable();
- public int captures=0,bubbles=0,defaults, total=0;
-
- static LCount lookup(String evtName)
- {
- LCount lc=(LCount)lCounts.get(evtName);
- if(lc==null)
- lCounts.put(evtName,(lc=new LCount()));
- return lc;
- }
-} // class LCount
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/LCount.syms b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/LCount.syms
deleted file mode 100644
index 74b39e2576..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/LCount.syms
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.sun.org.apache.xerces.internal.dom;
-
-class LCount {
-
- static java.util.Hashtable lCounts;
-
- public int captures;
-
- public int bubbles;
-
- public int defaults;
-
- public int total;
-
- static LCount lookup(String);
-
-}
-
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/Resource.src b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/Resource.src
deleted file mode 100644
index 65598bdd74..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/Resource.src
+++ /dev/null
@@ -1,28 +0,0 @@
-package javax.annotation;
-
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-@Target({TYPE, FIELD, METHOD})
-@Retention(RUNTIME)
-public @interface Resource {
- String name() default "";
-
- String lookup() default "";
-
- Class<?> type() default java.lang.Object.class;
-
- enum AuthenticationType {
- CONTAINER,
- APPLICATION
- }
-
- AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
-
- boolean shareable() default true;
-
- String mappedName() default "";
-
- String description() default "";
-}
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/Resource.syms b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/Resource.syms
deleted file mode 100644
index 6e017c9a7e..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/Resource.syms
+++ /dev/null
@@ -1,26 +0,0 @@
-package javax.annotation;
-
-public @interface Resource {
-
- String name();
-
- String lookup();
-
- Class<?> type();
-
- AuthenticationType authenticationType();
-
- boolean shareable();
-
- String mappedName();
-
- String description();
-
- enum AuthenticationType {
-
- CONTAINER, APPLICATION;
-
- }
-
-}
-
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/composite.src b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/composite.src
deleted file mode 100644
index 16c4a367ed..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/composite.src
+++ /dev/null
@@ -1,123 +0,0 @@
-package com.example;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-enum MyEnum {
- @SuppressWarnings("unused")
- @MyAnn(values = { "" })
- ENUM1(2 > 1 ? "Robin" : "Steve", new String[] { "value1", "value2" }), @SuppressWarnings("unused")
- ENUM2(2 > 1 ? "Robin" : "Steve", new String[] { "value1", "value2" }) {
-
- @Override
- public String getName() {
- // TODO Auto-generated method stub
- return super.getName();
- }
-
- },
- ;
- private String name;
-
- private String values[];
-
- MyEnum(String name, String... values) {
- this.name = name;
- this.values = values;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String[] getValues() {
- return values;
- }
-
- public void setValues(String[] values) {
- this.values = values;
- }
-
-};;
-
-@Target({ ElementType.TYPE_PARAMETER, ElementType.FIELD,
- ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE,
- ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER })
-@interface MyAnn {
- String[] values() default { "1", "2" };
-}
-
-@Target({ ElementType.TYPE_PARAMETER, ElementType.TYPE_USE, ElementType.FIELD,
- ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE,
- ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER })
-@interface MyAnotherAnn {
- String[] values() default { "1", "2" };
-}
-
-@SuppressWarnings("serial")
-public class Test<@MyAnn(values = { "a" }) K, V> extends HashMap<K, V> {
-
- @SuppressWarnings("unused")
- private Map<String, @MyAnotherAnn(values = { "value1", "value2" }) String> map1 = 2 < 1 ? new HashMap<String, @MyAnotherAnn String>()
- : new HashMap<String, String>(),
- map2 = (2 < 1 ? new HashMap<String, @MyAnotherAnn String>()
- : new HashMap<String, String>()),
- map3 = new HashMap<String, String>();
-
- {
- map1.put("a", "b");
- map2.put("c", "d");
- map3.put("e", "f");
- }
-
- static final java.util.List<String> values;
-
- static {
- values = new ArrayList<>();
- }
-
- static interface MyRunnable {
- void run(int a, int b);
- }
-
- class Inner {
- Runnable r1 = () -> System.out.println("Hello world two!");
-
- MyRunnable r2 = (a, b) -> {System.out.println(a+b);};
-
- public MyRunnable doSomething(Integer a, @MyAnn() @MyAnotherAnn String b) throws RuntimeException, Throwable {
- return null;
- }
-
- }
-
- public static void main(String[] args) {
-
- System.out.println("=== RunnableTest ===");
-
- // Anonymous Runnable
- Runnable r1 = new Runnable() {
-
- @Override
- public void run() {
- System.out.println("Hello world one!");
- }
- };
-
- // Lambda Runnable
- Runnable r2 = () -> System.out.println("Hello world two!");
-
- // Run em!
- r1.run();
- r2.run();
-
- }
-}
\ No newline at end of file
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/composite.syms b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/composite.syms
deleted file mode 100644
index 52eee52df3..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/composite.syms
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.example;
-
-enum MyEnum {
-
- ENUM1, ENUM2;
-
- private String name;
-
- private String[] values;
-
- MyEnum(String, String...);
-
- public String getName();
-
- public void setName(String);
-
- public String[] getValues();
-
- public void setValues(String[]);
-
-}
-
-@interface MyAnn {
-
- String[] values();
-
-}
-
-@interface MyAnotherAnn {
-
- String[] values();
-
-}
-
-public class Test {
-
- private Map<String,String> map1;
-
- private Map<String,String> map2;
-
- private Map<String,String> map3;
-
- static final java.util.List<String> values;
-
- public static void main(String[]);
-
- static interface MyRunnable {
-
- void run(int, int);
-
- }
-
- class Inner {
-
- Runnable r1;
-
- MyRunnable r2;
-
- public MyRunnable doSomething(Integer, String);
-
- }
-
-}
-
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/package-info.src b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/package-info.src
deleted file mode 100644
index 3c08192261..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/package-info.src
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- *some comment here
- */
-package com.sun.javadoc;
diff --git a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/package-info.syms b/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/package-info.syms
deleted file mode 100644
index 5268f58461..0000000000
--- a/commons.lang/src/test/java/com/gitplex/commons/lang/extractors/java/package-info.syms
+++ /dev/null
@@ -1,2 +0,0 @@
-package com.sun.javadoc;
-
diff --git a/commons.util/pom.xml b/commons.util/pom.xml
index bb0f71a966..4b9d8913f1 100644
--- a/commons.util/pom.xml
+++ b/commons.util/pom.xml
@@ -92,5 +92,21 @@
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.gitplex</groupId>
+ <artifactId>symbolextractor</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.gitplex</groupId>
+ <artifactId>jsyntax</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/commons.util/src/main/java/com/gitplex/commons/util/Highlighter.java b/commons.util/src/main/java/com/gitplex/commons/util/Highlighter.java
index b0dfdcc23a..90d663837b 100644
--- a/commons.util/src/main/java/com/gitplex/commons/util/Highlighter.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/Highlighter.java
@@ -5,6 +5,8 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import com.gitplex.symbolextractor.Range;
+
public class Highlighter {
public static String highlightRanges(String text, List<Range> ranges,
diff --git a/commons.util/src/main/java/com/gitplex/commons/util/Range.java b/commons.util/src/main/java/com/gitplex/commons/util/Range.java
deleted file mode 100644
index cee6c1ffe3..0000000000
--- a/commons.util/src/main/java/com/gitplex/commons/util/Range.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.gitplex.commons.util;
-
-import java.io.Serializable;
-
-public class Range implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private final int from;
-
- private final int to;
-
- public Range(int from, int to) {
- this.from = from;
- this.to = to;
- }
-
- public int getFrom() {
- return from;
- }
-
- public int getTo() {
- return to;
- }
-
- public Range moveBy(int distance) {
- return new Range(from+distance, to+distance);
- }
-
- @Override
- public String toString() {
- return from + "-" + to;
- }
-
-}
diff --git a/commons.util/src/main/java/com/gitplex/commons/util/RangeUtils.java b/commons.util/src/main/java/com/gitplex/commons/util/RangeUtils.java
index 6ae12a39a5..51c6a7fa68 100644
--- a/commons.util/src/main/java/com/gitplex/commons/util/RangeUtils.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/RangeUtils.java
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import com.gitplex.symbolextractor.Range;
+
public class RangeUtils {
public static List<Range> merge(Collection<Range> ranges) {
diff --git a/commons.util/src/main/java/com/gitplex/commons/util/StringUtils.java b/commons.util/src/main/java/com/gitplex/commons/util/StringUtils.java
index 27468f8859..dba4e411c7 100644
--- a/commons.util/src/main/java/com/gitplex/commons/util/StringUtils.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/StringUtils.java
@@ -11,8 +11,7 @@ import java.util.StringTokenizer;
import javax.annotation.Nullable;
-import org.unbescape.html.HtmlEscape;
-
+import com.gitplex.jsyntax.TokenizerUtils;
import com.google.common.base.CaseFormat;
public class StringUtils extends org.apache.commons.lang3.StringUtils {
@@ -329,13 +328,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
}
public static String escapeHtml(String text) {
- String escapedText = "";
- for (int i=0; i<text.length(); i++) {
- char ch = text.charAt(i);
- if (ch == ' ' || ch == '\t' || !Character.isWhitespace(ch))
- escapedText += ch;
- }
- return HtmlEscape.escapeHtml5(escapedText);
+ return TokenizerUtils.escapeHtml(text);
}
}
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffBlock.java b/commons.util/src/main/java/com/gitplex/commons/util/diff/DiffBlock.java
similarity index 90%
rename from commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffBlock.java
rename to commons.util/src/main/java/com/gitplex/commons/util/diff/DiffBlock.java
index 224050c065..7e6d671f46 100644
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffBlock.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/diff/DiffBlock.java
@@ -1,9 +1,9 @@
-package com.gitplex.commons.lang.diff;
+package com.gitplex.commons.util.diff;
import java.io.Serializable;
import java.util.List;
-import com.gitplex.commons.lang.diff.DiffMatchPatch.Operation;
+import com.gitplex.commons.util.diff.DiffMatchPatch.Operation;
public class DiffBlock<T> implements Serializable {
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffMatchPatch.java b/commons.util/src/main/java/com/gitplex/commons/util/diff/DiffMatchPatch.java
similarity index 99%
rename from commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffMatchPatch.java
rename to commons.util/src/main/java/com/gitplex/commons/util/diff/DiffMatchPatch.java
index 07d29d1811..34afcb5cd3 100644
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffMatchPatch.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/diff/DiffMatchPatch.java
@@ -16,7 +16,7 @@
* the License.
*/
-package com.gitplex.commons.lang.diff;
+package com.gitplex.commons.util.diff;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffUtils.java b/commons.util/src/main/java/com/gitplex/commons/util/diff/DiffUtils.java
similarity index 95%
rename from commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffUtils.java
rename to commons.util/src/main/java/com/gitplex/commons/util/diff/DiffUtils.java
index 4cd0665fff..8a05ff4741 100644
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/DiffUtils.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/diff/DiffUtils.java
@@ -1,4 +1,4 @@
-package com.gitplex.commons.lang.diff;
+package com.gitplex.commons.util.diff;
import java.util.ArrayList;
import java.util.HashMap;
@@ -10,11 +10,12 @@ import java.util.regex.Pattern;
import javax.annotation.Nullable;
-import com.gitplex.commons.lang.diff.DiffMatchPatch.Diff;
-import com.gitplex.commons.lang.diff.DiffMatchPatch.Operation;
import com.gitplex.commons.util.StringUtils;
+import com.gitplex.commons.util.diff.DiffMatchPatch.Diff;
+import com.gitplex.commons.util.diff.DiffMatchPatch.Operation;
import com.gitplex.jsyntax.Token;
-import com.gitplex.jsyntax.Tokenizers;
+import com.gitplex.jsyntax.Tokenizer;
+import com.gitplex.jsyntax.TokenizerRegistry;
import com.google.common.base.Preconditions;
public class DiffUtils {
@@ -42,10 +43,9 @@ public class DiffUtils {
}
private static List<List<Token>> tokenize(List<String> lines, @Nullable String fileName) {
- List<List<Token>> tokenizedLines = null;
- if (fileName != null)
- tokenizedLines = Tokenizers.tokenize(lines, fileName);
- if (tokenizedLines != null) {
+ Tokenizer tokenizer = TokenizerRegistry.getTokenizer(fileName);
+ if (tokenizer != null) {
+ List<List<Token>> tokenizedLines = tokenizer.tokenize(lines);
List<List<Token>> refinedLines = new ArrayList<>();
for (List<Token> tokenizedLine: tokenizedLines) {
List<Token> refinedLine = new ArrayList<>();
@@ -63,7 +63,7 @@ public class DiffUtils {
}
return refinedLines;
} else {
- tokenizedLines = new ArrayList<>();
+ List<List<Token>> tokenizedLines = new ArrayList<>();
for (String line: lines) {
List<Token> tokenizedLine = new ArrayList<>();
for (String each: splitByWord(line))
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/LineDiff.java b/commons.util/src/main/java/com/gitplex/commons/util/diff/LineDiff.java
similarity index 93%
rename from commons.lang/src/main/java/com/gitplex/commons/lang/diff/LineDiff.java
rename to commons.util/src/main/java/com/gitplex/commons/util/diff/LineDiff.java
index 0b18fc1253..a57bfa5467 100644
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/LineDiff.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/diff/LineDiff.java
@@ -1,4 +1,4 @@
-package com.gitplex.commons.lang.diff;
+package com.gitplex.commons.util.diff;
import java.io.Serializable;
import java.util.List;
diff --git a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/WhitespaceOption.java b/commons.util/src/main/java/com/gitplex/commons/util/diff/WhitespaceOption.java
similarity index 97%
rename from commons.lang/src/main/java/com/gitplex/commons/lang/diff/WhitespaceOption.java
rename to commons.util/src/main/java/com/gitplex/commons/util/diff/WhitespaceOption.java
index 0a3fbc6cfd..0c9a6b0931 100644
--- a/commons.lang/src/main/java/com/gitplex/commons/lang/diff/WhitespaceOption.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/diff/WhitespaceOption.java
@@ -1,4 +1,4 @@
-package com.gitplex.commons.lang.diff;
+package com.gitplex.commons.util.diff;
import java.util.regex.Pattern;
diff --git a/commons.util/src/main/java/com/gitplex/commons/util/match/PatternApplied.java b/commons.util/src/main/java/com/gitplex/commons/util/match/PatternApplied.java
index 62cb7382aa..c4ce8057e3 100644
--- a/commons.util/src/main/java/com/gitplex/commons/util/match/PatternApplied.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/match/PatternApplied.java
@@ -2,7 +2,7 @@ package com.gitplex.commons.util.match;
import java.io.Serializable;
-import com.gitplex.commons.util.Range;
+import com.gitplex.symbolextractor.Range;
public class PatternApplied implements Serializable {
diff --git a/commons.util/src/main/java/com/gitplex/commons/util/match/WildcardUtils.java b/commons.util/src/main/java/com/gitplex/commons/util/match/WildcardUtils.java
index ae30cd179b..90aa930f88 100644
--- a/commons.util/src/main/java/com/gitplex/commons/util/match/WildcardUtils.java
+++ b/commons.util/src/main/java/com/gitplex/commons/util/match/WildcardUtils.java
@@ -5,7 +5,7 @@ import java.util.List;
import javax.annotation.Nullable;
-import com.gitplex.commons.util.Range;
+import com.gitplex.symbolextractor.Range;
public class WildcardUtils {
diff --git a/commons.wicket/pom.xml b/commons.wicket/pom.xml
index d8ca45c0dd..9ae99ad2ba 100644
--- a/commons.wicket/pom.xml
+++ b/commons.wicket/pom.xml
@@ -108,6 +108,11 @@
<artifactId>commons.antlr</artifactId>
<version>1.0-EAP-build18</version>
</dependency>
+ <dependency>
+ <groupId>org.webjars.npm</groupId>
+ <artifactId>codemirror</artifactId>
+ <version>5.21.0</version>
+ </dependency>
</dependencies>
<properties>
<moduleClass>com.gitplex.commons.wicket.WicketModule</moduleClass>
diff --git a/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/annotatescrollbar2.js b/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/annotatescrollbar2.js
index 1fdf781afb..42310707fc 100644
--- a/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/annotatescrollbar2.js
+++ b/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/annotatescrollbar2.js
@@ -51,7 +51,7 @@
Annotation.prototype.computeScale = function() {
var cm = this.cm;
var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
- cm.heightAtLine(cm.lastLine() + 1, "local");
+ cm.getScrollerElement().scrollHeight
if (hScale != this.hScale) {
this.hScale = hScale;
return true;
@@ -68,15 +68,30 @@
var cm = this.cm, hScale = this.hScale;
var frag = document.createDocumentFragment(), anns = this.annotations;
+
+ var wrapping = cm.getOption("lineWrapping");
+ var singleLineH = wrapping && cm.defaultTextHeight() * 1.5;
+ var curLine = null, curLineObj = null;
+ function getY(pos, top) {
+ if (curLine != pos.line) {
+ curLine = pos.line;
+ curLineObj = cm.getLineHandle(curLine);
+ }
+ if (wrapping && curLineObj.height > singleLineH)
+ return cm.charCoords(pos, "local")[top ? "top" : "bottom"];
+ var topY = cm.heightAtLine(curLineObj, "local");
+ return topY + (top ? 0 : curLineObj.height);
+ }
+
if (cm.display.barWidth) for (var i = 0, nextTop; i < anns.length; i++) {
var ann = anns[i];
- var top = nextTop || cm.charCoords(ann.from, "local").top * hScale;
- var bottom = cm.charCoords(ann.to, "local").bottom * hScale;
+ var top = nextTop || getY(ann.from, true) * hScale;
+ var bottom = getY(ann.to, false) * hScale;
while (i < anns.length - 1) {
- nextTop = cm.charCoords(anns[i + 1].from, "local").top * hScale;
+ nextTop = getY(anns[i + 1].from, true) * hScale;
if (nextTop > bottom + .9) break;
ann = anns[++i];
- bottom = cm.charCoords(ann.to, "local").bottom * hScale;
+ bottom = getY(ann.to, false) * hScale;
}
if (bottom == top) continue;
var height = Math.max(bottom - top, 3);
@@ -85,6 +100,9 @@
elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
+ (top + this.buttonHeight) + "px; height: " + height + "px";
elt.className = this.options.className;
+ if (ann.id) {
+ elt.setAttribute("annotation-id", ann.id);
+ }
}
this.div.textContent = "";
this.div.appendChild(frag);
diff --git a/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/matchesonscrollbar2.js b/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/matchesonscrollbar2.js
index ddc990e3cb..db81bd46f2 100644
--- a/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/matchesonscrollbar2.js
+++ b/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/matchesonscrollbar2.js
@@ -19,6 +19,7 @@
function SearchAnnotation(cm, query, caseFold, options) {
this.cm = cm;
+ this.options = options;
var annotateOptions = {listenForChanges: false};
for (var prop in options) annotateOptions[prop] = options[prop];
if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match2";
@@ -46,11 +47,12 @@
if (match.to.line >= this.gap.from) this.matches.splice(i--, 1);
}
var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), this.caseFold);
+ var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES;
while (cursor.findNext()) {
var match = {from: cursor.from(), to: cursor.to()};
if (match.from.line >= this.gap.to) break;
this.matches.splice(i++, 0, match);
- if (this.matches.length > MAX_MATCHES) break;
+ if (this.matches.length > maxMatches) break;
}
this.gap = null;
};
diff --git a/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/simplescrollbars.js b/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/simplescrollbars.js
index 3b8c54e2e8..2878d2f54e 100644
--- a/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/simplescrollbars.js
+++ b/commons.wicket/src/main/java/com/gitplex/commons/wicket/assets/codemirror/simplescrollbars.js
@@ -89,22 +89,29 @@
CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
}
- Bar.prototype.moveTo = function(pos, update) {
+ Bar.prototype.setPos = function(pos, force) {
if (pos < 0) pos = 0;
if (pos > this.total - this.screen) pos = this.total - this.screen;
- if (pos == this.pos) return;
+ if (!force && pos == this.pos) return false;
this.pos = pos;
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
(pos * (this.size / this.total)) + "px";
- if (update !== false) this.scroll(pos, this.orientation);
+ return true
};
+ Bar.prototype.moveTo = function(pos) {
+ if (this.setPos(pos)) this.scroll(pos, this.orientation);
+ }
+
var minButtonSize = 10;
Bar.prototype.update = function(scrollSize, clientSize, barSize) {
- this.screen = clientSize;
- this.total = scrollSize;
- this.size = barSize;
+ var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize
+ if (sizeChanged) {
+ this.screen = clientSize;
+ this.total = scrollSize;
+ this.size = barSize;
+ }
var buttonSize = this.screen * (this.size / this.total);
if (buttonSize < minButtonSize) {
@@ -113,8 +120,7 @@
}
this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
buttonSize + "px";
- this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
- this.pos * (this.size / this.total) + "px";
+ this.setPos(this.pos, sizeChanged);
};
function SimpleScrollbars(cls, place, scroll) {
@@ -141,7 +147,6 @@
if (needsV) {
this.vert.update(measure.scrollHeight, measure.clientHeight,
measure.viewHeight - (needsH ? width : 0));
- this.vert.node.style.display = "block";
this.vert.node.style.bottom = needsH ? width + "px" : "0";
}
if (needsH) {
@@ -155,11 +160,11 @@
};
SimpleScrollbars.prototype.setScrollTop = function(pos) {
- this.vert.moveTo(pos, false);
+ this.vert.setPos(pos, false);
};
SimpleScrollbars.prototype.setScrollLeft = function(pos) {
- this.horiz.moveTo(pos, false);
+ this.horiz.setPos(pos, false);
};
SimpleScrollbars.prototype.clear = function() {
diff --git a/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java b/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java
index d4245b7fe1..b504158056 100644
--- a/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java
+++ b/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java
@@ -27,8 +27,8 @@ import com.gitplex.commons.antlr.codeassist.InputStatus;
import com.gitplex.commons.antlr.codeassist.InputSuggestion;
import com.gitplex.commons.antlr.codeassist.ParentedElement;
import com.gitplex.commons.antlr.grammar.ElementSpec;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.StringUtils;
+import com.gitplex.symbolextractor.Range;
@SuppressWarnings("serial")
public abstract class ANTLRAssistBehavior extends InputAssistBehavior {
diff --git a/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/AssistPanel.java b/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/AssistPanel.java
index 475a8e130a..c63d70100d 100644
--- a/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/AssistPanel.java
+++ b/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/AssistPanel.java
@@ -13,8 +13,8 @@ import org.apache.wicket.markup.repeater.RepeatingView;
import com.gitplex.commons.antlr.codeassist.InputCompletion;
import com.gitplex.commons.antlr.codeassist.InputStatus;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.wicket.behavior.infinitescroll.InfiniteScrollBehavior;
+import com.gitplex.symbolextractor.Range;
@SuppressWarnings("serial")
class AssistPanel extends Panel {
diff --git a/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/InputAssistBehavior.java b/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/InputAssistBehavior.java
index e48f8133e0..3b999fa456 100644
--- a/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/InputAssistBehavior.java
+++ b/commons.wicket/src/main/java/com/gitplex/commons/wicket/behavior/inputassist/InputAssistBehavior.java
@@ -21,13 +21,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.gitplex.commons.antlr.codeassist.InputCompletion;
import com.gitplex.commons.antlr.codeassist.InputStatus;
import com.gitplex.commons.loader.AppLoader;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.RangeUtils;
import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
import com.gitplex.commons.wicket.component.floating.AlignPlacement;
import com.gitplex.commons.wicket.component.floating.AlignTarget;
import com.gitplex.commons.wicket.component.floating.ComponentTarget;
import com.gitplex.commons.wicket.component.floating.FloatingPanel;
+import com.gitplex.symbolextractor.Range;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
diff --git a/commons.wicket/src/main/java/com/gitplex/commons/wicket/component/HighlightableLabel.java b/commons.wicket/src/main/java/com/gitplex/commons/wicket/component/HighlightableLabel.java
deleted file mode 100644
index 6d65c9d6a1..0000000000
--- a/commons.wicket/src/main/java/com/gitplex/commons/wicket/component/HighlightableLabel.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.gitplex.commons.wicket.component;
-
-import javax.annotation.Nullable;
-
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.model.LoadableDetachableModel;
-
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.util.StringUtils;
-
-@SuppressWarnings("serial")
-public class HighlightableLabel extends Label {
-
- public HighlightableLabel(String id, @Nullable String label, @Nullable Range highlight) {
- super(id, new LoadableDetachableModel<String>() {
-
- @Override
- protected String load() {
- if (label != null) {
- if (highlight != null) {
- String prefix = label.substring(0, highlight.getFrom());
- String middle = label.substring(highlight.getFrom(), highlight.getTo());
- String suffix = label.substring(highlight.getTo());
- return StringUtils.escapeHtml(prefix)
- + "<b>"
- + StringUtils.escapeHtml(middle)
- + "</b>"
- + StringUtils.escapeHtml(suffix);
- } else {
- return StringUtils.escapeHtml(label);
- }
- } else {
- return "";
- }
- }
-
- });
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
- setEscapeModelStrings(false);
- }
-
-}
diff --git a/pom.xml b/pom.xml
index ba25226ae7..eccbbfa6c0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
<module>commons.jetty</module>
<module>commons.git</module>
<module>commons.hibernate</module>
- <module>commons.lang</module>
+
<module>commons.jersey</module>
<module>commons.shiro</module>
<module>commons.wicket</module>
@@ -79,19 +79,6 @@
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <versionRange>[1.0.0,)</versionRange>
- <goals>
- <goal>enforce</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore/>
- </action>
- </pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.gitplex</groupId>
@@ -312,28 +299,6 @@
</plugin>
</plugins>
</pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.3.1</version>
- <executions>
- <execution>
- <id>enforce-java</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireJavaVersion>
- <version>1.8.0</version>
- </requireJavaVersion>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
</build>
<dependencyManagement>
<dependencies>
diff --git a/server.core/src/main/java/com/gitplex/server/core/entity/PullRequest.java b/server.core/src/main/java/com/gitplex/server/core/entity/PullRequest.java
index c19be3292b..a4143dccc4 100644
--- a/server.core/src/main/java/com/gitplex/server/core/entity/PullRequest.java
+++ b/server.core/src/main/java/com/gitplex/server/core/entity/PullRequest.java
@@ -45,7 +45,7 @@ import com.gitplex.commons.hibernate.AbstractEntity;
import com.gitplex.commons.hibernate.UnitOfWork;
import com.gitplex.commons.hibernate.dao.Dao;
import com.gitplex.commons.jackson.ExternalView;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.commons.wicket.editable.EditableUtils;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.support.CloseInfo;
diff --git a/server.core/src/main/java/com/gitplex/server/core/entity/support/CompareContext.java b/server.core/src/main/java/com/gitplex/server/core/entity/support/CompareContext.java
index 340b00b6dc..af2747bb9a 100644
--- a/server.core/src/main/java/com/gitplex/server/core/entity/support/CompareContext.java
+++ b/server.core/src/main/java/com/gitplex/server/core/entity/support/CompareContext.java
@@ -9,7 +9,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.OptimisticLock;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
@Embeddable
public class CompareContext implements Serializable {
diff --git a/server.core/src/main/java/com/gitplex/server/core/entity/support/TextRange.java b/server.core/src/main/java/com/gitplex/server/core/entity/support/TextRange.java
index 0fd94bdc06..7660aa49fe 100644
--- a/server.core/src/main/java/com/gitplex/server/core/entity/support/TextRange.java
+++ b/server.core/src/main/java/com/gitplex/server/core/entity/support/TextRange.java
@@ -8,7 +8,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
-import com.gitplex.commons.lang.extractors.TokenPosition;
+import com.gitplex.symbolextractor.TokenPosition;
public class TextRange implements Serializable {
@@ -34,8 +34,8 @@ public class TextRange implements Serializable {
}
public TextRange(TokenPosition tokenPos) {
- this(tokenPos.getLine(), tokenPos.getRange().getFrom(),
- tokenPos.getLine(), tokenPos.getRange().getTo());
+ this(tokenPos.getFromLine(), tokenPos.getFromCh(),
+ tokenPos.getToLine(), tokenPos.getToCh());
}
public TextRange(String markStr) {
diff --git a/server.product/src/test/java/com/gitplex/server/product/Test.java b/server.product/src/test/java/com/gitplex/server/product/Test.java
index 0443be550c..5b8e28b072 100644
--- a/server.product/src/test/java/com/gitplex/server/product/Test.java
+++ b/server.product/src/test/java/com/gitplex/server/product/Test.java
@@ -1,16 +1,31 @@
package com.gitplex.server.product;
import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
public class Test {
@org.junit.Test
public void test() throws IOException {
- Matcher matcher = Pattern.compile("\\d+\\.\\d+").matcher("1.0-EAP");
- matcher.find();
- System.out.println(matcher.group());
+ /*
+ BufferedImage image = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
+ Graphics graphics = null;
+ try {
+ graphics = image.getGraphics();
+
+ graphics.setColor(Color.decode("0x7F55FF"));
+ graphics.fillOval(0, 0, 16, 16);
+
+ int fontSize = new Double(16).intValue();
+ Font font = new Font(Font.MONOSPACED, Font.BOLD, fontSize);
+ graphics.setFont(font);
+ graphics.setColor(Color.WHITE);
+ graphics.drawString("p", 4, 13);
+ ImageIO.write(image, "PNG", new File("w:\\temp\\icons\\property.png"));
+ } finally {
+ if (graphics != null)
+ graphics.dispose();
+ }
+ */
}
}
\ No newline at end of file
diff --git a/server.search/src/main/java/com/gitplex/server/search/DefaultIndexManager.java b/server.search/src/main/java/com/gitplex/server/search/DefaultIndexManager.java
index 8738836a6c..451cafdd44 100644
--- a/server.search/src/main/java/com/gitplex/server/search/DefaultIndexManager.java
+++ b/server.search/src/main/java/com/gitplex/server/search/DefaultIndexManager.java
@@ -59,13 +59,7 @@ import org.eclipse.jgit.treewalk.filter.TreeFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
import com.gitplex.commons.hibernate.UnitOfWork;
-import com.gitplex.commons.lang.extractors.ExtractException;
-import com.gitplex.commons.lang.extractors.Extractor;
-import com.gitplex.commons.lang.extractors.Extractors;
-import com.gitplex.commons.lang.extractors.Symbol;
import com.gitplex.commons.loader.Listen;
import com.gitplex.commons.loader.ListenerRegistry;
import com.gitplex.commons.util.ContentDetector;
@@ -77,6 +71,11 @@ import com.gitplex.server.core.manager.DepotManager;
import com.gitplex.server.core.manager.StorageManager;
import com.gitplex.server.core.manager.support.BatchWorker;
import com.gitplex.server.core.manager.support.IndexResult;
+import com.gitplex.symbolextractor.Symbol;
+import com.gitplex.symbolextractor.SymbolExtractor;
+import com.gitplex.symbolextractor.SymbolExtractorRegistry;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
@Singleton
public class DefaultIndexManager implements IndexManager {
@@ -93,8 +92,6 @@ public class DefaultIndexManager implements IndexManager {
private final BatchWorkManager batchWorkManager;
- private final Extractors extractors;
-
private final UnitOfWork unitOfWork;
private final DepotManager depotManager;
@@ -103,12 +100,10 @@ public class DefaultIndexManager implements IndexManager {
@Inject
public DefaultIndexManager(ListenerRegistry listenerRegistry, StorageManager storageManager,
- BatchWorkManager batchWorkManager, Extractors extractors, UnitOfWork unitOfWork,
- DepotManager depotManager) {
+ BatchWorkManager batchWorkManager, UnitOfWork unitOfWork, DepotManager depotManager) {
this.listenerRegistry = listenerRegistry;
this.storageManager = storageManager;
this.batchWorkManager = batchWorkManager;
- this.extractors = extractors;
this.unitOfWork = unitOfWork;
this.depotManager = depotManager;
}
@@ -155,7 +150,7 @@ public class DefaultIndexManager implements IndexManager {
if (topDocs.scoreDocs.length != 0) {
Document doc = searcher.doc(topDocs.scoreDocs[0].doc);
String lastCommitAnalyzersVersion = doc.get(LAST_COMMIT_INDEX_VERSION.name());
- if (lastCommitAnalyzersVersion.equals(extractors.getVersion())) {
+ if (lastCommitAnalyzersVersion.equals(SymbolExtractorRegistry.getVersion())) {
String lastCommitHash = doc.get(LAST_COMMIT_HASH.name());
ObjectId lastCommitId = repository.resolve(lastCommitHash);
if (repository.hasObject(lastCommitId)) {
@@ -207,7 +202,7 @@ public class DefaultIndexManager implements IndexManager {
checked++;
}
- Extractor extractor = extractors.getExtractor(blobPath);
+ SymbolExtractor extractor = SymbolExtractorRegistry.getExtractor(blobPath);
String currentBlobIndexVersion = getCurrentBlobIndexVersion(extractor);
String blobIndexVersion = blobIndexVersionRef.get();
if (blobIndexVersion != null) {
@@ -236,7 +231,7 @@ public class DefaultIndexManager implements IndexManager {
// record last commit so that we only need to indexing changed files for subsequent commits
document = new Document();
document.add(new StringField(META.name(), LAST_COMMIT.name(), Store.NO));
- document.add(new StoredField(LAST_COMMIT_INDEX_VERSION.name(), extractors.getVersion()));
+ document.add(new StoredField(LAST_COMMIT_INDEX_VERSION.name(), SymbolExtractorRegistry.getVersion()));
document.add(new StoredField(LAST_COMMIT_HASH.name(), commitId.getName()));
writer.updateDocument(META.term(LAST_COMMIT.name()), document);
@@ -245,7 +240,7 @@ public class DefaultIndexManager implements IndexManager {
}
private void indexBlob(IndexWriter writer, Repository repository,
- Extractor extractor, ObjectId blobId, String blobPath) throws IOException {
+ SymbolExtractor extractor, ObjectId blobId, String blobPath) throws IOException {
Document document = new Document();
document.add(new StoredField(BLOB_INDEX_VERSION.name(), getCurrentBlobIndexVersion(extractor)));
@@ -268,7 +263,7 @@ public class DefaultIndexManager implements IndexManager {
if (extractor != null) {
try {
for (Symbol symbol: extractor.extract(content)) {
- String fieldValue = symbol.getName();
+ String fieldValue = symbol.getIndexName();
if (fieldValue != null) {
fieldValue = fieldValue.toLowerCase();
@@ -280,7 +275,7 @@ public class DefaultIndexManager implements IndexManager {
document.add(new StringField(fieldName, fieldValue, Store.NO));
}
}
- } catch (ExtractException e) {
+ } catch (Exception e) {
logger.error("Error extracting symbols from blob (hash:" + blobId.name() + ", path:" + blobPath + ")", e);
}
}
@@ -371,10 +366,10 @@ public class DefaultIndexManager implements IndexManager {
}
private String getCurrentCommitIndexVersion() {
- return INDEX_VERSION + ";" + extractors.getVersion();
+ return INDEX_VERSION + ";" + SymbolExtractorRegistry.getVersion();
}
- private String getCurrentBlobIndexVersion(Extractor extractor) {
+ private String getCurrentBlobIndexVersion(SymbolExtractor extractor) {
if (extractor != null)
return INDEX_VERSION + ";" + extractor.getVersion();
else
diff --git a/server.search/src/main/java/com/gitplex/server/search/hit/FileHit.java b/server.search/src/main/java/com/gitplex/server/search/hit/FileHit.java
index 5071968377..5847fa015d 100644
--- a/server.search/src/main/java/com/gitplex/server/search/hit/FileHit.java
+++ b/server.search/src/main/java/com/gitplex/server/search/hit/FileHit.java
@@ -4,11 +4,12 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.wicket.component.HighlightableLabel;
+import com.gitplex.symbolextractor.Range;
+import com.gitplex.symbolextractor.util.HighlightableLabel;
+import com.gitplex.symbolextractor.util.NoAntiCacheImage;
public class FileHit extends QueryHit {
@@ -36,8 +37,8 @@ public class FileHit extends QueryHit {
}
@Override
- public ResourceReference getIcon() {
- return new PackageResourceReference(FileHit.class, "file.png");
+ public Image renderIcon(String componentId) {
+ return new NoAntiCacheImage(componentId, new PackageResourceReference(FileHit.class, "file.png"));
}
@Override
diff --git a/server.search/src/main/java/com/gitplex/server/search/hit/PathHit.java b/server.search/src/main/java/com/gitplex/server/search/hit/PathHit.java
new file mode 100644
index 0000000000..cd4263d8c2
--- /dev/null
+++ b/server.search/src/main/java/com/gitplex/server/search/hit/PathHit.java
@@ -0,0 +1,53 @@
+package com.gitplex.server.search.hit;
+
+import javax.annotation.Nullable;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.image.Image;
+import org.apache.wicket.request.resource.PackageResourceReference;
+
+import com.gitplex.symbolextractor.Range;
+import com.gitplex.symbolextractor.util.HighlightableLabel;
+import com.gitplex.symbolextractor.util.NoAntiCacheImage;
+
+public class PathHit extends QueryHit {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Range matchRange;
+
+ public PathHit(String blobPath, @Nullable Range matchRange) {
+ super(blobPath, null);
+ this.matchRange = matchRange;
+ }
+
+ @Override
+ public String toString() {
+ return getBlobPath();
+ }
+
+ @Override
+ public Component render(String componentId) {
+ return new HighlightableLabel(componentId, getBlobPath(), matchRange);
+ }
+
+ @Override
+ public Image renderIcon(String componentId) {
+ return new NoAntiCacheImage(componentId, new PackageResourceReference(PathHit.class, "file.png"));
+ }
+
+ @Override
+ public String getScope() {
+ return null;
+ }
+
+ public Range getMatchRange() {
+ return matchRange;
+ }
+
+ @Override
+ protected int score() {
+ return getBlobPath().length();
+ }
+
+}
diff --git a/server.search/src/main/java/com/gitplex/server/search/hit/QueryHit.java b/server.search/src/main/java/com/gitplex/server/search/hit/QueryHit.java
index 19133aea49..debe94152a 100644
--- a/server.search/src/main/java/com/gitplex/server/search/hit/QueryHit.java
+++ b/server.search/src/main/java/com/gitplex/server/search/hit/QueryHit.java
@@ -5,9 +5,9 @@ import java.io.Serializable;
import javax.annotation.Nullable;
import org.apache.wicket.Component;
-import org.apache.wicket.request.resource.ResourceReference;
+import org.apache.wicket.markup.html.image.Image;
-import com.gitplex.commons.lang.extractors.TokenPosition;
+import com.gitplex.symbolextractor.TokenPosition;
public abstract class QueryHit implements Serializable, Comparable<QueryHit> {
@@ -38,7 +38,7 @@ public abstract class QueryHit implements Serializable, Comparable<QueryHit> {
@Nullable
public abstract String getScope();
- public abstract ResourceReference getIcon();
+ public abstract Image renderIcon(String componentId);
protected abstract int score();
diff --git a/server.search/src/main/java/com/gitplex/server/search/hit/SymbolHit.java b/server.search/src/main/java/com/gitplex/server/search/hit/SymbolHit.java
index 815c25b6c8..c41830a201 100644
--- a/server.search/src/main/java/com/gitplex/server/search/hit/SymbolHit.java
+++ b/server.search/src/main/java/com/gitplex/server/search/hit/SymbolHit.java
@@ -3,10 +3,10 @@ package com.gitplex.server.search.hit;
import javax.annotation.Nullable;
import org.apache.wicket.Component;
-import org.apache.wicket.request.resource.ResourceReference;
+import org.apache.wicket.markup.html.image.Image;
-import com.gitplex.commons.lang.extractors.Symbol;
-import com.gitplex.commons.util.Range;
+import com.gitplex.symbolextractor.Range;
+import com.gitplex.symbolextractor.Symbol;
public class SymbolHit extends QueryHit {
@@ -17,7 +17,7 @@ public class SymbolHit extends QueryHit {
private final Range matchRange;
public SymbolHit(String blobPath, Symbol symbol, @Nullable Range matchRange) {
- super(blobPath, symbol.getPos());
+ super(blobPath, symbol.getPosition());
this.symbol = symbol;
this.matchRange = matchRange;
}
@@ -37,10 +37,10 @@ public class SymbolHit extends QueryHit {
}
@Override
- public ResourceReference getIcon() {
- return symbol.getIcon();
+ public Image renderIcon(String componentId) {
+ return symbol.renderIcon(componentId);
}
-
+
@Override
public String getScope() {
return symbol.getScope();
diff --git a/server.search/src/main/java/com/gitplex/server/search/hit/TextHit.java b/server.search/src/main/java/com/gitplex/server/search/hit/TextHit.java
index 5c81f8a444..7f9a15d47c 100644
--- a/server.search/src/main/java/com/gitplex/server/search/hit/TextHit.java
+++ b/server.search/src/main/java/com/gitplex/server/search/hit/TextHit.java
@@ -2,12 +2,13 @@ package com.gitplex.server.search.hit;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-import com.gitplex.commons.lang.extractors.TokenPosition;
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.wicket.component.HighlightableLabel;
+import com.gitplex.symbolextractor.Range;
+import com.gitplex.symbolextractor.TokenPosition;
+import com.gitplex.symbolextractor.util.HighlightableLabel;
+import com.gitplex.symbolextractor.util.NoAntiCacheImage;
public class TextHit extends QueryHit {
@@ -25,25 +26,15 @@ public class TextHit extends QueryHit {
return lineContent;
}
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append(getTokenPos().getLine()).append(": ");
- Range range = getTokenPos().getRange();
- builder.append(lineContent.substring(0, range.getFrom()));
- builder.append("[").append(lineContent.substring(range.getFrom(), range.getTo())).append("]");
- builder.append(lineContent.substring(range.getTo()));
- return builder.toString();
- }
-
@Override
public Component render(String componentId) {
- return new HighlightableLabel(componentId, lineContent, getTokenPos().getRange());
+ return new HighlightableLabel(componentId, lineContent,
+ new Range(getTokenPos().getFromCh(), getTokenPos().getToCh()));
}
@Override
- public ResourceReference getIcon() {
- return new PackageResourceReference(FileHit.class, "bullet.gif");
+ public Image renderIcon(String componentId) {
+ return new NoAntiCacheImage(componentId, new PackageResourceReference(FileHit.class, "bullet.gif"));
}
@Override
diff --git a/server.search/src/main/java/com/gitplex/server/search/query/BlobQuery.java b/server.search/src/main/java/com/gitplex/server/search/query/BlobQuery.java
index a96a45506f..5100ceccd9 100644
--- a/server.search/src/main/java/com/gitplex/server/search/query/BlobQuery.java
+++ b/server.search/src/main/java/com/gitplex/server/search/query/BlobQuery.java
@@ -4,6 +4,8 @@ import static com.gitplex.server.search.FieldConstants.BLOB_PATH;
import java.util.List;
+import javax.annotation.Nullable;
+
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
@@ -14,12 +16,20 @@ import com.gitplex.server.search.hit.QueryHit;
public abstract class BlobQuery {
+ private final String directory;
+
private final int count;
- public BlobQuery(int count) {
+ public BlobQuery(@Nullable String directory, int count) {
+ this.directory = directory;
this.count = count;
}
+ @Nullable
+ public String getDirectory() {
+ return directory;
+ }
+
public int getCount() {
return count;
}
@@ -34,11 +44,21 @@ public abstract class BlobQuery {
* @throws
* TooGeneralQueryException if supplied query term is too general to possibly cause query slow
*/
- public abstract Query asLuceneQuery() throws TooGeneralQueryException;
-
- protected void applyDirectory(BooleanQuery query, String directory) {
- if (!directory.endsWith("/"))
- directory += "/";
- query.add(new WildcardQuery(BLOB_PATH.term(directory + "*")), Occur.MUST);
+ public Query asLuceneQuery() throws TooGeneralQueryException {
+ BooleanQuery luceneQuery = new BooleanQuery(true);
+
+ String directory = this.directory;
+ if (directory != null) {
+ if (!directory.endsWith("/"))
+ directory += "/";
+ luceneQuery.add(new WildcardQuery(BLOB_PATH.term(directory + "*")), Occur.MUST);
+ }
+
+ applyConstraints(luceneQuery);
+
+ return luceneQuery;
}
+
+ protected abstract void applyConstraints(BooleanQuery query);
+
}
diff --git a/server.search/src/main/java/com/gitplex/server/search/query/FileQuery.java b/server.search/src/main/java/com/gitplex/server/search/query/FileQuery.java
index 957f8daaa8..f00ad9fd6c 100644
--- a/server.search/src/main/java/com/gitplex/server/search/query/FileQuery.java
+++ b/server.search/src/main/java/com/gitplex/server/search/query/FileQuery.java
@@ -9,15 +9,14 @@ import javax.annotation.Nullable;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
import org.apache.lucene.search.WildcardQuery;
import org.eclipse.jgit.treewalk.TreeWalk;
-import com.google.common.base.Splitter;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.match.WildcardUtils;
import com.gitplex.server.search.hit.FileHit;
import com.gitplex.server.search.hit.QueryHit;
+import com.gitplex.symbolextractor.Range;
+import com.google.common.base.Splitter;
public class FileQuery extends BlobQuery {
@@ -27,16 +26,13 @@ public class FileQuery extends BlobQuery {
private final boolean caseSensitive;
- private final String directory;
-
public FileQuery(String fileNames, @Nullable String excludeFileName, boolean caseSensitive,
@Nullable String directory, int count) {
- super(count);
+ super(directory, count);
this.fileNames = fileNames;
this.excludeFileName = excludeFileName;
this.caseSensitive = caseSensitive;
- this.directory = directory;
}
@Override
@@ -65,12 +61,7 @@ public class FileQuery extends BlobQuery {
}
@Override
- public Query asLuceneQuery() throws TooGeneralQueryException {
- BooleanQuery query = new BooleanQuery(true);
-
- if (directory != null)
- applyDirectory(query, directory);
-
+ protected void applyConstraints(BooleanQuery query) {
boolean tooGeneral = true;
for (char ch: fileNames.toCharArray()) {
if (ch != '?' && ch != '*' && ch != ',' && ch != '.') {
@@ -89,8 +80,6 @@ public class FileQuery extends BlobQuery {
query.add(subQuery, Occur.MUST);
else
throw new TooGeneralQueryException();
-
- return query;
}
}
diff --git a/server.search/src/main/java/com/gitplex/server/search/query/PathQuery.java b/server.search/src/main/java/com/gitplex/server/search/query/PathQuery.java
new file mode 100644
index 0000000000..cce932b93b
--- /dev/null
+++ b/server.search/src/main/java/com/gitplex/server/search/query/PathQuery.java
@@ -0,0 +1,43 @@
+package com.gitplex.server.search.query;
+
+import static com.gitplex.server.search.FieldConstants.BLOB_PATH;
+
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.WildcardQuery;
+import org.eclipse.jgit.treewalk.TreeWalk;
+
+import com.gitplex.server.search.hit.PathHit;
+import com.gitplex.server.search.hit.QueryHit;
+import com.gitplex.symbolextractor.Range;
+
+public class PathQuery extends BlobQuery {
+
+ private final String subPath;
+
+ public PathQuery(@Nullable String directory, String subPath, int count) {
+ super(directory, count);
+ this.subPath = subPath;
+ }
+
+ @Override
+ public void collect(TreeWalk treeWalk, List<QueryHit> hits) {
+ String blobPath = treeWalk.getPathString();
+ int index = blobPath.indexOf(subPath);
+ if (index != -1) {
+ Range matchRange = new Range(index, index+subPath.length());
+ hits.add(new PathHit(blobPath, matchRange));
+ }
+ }
+
+ @Override
+ protected void applyConstraints(BooleanQuery query) {
+ query.add(new WildcardQuery(new Term(BLOB_PATH.name(), "*"+subPath+"*")), Occur.MUST);
+ }
+
+}
diff --git a/server.search/src/main/java/com/gitplex/server/search/query/SymbolQuery.java b/server.search/src/main/java/com/gitplex/server/search/query/SymbolQuery.java
index 6a89203847..e74e103c19 100644
--- a/server.search/src/main/java/com/gitplex/server/search/query/SymbolQuery.java
+++ b/server.search/src/main/java/com/gitplex/server/search/query/SymbolQuery.java
@@ -13,24 +13,22 @@ import javax.annotation.Nullable;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
import org.apache.lucene.search.WildcardQuery;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.gitplex.server.core.GitPlex;
+import com.gitplex.commons.util.ContentDetector;
+import com.gitplex.commons.util.match.WildcardUtils;
import com.gitplex.server.search.hit.QueryHit;
import com.gitplex.server.search.hit.SymbolHit;
+import com.gitplex.symbolextractor.ExtractException;
+import com.gitplex.symbolextractor.Range;
+import com.gitplex.symbolextractor.Symbol;
+import com.gitplex.symbolextractor.SymbolExtractor;
+import com.gitplex.symbolextractor.SymbolExtractorRegistry;
import com.google.common.base.Splitter;
-import com.gitplex.commons.lang.extractors.ExtractException;
-import com.gitplex.commons.lang.extractors.Extractor;
-import com.gitplex.commons.lang.extractors.Extractors;
-import com.gitplex.commons.lang.extractors.Symbol;
-import com.gitplex.commons.util.ContentDetector;
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.util.match.WildcardUtils;
public class SymbolQuery extends BlobQuery {
@@ -44,19 +42,17 @@ public class SymbolQuery extends BlobQuery {
private final boolean caseSensitive;
- private final String directory;
-
private final String fileNames;
public SymbolQuery(String term, @Nullable String excludeTerm, boolean primary,
- boolean caseSensitive, @Nullable String directory, @Nullable String fileNames, int count) {
- super(count);
+ boolean caseSensitive, @Nullable String directory, @Nullable String fileNames,
+ int count) {
+ super(directory, count);
this.term = term;
this.excludeTerm = excludeTerm;
this.primary = primary;
this.caseSensitive = caseSensitive;
- this.directory = directory;
this.fileNames = fileNames;
}
@@ -64,7 +60,7 @@ public class SymbolQuery extends BlobQuery {
public void collect(TreeWalk treeWalk, List<QueryHit> hits) {
String blobPath = treeWalk.getPathString();
- Extractor extractor = GitPlex.getInstance(Extractors.class).getExtractor(blobPath);
+ SymbolExtractor extractor = SymbolExtractorRegistry.getExtractor(blobPath);
if (extractor != null) {
ObjectLoader objectLoader;
try {
@@ -76,7 +72,7 @@ public class SymbolQuery extends BlobQuery {
try {
for (Symbol symbol: extractor.extract(content)) {
if (hits.size() < getCount()) {
- if (primary == symbol.isPrimary() && symbol.getName() != null) {
+ if (primary == symbol.isPrimary() && symbol.getIndexName() != null) {
String normalizedTerm;
if (!caseSensitive)
normalizedTerm = term.toLowerCase();
@@ -85,9 +81,9 @@ public class SymbolQuery extends BlobQuery {
String normalizedSymbolName;
if (!caseSensitive)
- normalizedSymbolName = symbol.getName().toLowerCase();
+ normalizedSymbolName = symbol.getIndexName().toLowerCase();
else
- normalizedSymbolName = symbol.getName();
+ normalizedSymbolName = symbol.getIndexName();
String normalizedExcludeTerm;
if (excludeTerm != null) {
@@ -121,12 +117,7 @@ public class SymbolQuery extends BlobQuery {
}
@Override
- public Query asLuceneQuery() throws TooGeneralQueryException {
- BooleanQuery query = new BooleanQuery(true);
-
- if (directory != null)
- applyDirectory(query, directory);
-
+ protected void applyConstraints(BooleanQuery query) {
if (fileNames != null) {
BooleanQuery subQuery = new BooleanQuery(true);
for (String pattern: Splitter.on(",").omitEmptyStrings().trimResults().split(fileNames.toLowerCase()))
@@ -152,8 +143,6 @@ public class SymbolQuery extends BlobQuery {
fieldName = BLOB_SECONDARY_SYMBOLS.name();
query.add(new WildcardQuery(new Term(fieldName, term.toLowerCase())), Occur.MUST);
-
- return query;
}
}
diff --git a/server.search/src/main/java/com/gitplex/server/search/query/TextQuery.java b/server.search/src/main/java/com/gitplex/server/search/query/TextQuery.java
index 520edb7078..eaed55283b 100644
--- a/server.search/src/main/java/com/gitplex/server/search/query/TextQuery.java
+++ b/server.search/src/main/java/com/gitplex/server/search/query/TextQuery.java
@@ -15,19 +15,18 @@ import org.apache.commons.lang3.CharUtils;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
import org.apache.lucene.search.WildcardQuery;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.treewalk.TreeWalk;
-import com.google.common.base.Splitter;
-import com.gitplex.commons.lang.extractors.TokenPosition;
import com.gitplex.commons.util.ContentDetector;
-import com.gitplex.commons.util.Range;
import com.gitplex.server.search.IndexConstants;
import com.gitplex.server.search.hit.QueryHit;
import com.gitplex.server.search.hit.TextHit;
import com.gitplex.server.search.query.regex.RegexLiterals;
+import com.gitplex.symbolextractor.Range;
+import com.gitplex.symbolextractor.TokenPosition;
+import com.google.common.base.Splitter;
public class TextQuery extends BlobQuery {
@@ -40,8 +39,6 @@ public class TextQuery extends BlobQuery {
private final boolean caseSensitive;
private final boolean wholeWord;
-
- private final String directory;
private final String fileNames;
@@ -49,13 +46,12 @@ public class TextQuery extends BlobQuery {
public TextQuery(String term, boolean regex, boolean caseSensitive, boolean wordMatch,
@Nullable String directory, @Nullable String fileNames, int count) {
- super(count);
+ super(directory, count);
this.term = term;
this.regex = regex;
this.caseSensitive = caseSensitive;
this.wholeWord = wordMatch;
- this.directory = directory;
this.fileNames = fileNames;
}
@@ -98,7 +94,8 @@ public class TextQuery extends BlobQuery {
Matcher matcher = pattern.matcher(line);
while (matcher.find()) {
Range range = new Range(matcher.start(), matcher.end());
- hits.add(new TextHit(blobPath, line, new TokenPosition(lineNo, range)));
+ TokenPosition position = new TokenPosition(lineNo, range.getFrom(), lineNo, range.getTo());
+ hits.add(new TextHit(blobPath, line, position));
if (hits.size() >= getCount())
break;
}
@@ -141,13 +138,15 @@ public class TextQuery extends BlobQuery {
if (!isWordChar(beforeChar) && !isWordChar(afterChar)) {
Range range = new Range(start, end);
- hits.add(new TextHit(blobPath, line, new TokenPosition(lineNo, range)));
+ TokenPosition position = new TokenPosition(lineNo, range.getFrom(), lineNo, range.getTo());
+ hits.add(new TextHit(blobPath, line, position));
if (hits.size() >= getCount())
break;
}
} else {
Range range = new Range(start, end);
- hits.add(new TextHit(blobPath, line, new TokenPosition(lineNo, range)));
+ TokenPosition position = new TokenPosition(lineNo, range.getFrom(), lineNo, range.getTo());
+ hits.add(new TextHit(blobPath, line, position));
if (hits.size() >= getCount())
break;
}
@@ -171,12 +170,7 @@ public class TextQuery extends BlobQuery {
}
@Override
- public Query asLuceneQuery() throws TooGeneralQueryException {
- BooleanQuery query = new BooleanQuery(true);
-
- if (directory != null)
- applyDirectory(query, directory);
-
+ protected void applyConstraints(BooleanQuery query) {
if (fileNames != null) {
BooleanQuery subQuery = new BooleanQuery(true);
for (String pattern: Splitter.on(",").omitEmptyStrings().trimResults().split(fileNames.toLowerCase()))
@@ -191,8 +185,6 @@ public class TextQuery extends BlobQuery {
query.add(new NGramLuceneQuery(BLOB_TEXT.name(), term, NGRAM_SIZE), Occur.MUST);
else
throw new TooGeneralQueryException();
-
- return query;
}
}
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/comment/comparecontext/CompareContextPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/comment/comparecontext/CompareContextPanel.java
index b92f6daf9e..0cb6c162b3 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/comment/comparecontext/CompareContextPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/comment/comparecontext/CompareContextPanel.java
@@ -22,7 +22,7 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitplex.commons.git.GitUtils;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.server.core.entity.CodeComment;
import com.gitplex.server.core.entity.Depot;
import com.gitplex.server.core.entity.PullRequest;
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
index 77be7b7132..ed1da3cf64 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
@@ -27,9 +27,16 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.request.IRequestParameters;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.request.resource.ResourceReference;
import org.eclipse.jgit.lib.ObjectId;
+import com.gitplex.commons.util.StringUtils;
+import com.gitplex.commons.wicket.ajaxlistener.ConfirmLeaveListener;
+import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
+import com.gitplex.commons.wicket.behavior.RunTaskBehavior;
+import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
+import com.gitplex.commons.wicket.component.floating.AlignPlacement;
+import com.gitplex.commons.wicket.component.floating.ComponentTarget;
+import com.gitplex.commons.wicket.component.floating.FloatingPanel;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.Depot;
import com.gitplex.server.core.entity.support.TextRange;
@@ -41,14 +48,6 @@ import com.gitplex.server.search.query.SymbolQuery;
import com.gitplex.server.search.query.TooGeneralQueryException;
import com.gitplex.server.web.component.depotfile.blobsearch.result.SearchResultPanel;
import com.gitplex.server.web.page.depot.file.DepotFilePage;
-import com.gitplex.commons.util.StringUtils;
-import com.gitplex.commons.wicket.ajaxlistener.ConfirmLeaveListener;
-import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
-import com.gitplex.commons.wicket.behavior.RunTaskBehavior;
-import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
-import com.gitplex.commons.wicket.component.floating.AlignPlacement;
-import com.gitplex.commons.wicket.component.floating.ComponentTarget;
-import com.gitplex.commons.wicket.component.floating.FloatingPanel;
@SuppressWarnings("serial")
public abstract class InstantSearchPanel extends Panel {
@@ -242,14 +241,7 @@ public abstract class InstantSearchPanel extends Panel {
}
};
- link.add(new Image("icon", hit.getIcon()) {
-
- @Override
- protected boolean shouldAddAntiCacheParameter() {
- return false;
- }
-
- });
+ link.add(hit.renderIcon("icon"));
link.add(hit.render("label"));
link.add(new Label("scope", hit.getScope()).setVisible(hit.getScope()!=null));
item.add(link);
@@ -378,12 +370,12 @@ public abstract class InstantSearchPanel extends Panel {
}
@Override
- public ResourceReference getIcon() {
+ protected int score() {
throw new UnsupportedOperationException();
}
@Override
- protected int score() {
+ public Image renderIcon(String componentId) {
throw new UnsupportedOperationException();
}
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/result/MatchedBlob.java b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/result/MatchedBlob.java
index 5810358f45..13ec097818 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/result/MatchedBlob.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/result/MatchedBlob.java
@@ -3,8 +3,8 @@ package com.gitplex.server.web.component.depotfile.blobsearch.result;
import java.io.Serializable;
import java.util.List;
-import com.gitplex.commons.util.Range;
import com.gitplex.server.search.hit.QueryHit;
+import com.gitplex.symbolextractor.Range;
public class MatchedBlob implements Serializable {
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/result/SearchResultPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/result/SearchResultPanel.java
index 7869b6da7c..935b989e70 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/result/SearchResultPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobsearch/result/SearchResultPanel.java
@@ -17,7 +17,6 @@ import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
@@ -26,15 +25,16 @@ import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.eclipse.jgit.lib.FileMode;
+import com.gitplex.commons.git.BlobIdent;
+import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
import com.gitplex.server.core.entity.support.TextRange;
import com.gitplex.server.search.hit.FileHit;
import com.gitplex.server.search.hit.QueryHit;
import com.gitplex.server.search.hit.TextHit;
import com.gitplex.server.web.component.depotfile.blobview.BlobViewContext;
import com.gitplex.server.web.page.depot.file.DepotFilePage;
-import com.gitplex.commons.git.BlobIdent;
-import com.gitplex.commons.wicket.component.HighlightableLabel;
-import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
+import com.gitplex.symbolextractor.Range;
+import com.gitplex.symbolextractor.util.HighlightableLabel;
@SuppressWarnings("serial")
public abstract class SearchResultPanel extends Panel {
@@ -86,14 +86,14 @@ public abstract class SearchResultPanel extends Panel {
FileHit fileHit = (FileHit) hit;
if (fileHit.getMatchRange() != null) {
int index = blob.getBlobPath().lastIndexOf('/');
- blob.setMatchRange(fileHit.getMatchRange().moveBy(index+1));
+ blob.setMatchRange(new Range(fileHit.getMatchRange().getFrom()+index+1, fileHit.getMatchRange().getTo()+index+1));
}
}
}
blobs = new ArrayList<>(hitsByBlob.values());
for (MatchedBlob blob: blobs) {
- blob.getHits().sort((hit1, hit2) -> hit1.getTokenPos().getLine() - hit2.getTokenPos().getLine());
+ blob.getHits().sort((hit1, hit2) -> hit1.getTokenPos().getFromLine() - hit2.getTokenPos().getFromLine());
}
}
@@ -447,15 +447,8 @@ public abstract class SearchResultPanel extends Panel {
protected void onInitialize() {
super.onInitialize();
- add(new Image("icon", hit.getIcon()) {
-
- @Override
- protected boolean shouldAddAntiCacheParameter() {
- return false;
- }
-
- });
- add(new Label("lineNo", String.valueOf(hit.getTokenPos().getLine()+1) + ":"));
+ add(hit.renderIcon("icon"));
+ add(new Label("lineNo", String.valueOf(hit.getTokenPos().getFromLine()+1) + ":"));
add(hit.render("label"));
add(new Label("scope", hit.getScope())
.setVisible(!(hit instanceof TextHit) && hit.getScope()!=null));
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/BlobViewContext.java b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/BlobViewContext.java
index 7aee6223e3..89b6a54f70 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/BlobViewContext.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/BlobViewContext.java
@@ -12,8 +12,8 @@ import com.gitplex.server.core.entity.CodeComment;
import com.gitplex.server.core.entity.Depot;
import com.gitplex.server.core.entity.support.TextRange;
import com.gitplex.server.search.hit.QueryHit;
+import com.gitplex.symbolextractor.TokenPosition;
import com.gitplex.commons.git.BlobIdent;
-import com.gitplex.commons.lang.extractors.TokenPosition;
public interface BlobViewContext extends Serializable {
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/source/SourceViewPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/source/SourceViewPanel.java
index d947fbc5f2..9ae12ce3aa 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/source/SourceViewPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/source/SourceViewPanel.java
@@ -29,7 +29,6 @@ import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
@@ -49,6 +48,16 @@ import org.unbescape.javascript.JavaScriptEscape;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.gitplex.commons.git.Blame;
+import com.gitplex.commons.git.Blob;
+import com.gitplex.commons.git.BlobIdent;
+import com.gitplex.commons.git.GitUtils;
+import com.gitplex.commons.git.command.BlameCommand;
+import com.gitplex.commons.wicket.ajaxlistener.ConfirmLeaveListener;
+import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
+import com.gitplex.commons.wicket.component.DropdownLink;
+import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
+import com.gitplex.commons.wicket.websocket.WebSocketRenderBehavior;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.CodeComment;
import com.gitplex.server.core.entity.Depot;
@@ -65,30 +74,20 @@ import com.gitplex.server.web.component.comment.CommentInput;
import com.gitplex.server.web.component.comment.DepotAttachmentSupport;
import com.gitplex.server.web.component.comment.comparecontext.CompareContextPanel;
import com.gitplex.server.web.component.depotfile.blobview.BlobViewContext;
-import com.gitplex.server.web.component.depotfile.blobview.BlobViewPanel;
import com.gitplex.server.web.component.depotfile.blobview.BlobViewContext.Mode;
+import com.gitplex.server.web.component.depotfile.blobview.BlobViewPanel;
import com.gitplex.server.web.component.sourceformat.OptionChangeCallback;
import com.gitplex.server.web.component.sourceformat.SourceFormatPanel;
import com.gitplex.server.web.component.symboltooltip.SymbolTooltipPanel;
import com.gitplex.server.web.page.depot.commit.CommitDetailPage;
import com.gitplex.server.web.page.depot.file.DepotFilePage;
import com.gitplex.server.web.util.DateUtils;
+import com.gitplex.symbolextractor.ExtractException;
+import com.gitplex.symbolextractor.Range;
+import com.gitplex.symbolextractor.Symbol;
+import com.gitplex.symbolextractor.SymbolExtractor;
+import com.gitplex.symbolextractor.SymbolExtractorRegistry;
import com.google.common.base.Preconditions;
-import com.gitplex.commons.git.Blame;
-import com.gitplex.commons.git.Blob;
-import com.gitplex.commons.git.BlobIdent;
-import com.gitplex.commons.git.GitUtils;
-import com.gitplex.commons.git.command.BlameCommand;
-import com.gitplex.commons.lang.extractors.ExtractException;
-import com.gitplex.commons.lang.extractors.Extractor;
-import com.gitplex.commons.lang.extractors.Extractors;
-import com.gitplex.commons.lang.extractors.Symbol;
-import com.gitplex.commons.util.Range;
-import com.gitplex.commons.wicket.ajaxlistener.ConfirmLeaveListener;
-import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
-import com.gitplex.commons.wicket.component.DropdownLink;
-import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
-import com.gitplex.commons.wicket.websocket.WebSocketRenderBehavior;
import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
@@ -138,7 +137,7 @@ public class SourceViewPanel extends BlobViewPanel {
Blob blob = context.getDepot().getBlob(context.getBlobIdent());
Preconditions.checkArgument(blob.getText() != null);
- Extractor extractor = GitPlex.getInstance(Extractors.class).getExtractor(context.getBlobIdent().path);
+ SymbolExtractor extractor = SymbolExtractorRegistry.getExtractor(context.getBlobIdent().path);
if (extractor != null) {
try {
symbols.addAll(extractor.extract(blob.getText().getContent()));
@@ -682,20 +681,20 @@ public class SourceViewPanel extends BlobViewPanel {
Fragment fragment = new Fragment(id, "outlineNodeFrag", SourceViewPanel.this);
Symbol symbol = nodeModel.getObject();
- fragment.add(new Image("icon", symbol.getIcon()));
+ fragment.add(symbol.renderIcon("icon"));
AjaxLink<Void> link = new PreventDefaultAjaxLink<Void>("link") {
@Override
public void onClick(AjaxRequestTarget target) {
- context.onSelect(target, context.getBlobIdent(), symbol.getPos());
+ context.onSelect(target, context.getBlobIdent(), symbol.getPosition());
}
};
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent = context.getBlobIdent();
state.commentId = CodeComment.idOf(context.getOpenComment());
- state.mark = TextRange.of(symbol.getPos());
+ state.mark = TextRange.of(symbol.getPosition());
PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
link.add(AttributeAppender.replace("href", urlFor(DepotFilePage.class, params).toString()));
link.add(symbol.render("label", null));
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/source/source-view.js b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/source/source-view.js
index 37ba22a57e..5a35f68870 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/source/source-view.js
+++ b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/blobview/source/source-view.js
@@ -147,7 +147,8 @@ gitplex.server.sourceview = {
$code.mouseover(function(e) {
var node = e.target || e.srcElement, $node = $(node);
if ($node.hasClass("cm-property") || $node.hasClass("cm-variable") || $node.hasClass("cm-variable-2")
- || $node.hasClass("cm-variable-3") || $node.hasClass("cm-def") || $node.hasClass("cm-meta")) {
+ || $node.hasClass("cm-variable-3") || $node.hasClass("cm-def") || $node.hasClass("cm-meta")
+ || $node.hasClass("cm-string")) {
document.getElementById(symbolTooltipId).onMouseOverSymbol(revision, node);
}
});
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/editsave/EditSavePanel.java b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/editsave/EditSavePanel.java
index 3c0df4bdc2..33975339f4 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/editsave/EditSavePanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/editsave/EditSavePanel.java
@@ -40,7 +40,7 @@ import com.gitplex.commons.git.PathAndContent;
import com.gitplex.commons.git.exception.GitObjectAlreadyExistsException;
import com.gitplex.commons.git.exception.NotGitTreeException;
import com.gitplex.commons.git.exception.ObsoleteCommitException;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.Account;
import com.gitplex.server.core.entity.Depot;
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/fileedit/FileEditPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/fileedit/FileEditPanel.java
index 6c512d513c..349779b268 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/depotfile/fileedit/FileEditPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/depotfile/fileedit/FileEditPanel.java
@@ -28,7 +28,7 @@ import com.gitplex.commons.git.BlobChange;
import com.gitplex.commons.git.BlobIdent;
import com.gitplex.commons.git.GitUtils;
import com.gitplex.commons.git.PathAndContent;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.commons.wicket.ajaxlistener.ConfirmLeaveListener;
import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
import com.gitplex.commons.wicket.component.ViewStateAwareAjaxLink;
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/BlobDiffPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/BlobDiffPanel.java
index 1d62a2a93c..d68c5cf740 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/BlobDiffPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/BlobDiffPanel.java
@@ -16,7 +16,7 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import com.gitplex.commons.git.Blob;
import com.gitplex.commons.git.BlobChange;
-import com.gitplex.commons.lang.diff.DiffUtils;
+import com.gitplex.commons.util.diff.DiffUtils;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.CodeComment;
import com.gitplex.server.core.entity.Depot;
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/text/TextDiffPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/text/TextDiffPanel.java
index 58bcd82cbe..00849a461d 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/text/TextDiffPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/text/TextDiffPanel.java
@@ -60,19 +60,19 @@ import com.gitplex.server.web.page.depot.file.DepotFilePage;
import com.gitplex.server.web.page.depot.file.RequestCompareInfo;
import com.gitplex.server.web.page.depot.pullrequest.requestdetail.changes.RequestChangesPage;
import com.gitplex.server.web.util.DateUtils;
+import com.gitplex.symbolextractor.Range;
import com.google.common.base.Preconditions;
import com.gitplex.commons.git.Blame;
import com.gitplex.commons.git.BlobChange;
import com.gitplex.commons.git.BriefCommit;
import com.gitplex.commons.git.GitUtils;
import com.gitplex.commons.git.command.BlameCommand;
-import com.gitplex.commons.lang.diff.DiffBlock;
-import com.gitplex.commons.lang.diff.DiffMatchPatch.Operation;
-import com.gitplex.commons.lang.diff.DiffUtils;
-import com.gitplex.commons.lang.diff.LineDiff;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.RangeUtils;
import com.gitplex.commons.util.StringUtils;
+import com.gitplex.commons.util.diff.DiffBlock;
+import com.gitplex.commons.util.diff.DiffUtils;
+import com.gitplex.commons.util.diff.LineDiff;
+import com.gitplex.commons.util.diff.DiffMatchPatch.Operation;
import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
import com.gitplex.jsyntax.Token;
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/text/text-diff.js b/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/text/text-diff.js
index 9244f6fe57..f74fcbdab0 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/text/text-diff.js
+++ b/server.web/src/main/java/com/gitplex/server/web/component/diff/blob/text/text-diff.js
@@ -1,5 +1,5 @@
gitplex.server.textdiff = {
- symbolClasses: ".cm-property, .cm-variable, .cm-variable-2, .cm-variable-3, .cm-def, .cm-meta",
+ symbolClasses: ".cm-property, .cm-variable, .cm-variable-2, .cm-variable-3, .cm-def, .cm-meta, .cm-string",
init: function(containerId, symbolTooltipId, oldRev, newRev, scroll, callback, blameMessageCallback,
markSupport, mark, openComment, oldComments, newComments, dirtyContainerId, doclink) {
var $container = $("#" + containerId);
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java
index 27cd14e935..650b56e112 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java
@@ -61,10 +61,9 @@ import com.gitplex.commons.antlr.codeassist.InputSuggestion;
import com.gitplex.commons.git.Blob;
import com.gitplex.commons.git.BlobChange;
import com.gitplex.commons.git.BlobIdent;
-import com.gitplex.commons.lang.diff.DiffUtils;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.StringUtils;
+import com.gitplex.commons.util.diff.DiffUtils;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.commons.util.match.WildcardUtils;
import com.gitplex.commons.wicket.ajaxlistener.ConfirmLeaveListener;
import com.gitplex.commons.wicket.behavior.inputassist.InputAssistBehavior;
@@ -88,6 +87,7 @@ import com.gitplex.server.web.component.diff.blob.BlobDiffPanel;
import com.gitplex.server.web.component.diff.blob.SourceAware;
import com.gitplex.server.web.component.diff.diffstat.DiffStatBar;
import com.gitplex.server.web.util.SuggestionUtils;
+import com.gitplex.symbolextractor.Range;
import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/refmatch/RefMatchBehavior.java b/server.web/src/main/java/com/gitplex/server/web/component/refmatch/RefMatchBehavior.java
index 17f5250090..492cf3093c 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/refmatch/RefMatchBehavior.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/refmatch/RefMatchBehavior.java
@@ -14,9 +14,9 @@ import com.gitplex.commons.antlr.codeassist.InputSuggestion;
import com.gitplex.commons.antlr.codeassist.ParentedElement;
import com.gitplex.commons.antlr.grammar.ElementSpec;
import com.gitplex.commons.antlr.grammar.LexerRuleRefElementSpec;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.wicket.behavior.inputassist.ANTLRAssistBehavior;
import com.gitplex.server.core.util.includeexclude.IncludeExcludeParser;
+import com.gitplex.symbolextractor.Range;
import com.gitplex.server.core.entity.Depot;
@SuppressWarnings("serial")
diff --git a/server.web/src/main/java/com/gitplex/server/web/component/symboltooltip/SymbolTooltipPanel.java b/server.web/src/main/java/com/gitplex/server/web/component/symboltooltip/SymbolTooltipPanel.java
index dd3716bad2..9e2b8dbfea 100644
--- a/server.web/src/main/java/com/gitplex/server/web/component/symboltooltip/SymbolTooltipPanel.java
+++ b/server.web/src/main/java/com/gitplex/server/web/component/symboltooltip/SymbolTooltipPanel.java
@@ -5,6 +5,7 @@ import static org.apache.wicket.ajax.attributes.CallbackParameter.explicit;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
@@ -15,7 +16,6 @@ import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
@@ -28,19 +28,20 @@ import org.apache.wicket.request.resource.PackageResourceReference;
import org.apache.wicket.request.resource.ResourceReference;
import org.eclipse.jgit.lib.ObjectId;
+import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
+import com.gitplex.commons.wicket.behavior.RunTaskBehavior;
+import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.Depot;
import com.gitplex.server.core.entity.support.TextRange;
import com.gitplex.server.search.SearchManager;
import com.gitplex.server.search.hit.QueryHit;
import com.gitplex.server.search.query.BlobQuery;
+import com.gitplex.server.search.query.PathQuery;
import com.gitplex.server.search.query.SymbolQuery;
import com.gitplex.server.search.query.TextQuery;
import com.gitplex.server.web.component.depotfile.blobsearch.result.SearchResultPanel;
import com.gitplex.server.web.page.depot.file.DepotFilePage;
-import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
-import com.gitplex.commons.wicket.behavior.RunTaskBehavior;
-import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
@SuppressWarnings("serial")
public abstract class SymbolTooltipPanel extends Panel {
@@ -81,14 +82,7 @@ public abstract class SymbolTooltipPanel extends Panel {
@Override
protected void populateItem(ListItem<QueryHit> item) {
final QueryHit hit = item.getModelObject();
- item.add(new Image("icon", hit.getIcon()) {
-
- @Override
- protected boolean shouldAddAntiCacheParameter() {
- return false;
- }
-
- });
+ item.add(hit.renderIcon("icon"));
AjaxLink<Void> link = new PreventDefaultAjaxLink<Void>("link") {
@Override
@@ -183,10 +177,12 @@ public abstract class SymbolTooltipPanel extends Panel {
IRequestParameters params = RequestCycle.get().getRequest().getPostParameters();
revision = params.getParameterValue("revision").toString();
symbol = params.getParameterValue("symbol").toString();
- if (symbol.startsWith("@"))
- symbol = symbol.substring(1);
+ boolean isString = symbol.indexOf('\'') != -1 || symbol.indexOf('"') != -1;
+ String charsToStrip = "@'\"./\\";
+ symbol = StringUtils.stripEnd(StringUtils.stripStart(symbol, charsToStrip), charsToStrip);
+ symbol = StringUtils.replace(symbol, "\\", "/");
try {
- SymbolQuery query = new SymbolQuery(symbol, null, true, true, null, null, QUERY_ENTRIES);
+ BlobQuery query = new SymbolQuery(symbol, null, true, true, null, null, QUERY_ENTRIES);
SearchManager searchManager = GitPlex.getInstance(SearchManager.class);
ObjectId commit = depotModel.getObject().getRevCommit(revision);
symbolHits = searchManager.search(depotModel.getObject(), commit, query);
@@ -194,6 +190,10 @@ public abstract class SymbolTooltipPanel extends Panel {
query = new SymbolQuery(symbol, null, false, true, null, null, QUERY_ENTRIES - symbolHits.size());
symbolHits.addAll(searchManager.search(depotModel.getObject(), commit, query));
}
+ if (isString && symbolHits.size() < QUERY_ENTRIES) {
+ query = new PathQuery(null, symbol, QUERY_ENTRIES - symbolHits.size());
+ symbolHits.addAll(searchManager.search(depotModel.getObject(), commit, query));
+ }
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
diff --git a/server.web/src/main/java/com/gitplex/server/web/editable/filechoice/FileChoiceEditor.java b/server.web/src/main/java/com/gitplex/server/web/editable/filechoice/FileChoiceEditor.java
index 42c9d70765..816af65758 100644
--- a/server.web/src/main/java/com/gitplex/server/web/editable/filechoice/FileChoiceEditor.java
+++ b/server.web/src/main/java/com/gitplex/server/web/editable/filechoice/FileChoiceEditor.java
@@ -13,7 +13,6 @@ import com.google.common.collect.Lists;
import com.gitplex.commons.antlr.codeassist.InputCompletion;
import com.gitplex.commons.antlr.codeassist.InputStatus;
import com.gitplex.commons.antlr.codeassist.InputSuggestion;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.ReflectionUtils;
import com.gitplex.commons.wicket.behavior.inputassist.InputAssistBehavior;
import com.gitplex.commons.wicket.editable.ErrorContext;
@@ -22,6 +21,7 @@ import com.gitplex.commons.wicket.editable.PropertyDescriptor;
import com.gitplex.commons.wicket.editable.PropertyEditor;
import com.gitplex.server.core.annotation.FileChoice;
import com.gitplex.server.web.util.SuggestionUtils;
+import com.gitplex.symbolextractor.Range;
@SuppressWarnings("serial")
public class FileChoiceEditor extends PropertyEditor<String> {
diff --git a/server.web/src/main/java/com/gitplex/server/web/page/depot/commit/CommitDetailPage.java b/server.web/src/main/java/com/gitplex/server/web/page/depot/commit/CommitDetailPage.java
index dda27e5550..d28db6a6f1 100644
--- a/server.web/src/main/java/com/gitplex/server/web/page/depot/commit/CommitDetailPage.java
+++ b/server.web/src/main/java/com/gitplex/server/web/page/depot/commit/CommitDetailPage.java
@@ -38,7 +38,7 @@ import com.google.common.base.Preconditions;
import com.gitplex.commons.git.BlobIdent;
import com.gitplex.commons.git.GitUtils;
import com.gitplex.commons.git.RefInfo;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.commons.wicket.behavior.clipboard.CopyClipboardBehavior;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.CodeComment;
diff --git a/server.web/src/main/java/com/gitplex/server/web/page/depot/commit/QueryAssistBehavior.java b/server.web/src/main/java/com/gitplex/server/web/page/depot/commit/QueryAssistBehavior.java
index ca0c968257..2b58948a45 100644
--- a/server.web/src/main/java/com/gitplex/server/web/page/depot/commit/QueryAssistBehavior.java
+++ b/server.web/src/main/java/com/gitplex/server/web/page/depot/commit/QueryAssistBehavior.java
@@ -14,7 +14,6 @@ import com.gitplex.commons.antlr.codeassist.ParentedElement;
import com.gitplex.commons.antlr.grammar.ElementSpec;
import com.gitplex.commons.antlr.grammar.LexerRuleRefElementSpec;
import com.gitplex.commons.git.NameAndEmail;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.StringUtils;
import com.gitplex.commons.util.match.PatternApplied;
import com.gitplex.commons.util.match.WildcardUtils;
@@ -24,6 +23,7 @@ import com.gitplex.server.core.entity.Depot;
import com.gitplex.server.core.manager.CommitInfoManager;
import com.gitplex.server.web.Constants;
import com.gitplex.server.web.util.SuggestionUtils;
+import com.gitplex.symbolextractor.Range;
import com.gitplex.server.web.page.depot.commit.CommitQueryParser;
@SuppressWarnings("serial")
diff --git a/server.web/src/main/java/com/gitplex/server/web/page/depot/compare/RevisionComparePage.java b/server.web/src/main/java/com/gitplex/server/web/page/depot/compare/RevisionComparePage.java
index f958455bba..74f751c4a9 100644
--- a/server.web/src/main/java/com/gitplex/server/web/page/depot/compare/RevisionComparePage.java
+++ b/server.web/src/main/java/com/gitplex/server/web/page/depot/compare/RevisionComparePage.java
@@ -32,7 +32,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import com.gitplex.commons.git.GitUtils;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.commons.wicket.behavior.TooltipBehavior;
import com.gitplex.commons.wicket.component.tabbable.AjaxActionTab;
import com.gitplex.commons.wicket.component.tabbable.Tab;
diff --git a/server.web/src/main/java/com/gitplex/server/web/page/depot/file/DepotFilePage.java b/server.web/src/main/java/com/gitplex/server/web/page/depot/file/DepotFilePage.java
index 19490b32b1..ba2f1713d3 100644
--- a/server.web/src/main/java/com/gitplex/server/web/page/depot/file/DepotFilePage.java
+++ b/server.web/src/main/java/com/gitplex/server/web/page/depot/file/DepotFilePage.java
@@ -24,7 +24,6 @@ import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;
@@ -38,6 +37,17 @@ import org.eclipse.jgit.revwalk.RevTree;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.treewalk.TreeWalk;
+import com.gitplex.commons.git.Blob;
+import com.gitplex.commons.git.BlobIdent;
+import com.gitplex.commons.git.GitUtils;
+import com.gitplex.commons.git.exception.GitObjectNotFoundException;
+import com.gitplex.commons.hibernate.UnitOfWork;
+import com.gitplex.commons.loader.ListenerRegistry;
+import com.gitplex.commons.util.diff.DiffUtils;
+import com.gitplex.commons.wicket.component.modal.ModalLink;
+import com.gitplex.commons.wicket.websocket.WebSocketManager;
+import com.gitplex.commons.wicket.websocket.WebSocketRegion;
+import com.gitplex.commons.wicket.websocket.WebSocketRenderBehavior;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.CodeComment;
import com.gitplex.server.core.entity.Depot;
@@ -78,19 +88,9 @@ import com.gitplex.server.web.page.depot.pullrequest.requestdetail.changes.Reque
import com.gitplex.server.web.websocket.CodeCommentChangedRegion;
import com.gitplex.server.web.websocket.CommitIndexedRegion;
import com.gitplex.server.web.websocket.PullRequestChangedRegion;
+import com.gitplex.symbolextractor.TokenPosition;
+import com.gitplex.symbolextractor.util.NoAntiCacheImage;
import com.google.common.base.Objects;
-import com.gitplex.commons.git.Blob;
-import com.gitplex.commons.git.BlobIdent;
-import com.gitplex.commons.git.GitUtils;
-import com.gitplex.commons.git.exception.GitObjectNotFoundException;
-import com.gitplex.commons.hibernate.UnitOfWork;
-import com.gitplex.commons.lang.diff.DiffUtils;
-import com.gitplex.commons.lang.extractors.TokenPosition;
-import com.gitplex.commons.loader.ListenerRegistry;
-import com.gitplex.commons.wicket.component.modal.ModalLink;
-import com.gitplex.commons.wicket.websocket.WebSocketManager;
-import com.gitplex.commons.wicket.websocket.WebSocketRegion;
-import com.gitplex.commons.wicket.websocket.WebSocketRenderBehavior;
@SuppressWarnings("serial")
public class DepotFilePage extends DepotPage implements BlobViewContext {
@@ -352,7 +352,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
@Override
protected void onInitialize() {
super.onInitialize();
- add(new Image("icon", new PackageResourceReference(DepotFilePage.class, "indexing.gif")));
+ add(new NoAntiCacheImage("icon", new PackageResourceReference(DepotFilePage.class, "indexing.gif")));
setOutputMarkupPlaceholderTag(true);
}
diff --git a/server.web/src/main/java/com/gitplex/server/web/page/depot/file/RequestCompareInfo.java b/server.web/src/main/java/com/gitplex/server/web/page/depot/file/RequestCompareInfo.java
index 58b6275d75..f19a2ec5f7 100644
--- a/server.web/src/main/java/com/gitplex/server/web/page/depot/file/RequestCompareInfo.java
+++ b/server.web/src/main/java/com/gitplex/server/web/page/depot/file/RequestCompareInfo.java
@@ -12,7 +12,7 @@ import javax.annotation.Nullable;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.server.core.entity.support.CommentPos;
import com.gitplex.server.web.page.depot.pullrequest.requestdetail.changes.RequestChangesPage;
diff --git a/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/newrequest/NewRequestPage.java b/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/newrequest/NewRequestPage.java
index fd1eb40987..d62c13e796 100644
--- a/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/newrequest/NewRequestPage.java
+++ b/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/newrequest/NewRequestPage.java
@@ -38,7 +38,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
import com.google.common.base.Preconditions;
import com.gitplex.commons.git.GitUtils;
import com.gitplex.commons.hibernate.dao.Dao;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.commons.wicket.behavior.markdown.AttachmentSupport;
import com.gitplex.commons.wicket.component.tabbable.AjaxActionTab;
import com.gitplex.commons.wicket.component.tabbable.Tab;
diff --git a/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java b/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
index 58230d1c99..b360110142 100644
--- a/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
+++ b/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
@@ -34,7 +34,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
import com.google.common.base.Preconditions;
import com.gitplex.commons.git.GitUtils;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.commons.wicket.behavior.AbstractPostAjaxBehavior;
import com.gitplex.commons.wicket.component.DropdownLink;
import com.gitplex.commons.wicket.websocket.WebSocketManager;
diff --git a/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/requestdetail/integrationpreview/IntegrationPreviewPage.java b/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/requestdetail/integrationpreview/IntegrationPreviewPage.java
index 0f8b03a29c..efd198d492 100644
--- a/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/requestdetail/integrationpreview/IntegrationPreviewPage.java
+++ b/server.web/src/main/java/com/gitplex/server/web/page/depot/pullrequest/requestdetail/integrationpreview/IntegrationPreviewPage.java
@@ -16,7 +16,7 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
-import com.gitplex.commons.lang.diff.WhitespaceOption;
+import com.gitplex.commons.util.diff.WhitespaceOption;
import com.gitplex.server.core.entity.Depot;
import com.gitplex.server.core.entity.PullRequest;
import com.gitplex.server.core.entity.support.IntegrationPreview;
diff --git a/server.web/src/main/java/com/gitplex/server/web/util/SuggestionUtils.java b/server.web/src/main/java/com/gitplex/server/web/util/SuggestionUtils.java
index f15a5f95b3..bffe301783 100644
--- a/server.web/src/main/java/com/gitplex/server/web/util/SuggestionUtils.java
+++ b/server.web/src/main/java/com/gitplex/server/web/util/SuggestionUtils.java
@@ -15,12 +15,12 @@ import com.gitplex.commons.antlr.codeassist.InputSuggestion;
import com.gitplex.commons.git.GitUtils;
import com.gitplex.commons.git.RefInfo;
import com.gitplex.commons.hibernate.dao.Dao;
-import com.gitplex.commons.util.Range;
import com.gitplex.commons.util.match.PatternApplied;
import com.gitplex.commons.util.match.WildcardUtils;
import com.gitplex.server.core.GitPlex;
import com.gitplex.server.core.entity.Depot;
import com.gitplex.server.core.manager.CommitInfoManager;
+import com.gitplex.symbolextractor.Range;
public class SuggestionUtils {