Skip to content

Commit

Permalink
Eclipse 4.25 (RC1) JDT Patch for Groovy-Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Aug 29, 2022
1 parent 04c62e5 commit 08d9da0
Show file tree
Hide file tree
Showing 34 changed files with 551 additions and 158 deletions.
2 changes: 1 addition & 1 deletion groovy-eclipse.setup
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
<repository
url="https://download.eclipse.org/eclipse/updates/4.25"/>
<repository
url="https://download.eclipse.org/eclipse/updates/4.25-I-builds/I20220817-1800"/>
url="https://download.eclipse.org/eclipse/updates/4.25-I-builds/I20220824-1800"/>
</repositoryList>
<repositoryList
name="2022-06">
Expand Down
22 changes: 14 additions & 8 deletions jdt-patch/e425/org.eclipse.jdt.core/.settings/.api_filters
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/AbstractTextElement.java" type="org.eclipse.jdt.core.dom.AbstractTextElement">
<filter id="576725006">
<message_arguments>
<message_argument value="IDocElement"/>
<message_argument value="AbstractTextElement"/>
</message_arguments>
</filter>
<filter id="576778288">
<message_arguments>
<message_argument value="ASTNode"/>
<message_argument value="AbstractTextElement"/>
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/Annotation.java" type="org.eclipse.jdt.core.dom.Annotation">
<filter id="576725006">
<message_arguments>
Expand Down Expand Up @@ -200,14 +214,6 @@
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/TextElement.java" type="org.eclipse.jdt.core.dom.TextElement">
<filter id="576725006">
<message_arguments>
<message_argument value="IDocElement"/>
<message_argument value="TextElement"/>
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/Type.java" type="org.eclipse.jdt.core.dom.Type">
<filter id="576778288">
<message_arguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,15 @@ private int resolveImports(int numberOfStatements, ImportBinding[] resolvedImpor
// skip duplicates or imports of the current package
for (int j = 0; j < index; j++) {
ImportBinding resolved = resolvedImports[j];
if (resolved.onDemand == ((importReference.bits & ASTNode.OnDemand) != 0) && resolved.isStatic() == importReference.isStatic())
if (resolved.onDemand == ((importReference.bits & ASTNode.OnDemand) != 0) && resolved.isStatic() == importReference.isStatic()) {
/* GROOVY edit
if (CharOperation.equals(compoundName, resolvedImports[j].compoundName))
if (CharOperation.equals(compoundName, resolvedImports[j].compoundName)) {
*/
if (CharOperation.equals(compoundName, resolvedImports[j].compoundName) && CharOperation.equals(importReference.getSimpleName(), resolvedImports[j].getSimpleName()))
if (CharOperation.equals(compoundName, resolvedImports[j].compoundName) && CharOperation.equals(importReference.getSimpleName(), resolvedImports[j].getSimpleName())) {
// GROOVY end
continue nextImport;
}
}
}

if ((importReference.bits & ASTNode.OnDemand) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1876,14 +1876,15 @@ private void parseExternalSnippet(String content, Object snippetTag) {
previousPosition = indexPos;
tokenType = snippetScanner.getNextToken();

if (tokenType == TokenNameEOF)
if (tokenType == TokenNameEOF) {
if (!resetTextStartPos) {
pushExternalSnippetText(snippetScanner.source, textStartPosition, textEndPosition, false, snippetTag);
}
break;
}

indexPos = snippetScanner.currentPosition;
textEndPosition = indexPos;
if (tokenType == TerminalTokens.TokenNameEOF) {
break;
}
if (resetTextStartPos) {
textStartPosition = snippetScanner.getCurrentTokenStartPosition();
newLineStarted = true;
Expand All @@ -1892,7 +1893,7 @@ private void parseExternalSnippet(String content, Object snippetTag) {
switch (tokenType) {
case TerminalTokens.TokenNameWHITESPACE:
if (containsNewLine(snippetScanner.getCurrentTokenString())) {
pushSnippetText(snippetScanner.source, textStartPosition, textEndPosition, false, snippetTag);
pushExternalSnippetText(snippetScanner.source, textStartPosition, textEndPosition, false, snippetTag);
resetTextStartPos = true;
newLineStarted = false;
}
Expand Down Expand Up @@ -1928,7 +1929,7 @@ private void parseExternalSnippet(String content, Object snippetTag) {
textStartPosition = previousPosition;
}
if (textStartPosition != -1 && textStartPosition < indexPos) {
pushSnippetText(snippetScanner.source, textStartPosition,(innerTag!=null && indexOfLastComment >=0) ? textPos+indexOfLastComment+2:textPos, true, snippetTag);
pushExternalSnippetText(snippetScanner.source, textStartPosition,(innerTag!=null && indexOfLastComment >=0) ? textPos+indexOfLastComment+2:textPos, true, snippetTag);
resetTextStartPos = true;
newLineStarted = false;
if (handleNow) {
Expand Down Expand Up @@ -3055,7 +3056,7 @@ protected void pushSnippetText(char[] text, int start, int end, boolean addNewLi
protected abstract void closeJavaDocRegion(String name, Object snippetTag, int end);
protected abstract boolean areRegionsClosed();

protected void pushExternalSnippetText(String text, int start, int end) {
protected void pushExternalSnippetText(char[] text, int start, int end, boolean addNewLine, Object snippetTag) {
// do not store text by default
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ protected void closeJavaDocRegion(String name, Object snippetTag, int end){
}

@Override
protected void pushExternalSnippetText(String text, int start, int end) {
protected void pushExternalSnippetText(char[] text, int start, int end, boolean addNewLine, Object snippetTag) {
// The tag gets its description => clear the flag
this.tagWaitingForDescription = TAG_SNIPPET_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,22 @@ public JavaDocRegion newJavaDocRegion() {
return result;
}

/**
* Creates and returns a new text element node.
* Initially the new node has an empty text string.
* <p>
* Note that this node type is used only inside doc comments
* ({@link Javadoc Javadoc}).
* </p>
*
* @return a new unparented JavaDoc text element node
* @since 3.31
*/
public JavaDocTextElement newJavaDocTextElement() {
JavaDocTextElement result = new JavaDocTextElement(this);
return result;
}

/**
* Creates a new unparented labeled statement node owned by this AST.
* By default, the label and statement are both unspecified, but legal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,29 @@ public boolean match(JavaDocRegion node, Object other) {
&& safeEquals(node.isDummyRegion(), o.isDummyRegion() && safeEquals(node.isValidSnippet(), o.isValidSnippet()));
}

/**
* Returns whether the given node and the other object match.
* <p>
* The default implementation provided by this class tests whether the
* other object is a node of the same type with structurally isomorphic
* child subtrees. Subclasses may override this method as needed.
* </p>
*
* @param node the node
* @param other the other object, or <code>null</code>
* @return <code>true</code> if the subtree matches, or
* <code>false</code> if they do not match or the other object has a
* different node type or is <code>null</code>
* @since 3.31
*/
public boolean match(JavaDocTextElement node, Object other) {
if (!(other instanceof JavaDocTextElement)) {
return false;
}
JavaDocTextElement o = (JavaDocTextElement) other;
return safeEquals(node.getText(), o.getText());
}

/**
* Return whether the deprecated comment strings of the given java doc are equals.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,14 @@ public abstract class ASTNode {
*/
public static final int JAVADOC_REGION = 111;

/**
* Node type constant indicating a node of type
* <code>TextElement</code>.
* @see TextElement
* @since 3.31
*/
public static final int JAVADOC_TEXT_ELEMENT = 112;


/**
* Returns the node class for the corresponding node type.
Expand Down Expand Up @@ -1152,6 +1160,8 @@ public static Class nodeClassForType(int nodeType) {
return Javadoc.class;
case JAVADOC_REGION :
return JavaDocRegion.class;
case JAVADOC_TEXT_ELEMENT :
return JavaDocTextElement.class;
case LABELED_STATEMENT :
return LabeledStatement.class;
case LAMBDA_EXPRESSION :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,23 @@ public boolean visit(JavaDocRegion node) {
return this.visitDocTags;
}

/**
* Visits the given type-specific AST node.
* <p>
* The default implementation does nothing and return true.
* Subclasses may reimplement.
* </p>
*
* @param node the node to visit
* @return <code>true</code> if the children of this node should be
* visited, and <code>false</code> if the children of this node should
* be skipped
* @since 3.31
*/
public boolean visit(JavaDocTextElement node) {
return true;
}

/**
* Visits the given type-specific AST node.
* <p>
Expand Down Expand Up @@ -2580,6 +2597,19 @@ public void endVisit(JavaDocRegion node) {
// default implementation: do nothing
}

/**
* End of visit the given type-specific AST node.
* <p>
* The default implementation does nothing. Subclasses may reimplement.
* </p>
*
* @param node the node to visit
* @since 3.31
*/
public void endVisit(JavaDocTextElement node) {
// default implementation: do nothing
}

/**
* End of visit the given type-specific AST node.
* <p>
Expand Down
Loading

0 comments on commit 08d9da0

Please sign in to comment.