Unverified Commit 631bd69c authored by Eric Barboni's avatar Eric Barboni Committed by GitHub
Browse files

Merge pull request #2159 from apache/master

Sync master to release 12.0 beta 6
parents 16abbbfa 37fba0ac
......@@ -21,9 +21,7 @@ package org.netbeans.modules.apisupport.project.ui.wizard.action;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
......@@ -40,7 +38,6 @@ import org.netbeans.api.project.Project;
import org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles;
import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
import org.openide.WizardDescriptor;
import org.openide.awt.ActionReference;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileSystem;
import org.openide.filesystems.FileUtil;
......@@ -253,7 +250,7 @@ final class DataModel extends BasicWizardIterator.BasicDataModel {
}
if (annotations) {
List<ActionReference> refs = new ArrayList<ActionReference>();
List<ActionReferenceModel> refs = new ArrayList<>();
// create layer entry for global menu item
if (globalMenuItemEnabled) {
refs.add(createActionReference(
......@@ -624,46 +621,58 @@ final class DataModel extends BasicWizardIterator.BasicDataModel {
this.edContextSeparatorBefore = separator;
}
static ActionReference createActionReference(
static class ActionReferenceModel implements Serializable {
String parentPath;
String name;
int beforeSep;
int afterSep;
int position;
public ActionReferenceModel(String parentPath, String name, int beforeSep, int afterSep, int position) {
this.parentPath = parentPath;
this.name = name;
this.beforeSep = beforeSep;
this.afterSep = afterSep;
this.position = position;
}
public String path() {
return parentPath;
}
public int position() {
return position;
}
public String name() {
return name == null ? "" : name;
}
public int separatorBefore() {
return beforeSep;
}
public int separatorAfter() {
return afterSep;
}
@Override
public String toString() {
return "ActionReferenceModel{" + "parentPath=" + parentPath + ", name=" + name + ", beforeSep=" + beforeSep + ", afterSep=" + afterSep + ", position=" + position + '}';
}
}
static ActionReferenceModel createActionReference(
final String parentPath,
final int beforeSep,
final int afterSep,
final int position,
final String name
) {
class H implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("path")) {
return parentPath;
}
if (method.getName().equals("position")) {
return position;
}
if (method.getName().equals("separatorBefore")) {
return beforeSep;
}
if (method.getName().equals("separatorAfter")) {
return afterSep;
}
if (method.getName().equals("name")) {
return name == null ? "" : name;
}
if (method.getName().equals("equals")) {
return this == Proxy.getInvocationHandler(proxy);
}
if (method.getName().equals("hashCode")) {
return hashCode();
}
return null;
}
}
return (ActionReference) Proxy.newProxyInstance(
ActionReference.class.getClassLoader(),
new Class[] { ActionReference.class },
new H()
);
return new ActionReferenceModel(parentPath, name, beforeSep, afterSep, position);
}
void setSFS(FileSystem sfs) {
......
......@@ -20,7 +20,7 @@
package org.netbeans.modules.apisupport.project.ui.wizard.action;
import org.netbeans.junit.NbTestCase;
import org.openide.awt.ActionReference;
import org.netbeans.modules.apisupport.project.ui.wizard.action.DataModel.ActionReferenceModel;
/**
* Tests {@link DataModel}.
......@@ -34,7 +34,7 @@ public class DataModelTest extends NbTestCase {
}
public void testActionReferenceCreate() throws Exception {
ActionReference res = DataModel.createActionReference("mypath/sub", 30, 130, 100, "myname");
ActionReferenceModel res = DataModel.createActionReference("mypath/sub", 30, 130, 100, "myname");
assertEquals("mypath/sub", res.path());
assertEquals(100, res.position());
assertEquals("myname", res.name());
......
......@@ -468,6 +468,12 @@ public final class YamlLexer implements Lexer<YamlTokenId> {
case ISA_CURLY:
state = ISI_WHITESPACE;
return token(YamlTokenId.TEXT);
case ISI_MUSTACHE:
state = ISI_WHITESPACE;
return token(YamlTokenId.MUSTACHE);
case ISI_MUSTACHE_QUOTE:
state = ISI_WHITESPACE;
return token(YamlTokenId.MUSTACHE);
case ISI_PHP:
state = ISI_WHITESPACE;
return token(YamlTokenId.PHP);
......
.t.e.s.t. SimpleMustache
k: {{a
.e.o.f.
\ No newline at end of file
.t.e.s.t. SimpleMustache
TEXT "k: ", la=2, st=0
MUSTACHE_DELIMITER "{{", st=13
MUSTACHE "a", la=1, st=0
----- EOF -----
<Unnamed test>
----- EOF -----
.t.e.s.t. SimpleMustacheQuote
k: {{ '}}
.e.o.f.
\ No newline at end of file
.t.e.s.t. SimpleMustacheQuote
TEXT "k: ", la=2, st=0
MUSTACHE_DELIMITER "{{", st=13
MUSTACHE " '}}", la=1, st=0
----- EOF -----
<Unnamed test>
----- EOF -----
......@@ -65,7 +65,17 @@ public class YamlLexerTest extends YamlTestBase {
YamlTokenId.language());
}
public void testIssue246124() throws Exception {
public void testNETBEANS_4370_1() throws Exception {
LexerTestUtilities.checkTokenDump(this, "testfiles/issue_NETBEANS-4370_1.yaml.txt",
YamlTokenId.language());
}
public void testNETBEANS_4370_2() throws Exception {
LexerTestUtilities.checkTokenDump(this, "testfiles/issue_NETBEANS-4370_2.yaml.txt",
YamlTokenId.language());
}
public void testIssue246124() throws Exception {
LexerTestUtilities.checkTokenDump(this, "testfiles/issue246124.yaml",
YamlTokenId.language());
}
......
......@@ -208,7 +208,7 @@ public class ParameterNameProviderImpl {
static void capCache(LinkedHashMap<String, ?> map) {
Iterator<String> it = map.keySet().iterator();
while (map.size() > MAX_CACHE_SIZE) {
while (map.size() > MAX_CACHE_SIZE && it.hasNext()) {
it.next();
it.remove();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment