Bug 489656 [ES6] Support for ES exports on Outline view
Change-Id: I8f29f2d4e1706632f926e9857411d99bd1a6dc0a
Signed-off-by: Shane Bryzak <sbryzak@redhat.com>
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportContainer.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportContainer.java
new file mode 100644
index 0000000..cd235e7
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportContainer.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2016, Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.core;
+
+
+/**
+ * Represents an export container; a child of a JavaScript unit that contains
+ * all (and only) the export declarations. If a JavaScript unit has no export
+ * declarations, no export container will be present.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ */
+public interface IExportContainer extends IJavaScriptElement, IParent, ISourceReference {
+ /**
+ * Returns the first export declaration in this export container with the given name.
+ * This is a handle-only method. The export declaration may or may not exist.
+ *
+ * @param name the given name
+ *
+ * @return the first export declaration in this export container with the given name
+ */
+ IExportDeclaration getExport(String name);
+}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportDeclaration.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportDeclaration.java
new file mode 100644
index 0000000..4a49bcd
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportDeclaration.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.core;
+
+/**
+ * Represents an export declaration in JavaScript unit.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ */
+public interface IExportDeclaration extends IJavaScriptElement, ISourceReference, ISourceManipulation {
+ /**
+ * Returns the name that has been exported.
+ *
+ * @return the name that has been exported
+ */
+ String getElementName();
+}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IJavaScriptElement.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IJavaScriptElement.java
index d1a6e76..727d52b 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IJavaScriptElement.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IJavaScriptElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -124,6 +124,18 @@
int LOCAL_VARIABLE = 14;
/**
+ * Constant representing all export declarations within a compilation unit.
+ * A JavaScript element with this type can be safely cast to {@link IExportContainer}.
+ */
+ int EXPORT_CONTAINER = 15;
+
+ /**
+ * Constant representing an export declaration within a compilation unit.
+ * A JavaScript element with this type can be safely cast to {@link IExportDeclaration}.
+ */
+ int EXPORT_DECLARATION = 16;
+
+ /**
* Returns whether this JavaScript element exists in the model.
* <p>
* JavaScript elements are handle objects that may or may not be backed by an
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IJavaScriptUnit.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IJavaScriptUnit.java
index c6fd2b5..8035493 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IJavaScriptUnit.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IJavaScriptUnit.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -404,6 +404,39 @@
* exception occurs while accessing its corresponding resource
*/
IImportDeclaration[] getImports() throws JavaScriptModelException;
+
+/**
+ * Returns the first export declaration in this javaScript file with the given name.
+ * This is a handle-only method. The export declaration may or may not exist. This
+ * is a convenience method - exports can also be accessed from a javaScript file's
+ * export container.
+ *
+ * @param name the name of the export to find
+ * @return a handle onto the corresponding export declaration. The export declaration may or may not exist.
+ */
+IExportDeclaration getExport(String name) ;
+/**
+ * Returns the export container for this javaScript file.
+ * This is a handle-only method. The export container may or
+ * may not exist. The export container can used to access the
+ * exports.
+ *
+ * @return a handle onto the corresponding export container. The
+ * export contain may or may not exist.
+ */
+IExportContainer getExportContainer();
+/**
+ * Returns the export declarations in this javaScript file
+ * in the order in which they appear in the source. This is
+ * a convenience method - export declarations can also be
+ * accessed from a javaScript file's export container.
+ *
+ * @return the export declarations in this javaScript file
+ * @throws JavaScriptModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+IExportDeclaration[] getExports() throws JavaScriptModelException;
+
/**
* Returns the primary javaScript file (whose owner is the primary owner)
* this working copy was created from, or this javaScript file if this a primary
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/ISourceElementRequestor.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/ISourceElementRequestor.java
index f959eff..5dcdf26 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/ISourceElementRequestor.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/ISourceElementRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -109,6 +109,18 @@
*/
void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand);
+ /**
+ * @param declarationStart
+ * This is the position of the first character of the export
+ * keyword.
+ * @param declarationEnd
+ * This is the position of the ';' ending the export statement or
+ * the end of the comment following the export.
+ * @param tokens
+ * This are the tokens of the export like specified in the source.
+ */
+ void acceptExport(int declarationStart, int declarationEnd, char[][] tokens);
+
/*
* Table of line separator position. This table is passed once at the end of
* the parse action, so as to allow computation of normalized ranges.
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnit.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnit.java
index b38549c..4e1861b 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnit.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnit.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,6 +31,8 @@
import org.eclipse.wst.jsdt.core.Flags;
import org.eclipse.wst.jsdt.core.IBuffer;
import org.eclipse.wst.jsdt.core.IBufferFactory;
+import org.eclipse.wst.jsdt.core.IExportContainer;
+import org.eclipse.wst.jsdt.core.IExportDeclaration;
import org.eclipse.wst.jsdt.core.IField;
import org.eclipse.wst.jsdt.core.IFunction;
import org.eclipse.wst.jsdt.core.IImportContainer;
@@ -73,6 +75,7 @@
/*package*/ static final int JLS2_INTERNAL = AST.JLS2;
private static final IImportDeclaration[] NO_IMPORTS = new IImportDeclaration[0];
+ private static final IExportDeclaration[] NO_EXPORTS = new IExportDeclaration[0];
protected String name;
public WorkingCopyOwner owner;
public String superTypeName;
@@ -290,6 +293,26 @@
op.runOperation(monitor);
return getImport(importName);
}
+
+ /**
+ * @see IJavaScriptUnit#createExport(String, IJavaScriptElement, IProgressMonitor)
+ */
+ public IExportDeclaration createExport(String exportName, IJavaScriptElement sibling, IProgressMonitor monitor) throws JavaScriptModelException {
+ return createExport(exportName, sibling, Flags.AccDefault, monitor);
+ }
+
+ /**
+ * @see IJavaScriptUnit#createExport(String, IJavaScriptElement, int, IProgressMonitor)
+ * @since 3.0
+ */
+ public IExportDeclaration createExport(String exportName, IJavaScriptElement sibling, int flags, IProgressMonitor monitor) throws JavaScriptModelException {
+ CreateExportOperation op = new CreateExportOperation(exportName, this, flags);
+ if (sibling != null) {
+ op.createBefore(sibling);
+ }
+ op.runOperation(monitor);
+ return getExport(exportName);
+ }
/**
* @see IJavaScriptUnit#createType(String, IJavaScriptElement, boolean, IProgressMonitor)
@@ -382,6 +405,12 @@
case IJavaScriptElement.IMPORT_DECLARATION:
currentElement = ((IImportContainer)currentElement).getImport(child.getElementName());
break;
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ currentElement = ((IJavaScriptUnit)currentElement).getExportContainer();
+ break;
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ currentElement = ((IExportContainer)currentElement).getExport(child.getElementName());
+ break;
case IJavaScriptElement.TYPE:
switch (currentElement.getElementType()) {
case IJavaScriptElement.JAVASCRIPT_UNIT:
@@ -720,6 +749,46 @@
return imports;
}
+
+ /**
+ * @see IJavaScriptUnit#getExport(String)
+ */
+ public IExportDeclaration getExport(String exportName) {
+ return getExportContainer().getExport(exportName);
+ }
+
+ /**
+ * @see IJavaScriptUnit#getExportContainer()
+ */
+ public IExportContainer getExportContainer() {
+ return new ExportContainer(this);
+ }
+
+ /**
+ * @see IJavaScriptUnit#getExports()
+ */
+ public IExportDeclaration[] getExports() throws JavaScriptModelException {
+ IExportContainer container= getExportContainer();
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ Object info = manager.getInfo(container);
+ if (info == null) {
+ if (manager.getInfo(this) != null)
+ // CU was opened, but no export container, then no exports
+ return NO_EXPORTS;
+ else {
+ open(null); // force opening of CU
+ info = manager.getInfo(container);
+ if (info == null)
+ // after opening, if no export container, then no exports
+ return NO_EXPORTS;
+ }
+ }
+ IJavaScriptElement[] elements = ((JavaElementInfo) info).children;
+ int length = elements.length;
+ IExportDeclaration[] exports = new IExportDeclaration[length];
+ System.arraycopy(elements, 0, exports, 0, length);
+ return exports;
+ }
/**
* @see IMember#getTypeRoot()
*/
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnitStructureRequestor.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnitStructureRequestor.java
index 2d4f783..a7a17ff 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnitStructureRequestor.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnitStructureRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -47,6 +47,11 @@
* The import container info - null until created
*/
protected JavaElementInfo importContainerInfo = null;
+
+ /**
+ * The export container info - null until created
+ */
+ protected JavaElementInfo exportContainerInfo = null;
/**
* Hashtable of children elements of the compilation unit.
@@ -138,6 +143,38 @@
addToChildren(this.importContainerInfo, handle);
this.newElements.put(handle, info);
}
+
+/**
+ * @see ISourceElementRequestor
+ */
+public void acceptExport(int declarationStart, int declarationEnd, char[][] tokens) {
+ JavaElement parentHandle= (JavaElement) this.handleStack.peek();
+ if (!(parentHandle.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT)) {
+ Assert.isTrue(false); // Should not happen
+ }
+
+ IJavaScriptUnit parentCU= (IJavaScriptUnit)parentHandle;
+ //create the export container and its info
+ ExportContainer exportContainer= (ExportContainer)parentCU.getExportContainer();
+ if (this.exportContainerInfo == null) {
+ this.exportContainerInfo = new JavaElementInfo();
+ JavaElementInfo parentInfo = (JavaElementInfo) this.infoStack.peek();
+ addToChildren(parentInfo, exportContainer);
+ this.newElements.put(exportContainer, this.exportContainerInfo);
+ }
+
+ String elementName = JavaModelManager.getJavaModelManager().intern(new String(CharOperation.concatWith(tokens, '.')));
+ ExportDeclaration handle = new ExportDeclaration(exportContainer, elementName);
+ resolveDuplicates(handle);
+
+ ExportDeclarationElementInfo info = new ExportDeclarationElementInfo();
+ info.setSourceRangeStart(declarationStart);
+ info.setSourceRangeEnd(declarationEnd);
+
+ addToChildren(this.exportContainerInfo, handle);
+ this.newElements.put(handle, info);
+}
+
/*
* Table of line separator position. This table is passed once at the end
* of the parse action, so as to allow computation of normalized ranges.
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnitStructureVisitor.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnitStructureVisitor.java
index 8ddd00d..41b02ba 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnitStructureVisitor.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CompilationUnitStructureVisitor.java
@@ -27,6 +27,7 @@
import org.eclipse.wst.jsdt.core.dom.ASTNode;
import org.eclipse.wst.jsdt.core.dom.Block;
import org.eclipse.wst.jsdt.core.dom.DefaultASTVisitor;
+import org.eclipse.wst.jsdt.core.dom.ExportDeclaration;
import org.eclipse.wst.jsdt.core.dom.Expression;
import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
import org.eclipse.wst.jsdt.core.dom.FieldAccess;
@@ -74,6 +75,11 @@
*/
protected JavaElementInfo importContainerInfo = null;
+ /**
+ * The export container info - null until created
+ */
+ protected JavaElementInfo exportContainerInfo = null;
+
/**
* Stack of parent scope info objects. The info on the
* top of the stack is the parent of the next element found.
@@ -366,11 +372,88 @@
}
return false;
}
+
+ private void visitExportModule(ExportDeclaration parent, ModuleSpecifier module) {
+ JavaElement parentHandle = this.handleStack.peek();
+ if (!(parentHandle.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT)) {
+ Assert.isTrue(false); // Should not happen
+ }
+
+ IJavaScriptUnit parentCU = (IJavaScriptUnit) parentHandle;
+ // create the export container and its info
+ ExportContainer exportContainer = (ExportContainer) parentCU.getExportContainer();
+ if (this.exportContainerInfo == null) {
+ this.exportContainerInfo = new JavaElementInfo();
+ JavaElementInfo parentInfo = this.infoStack.peek();
+ addToChildren(parentInfo, exportContainer);
+ this.newElements.put(exportContainer, this.exportContainerInfo);
+ }
+
+ final SimpleName localName = module.getLocal();
+ StringBuilder nameString = parent.getSource() != null ? new StringBuilder(parent.getSource().getLiteralValue()) : new StringBuilder("export");
+ nameString.append(" as ");
+ nameString.append(localName.getIdentifier());
+ String elementName = JavaModelManager.getJavaModelManager().intern(nameString.toString());
+ org.eclipse.wst.jsdt.internal.core.ExportDeclaration handle = new org.eclipse.wst.jsdt.internal.core.ExportDeclaration(exportContainer, elementName);
+ resolveDuplicates(handle);
+
+ ExportDeclarationElementInfo info = new ExportDeclarationElementInfo();
+ info.setNameSourceStart(localName.getStartPosition());
+ info.setNameSourceEnd(localName.getStartPosition() + localName.getLength() - 1);
+ info.setSourceRangeStart(parent.getStartPosition());
+ info.setSourceRangeEnd(parent.getStartPosition() + parent.getLength() - 1);
+
+ addToChildren(this.exportContainerInfo, handle);
+ this.newElements.put(handle, info);
+ }
+
+ public boolean visit(ExportDeclaration node) {
+ List specifiers = node.specifiers();
+ if (specifiers.isEmpty()) {
+ JavaElement parentHandle = this.handleStack.peek();
+ if (!(parentHandle.getElementType() == IJavaScriptElement.JAVASCRIPT_UNIT)) {
+ Assert.isTrue(false); // Should not happen
+ }
+
+ IJavaScriptUnit parentCU = (IJavaScriptUnit) parentHandle;
+ // create the export container and its info
+ ExportContainer exportContainer = (ExportContainer) parentCU.getExportContainer();
+ if (this.exportContainerInfo == null) {
+ this.exportContainerInfo = new JavaElementInfo();
+ JavaElementInfo parentInfo = this.infoStack.peek();
+ addToChildren(parentInfo, exportContainer);
+ this.newElements.put(exportContainer, this.exportContainerInfo);
+ }
+
+ String elementName = node.getSource() != null ? JavaModelManager.getJavaModelManager().intern(node.getSource().getLiteralValue()) : "export";
+
+ org.eclipse.wst.jsdt.internal.core.ExportDeclaration handle = new org.eclipse.wst.jsdt.internal.core.ExportDeclaration(exportContainer, elementName);
+ resolveDuplicates(handle);
+
+ ExportDeclarationElementInfo info = new ExportDeclarationElementInfo();
+ info.setNameSourceStart(node.getStartPosition());
+ info.setNameSourceEnd(node.getStartPosition() + node.getLength() - 1);
+ info.setSourceRangeStart(node.getStartPosition());
+ info.setSourceRangeEnd(node.getStartPosition() + node.getLength() - 1);
+
+ addToChildren(this.exportContainerInfo, handle);
+ this.newElements.put(handle, info);
+
+ }
+ else {
+ for (Iterator iterator = specifiers.iterator(); iterator.hasNext();) {
+ ModuleSpecifier module = (ModuleSpecifier) iterator.next();
+ visitExportModule(node, module);
+ }
+ }
+ return false;
+ }
public boolean visit(VariableDeclarationFragment node){
JavaElementInfo parentInfo = this.infoStack.peek();
JavaElement parentHandle= this.handleStack.peek();
- String fieldName = JavaModelManager.getJavaModelManager().intern(new String(node.getName().getIdentifier()));
+ String fieldName = JavaModelManager.getJavaModelManager().intern(
+ new String(node.getName().getIdentifier()));
SourceField handle = new SourceField(parentHandle, fieldName);
resolveDuplicates(handle);
@@ -435,6 +518,11 @@
setChildren(this.importContainerInfo);
}
+ // set export container children
+ if (this.exportContainerInfo != null) {
+ setChildren(this.exportContainerInfo);
+ }
+
// set children
setChildren(this.unitInfo);
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CreateElementInCUOperation.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CreateElementInCUOperation.java
index 09d2fa1..c31a23f 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CreateElementInCUOperation.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CreateElementInCUOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -321,6 +321,9 @@
if (domPresentParent.getElementType() == IJavaScriptElement.IMPORT_CONTAINER) {
domPresentParent = domPresentParent.getParent();
}
+ if (domPresentParent.getElementType() == IJavaScriptElement.EXPORT_CONTAINER) {
+ domPresentParent = domPresentParent.getParent();
+ }
if (!domPresentParent.equals(getParentElement())) {
return new JavaModelStatus(IJavaScriptModelStatusConstants.INVALID_SIBLING, this.anchorElement);
}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CreateExportOperation.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CreateExportOperation.java
new file mode 100644
index 0000000..9d7cdff
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/CreateExportOperation.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.internal.core;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.jsdt.core.IExportDeclaration;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.IJavaScriptModelStatus;
+import org.eclipse.wst.jsdt.core.IJavaScriptModelStatusConstants;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
+import org.eclipse.wst.jsdt.core.IType;
+import org.eclipse.wst.jsdt.core.JavaScriptConventions;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.core.JavaScriptModelException;
+import org.eclipse.wst.jsdt.core.compiler.CharOperation;
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.ExportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.Name;
+import org.eclipse.wst.jsdt.core.dom.StructuralPropertyDescriptor;
+import org.eclipse.wst.jsdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.wst.jsdt.internal.core.util.Messages;
+
+/**
+ * <p>
+ * This operation adds an export declaration to an existing compilation unit.
+ * If the compilation unit already includes the specified export declaration,
+ * the export is not generated (it does not generate duplicates).
+ *
+ * <p>
+ * Required Attributes:
+ * <ul>
+ * <li>Compilation unit
+ * <li>Export name - the name of the export to add to the compilation unit.
+ * </ul>
+ */
+public class CreateExportOperation extends CreateElementInCUOperation {
+ /*
+ * The name of the export to be created.
+ */
+ protected String exportName;
+
+ /*
+ * The flags of the export to be created (either Flags#AccDefault or
+ * Flags#AccStatic)
+ */
+ protected int flags;
+
+ /**
+ * This operation will add an export to the specified compilation unit.
+ */
+ public CreateExportOperation(String exportName, IJavaScriptUnit parentElement, int flags) {
+ super(parentElement);
+ this.exportName = exportName;
+ this.flags = flags;
+ }
+
+ protected StructuralPropertyDescriptor getChildPropertyDescriptor(ASTNode parent) {
+ return JavaScriptUnit.EXPORTS_PROPERTY;
+ }
+
+ protected ASTNode generateElementAST(ASTRewrite rewriter, IDocument document, IJavaScriptUnit cu) throws JavaScriptModelException {
+ // ensure no duplicate
+ Iterator exports = this.cuAST.exports().iterator();
+ //boolean onDemand = this.exportName.endsWith(".*"); //$NON-NLS-1$
+ String exportActualName = this.exportName;
+ //if (onDemand) {
+// importActualName = this.importName.substring(0, this.importName.length() - 2);
+ // }
+ while (exports.hasNext()) {
+ ExportDeclaration exportDeclaration = (ExportDeclaration) exports.next();
+ //ModuleSpecifier specifiers = exportDeclaration.specifiers();
+ //if (exportActualName.equals(exportDeclaration.getName().getFullyQualifiedName()) &&
+ //(onDemand == importDeclaration.isOnDemand()) &&
+ //(Flags.isStatic(this.flags) == exportDeclaration.isStatic())) {
+ //this.creationOccurred = false;
+ //return null;
+ //}
+ }
+
+ AST ast = this.cuAST.getAST();
+ ExportDeclaration exportDeclaration = ast.newExportDeclaration();
+
+ // split export name into individual fragments, checking for on demand
+ // imports
+ char[][] charFragments = CharOperation.splitOn('.', exportActualName.toCharArray(), 0, exportActualName.length());
+ int length = charFragments.length;
+ String[] strFragments = new String[length];
+ for (int i = 0; i < length; i++) {
+ strFragments[i] = String.valueOf(charFragments[i]);
+ }
+ Name name = ast.newName(strFragments);
+ //exportDeclaration.setName(name);
+ //if (onDemand)
+ // importDeclaration.setOnDemand(true);
+ return exportDeclaration;
+ }
+
+ /**
+ * @see CreateElementInCUOperation#generateResultHandle
+ */
+ protected IJavaScriptElement generateResultHandle() {
+ return getCompilationUnit().getExport(this.exportName);
+ }
+
+ /**
+ * @see CreateElementInCUOperation#getMainTaskName()
+ */
+ public String getMainTaskName() {
+ return Messages.operation_createImportsProgress;
+ }
+
+ /**
+ * Sets the correct position for the new export:
+ * <ul>
+ * <li>after the last export
+ * <li>if no exports, before the first type
+ * <li>if no type, after the package statement
+ * <li>and if no package statement - first thing in the CU
+ */
+ protected void initializeDefaultPosition() {
+ try {
+ IJavaScriptUnit cu = getCompilationUnit();
+ IExportDeclaration[] exports = cu.getExports();
+ if (exports.length > 0) {
+ createAfter(exports[exports.length - 1]);
+ return;
+ }
+ IType[] types = cu.getTypes();
+ if (types.length > 0) {
+ createBefore(types[0]);
+ return;
+ }
+ }
+ catch (JavaScriptModelException e) {
+ // cu doesn't exit: ignore
+ }
+ }
+
+ /**
+ * Possible failures:
+ * <ul>
+ * <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the
+ * operation is <code>null</code>.
+ * <li>INVALID_NAME - not a valid import declaration name.
+ * </ul>
+ *
+ * @see IJavaScriptModelStatus
+ * @see JavaScriptConventions
+ */
+ public IJavaScriptModelStatus verify() {
+ IJavaScriptModelStatus status = super.verify();
+ if (!status.isOK()) {
+ return status;
+ }
+ IJavaScriptProject project = getParentElement().getJavaScriptProject();
+ if (JavaScriptConventions.validateImportDeclaration(this.exportName,
+ project.getOption(JavaScriptCore.COMPILER_SOURCE, true),
+ project.getOption(JavaScriptCore.COMPILER_COMPLIANCE, true)).getSeverity() == IStatus.ERROR) {
+ return new JavaModelStatus(IJavaScriptModelStatusConstants.INVALID_NAME, this.exportName);
+ }
+ return JavaModelStatus.VERIFIED_OK;
+ }
+}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/DeleteElementsOperation.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/DeleteElementsOperation.java
index 53756d5..ca98f19 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/DeleteElementsOperation.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/DeleteElementsOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -145,6 +145,10 @@
// keep track of the import statements - if all are removed, delete
// the import container (and report it in the delta)
int numberOfImports = cu.getImports().length;
+
+ // keep track of the export statements - if all are removed, delete
+ // the export container (and report it in the delta)
+ int numberOfExports = cu.getExports().length;
JavaElementDelta delta = new JavaElementDelta(cu);
IJavaScriptElement[] cuElements = ((IRegion) childrenToRemove.get(cu)).getElements();
@@ -158,6 +162,11 @@
if (numberOfImports == 0) {
delta.removed(cu.getImportContainer());
}
+ } else if (e.getElementType() == IJavaScriptElement.EXPORT_DECLARATION) {
+ numberOfExports--;
+ if (numberOfExports == 0) {
+ delta.removed(cu.getExportContainer());
+ }
}
}
}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportContainer.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportContainer.java
new file mode 100644
index 0000000..d905d9d
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportContainer.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Licensed Materials - Property of IBM
+ * © Copyright 2016 IBM Corporation and others. All Rights Reserved.
+ * U.S. Government Users Restricted Rights - Use, duplication or disclosure
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.internal.core;
+
+import org.eclipse.wst.jsdt.core.IExportContainer;
+import org.eclipse.wst.jsdt.core.IExportDeclaration;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.ISourceRange;
+import org.eclipse.wst.jsdt.core.ISourceReference;
+import org.eclipse.wst.jsdt.core.JavaScriptModelException;
+import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
+import org.eclipse.wst.jsdt.internal.core.util.MementoTokenizer;
+
+public class ExportContainer extends SourceRefElement implements IExportContainer {
+ protected ExportContainer(CompilationUnit parent) {
+ super(parent);
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof ExportContainer))
+ return false;
+ return super.equals(o);
+ }
+
+ /**
+ * @see IJavaScriptElement
+ */
+ public int getElementType() {
+ return EXPORT_CONTAINER;
+ }
+
+ /*
+ * @see JavaElement
+ */
+ public IJavaScriptElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
+ switch (token.charAt(0)) {
+ case JEM_COUNT :
+ return getHandleUpdatingCountFromMemento(memento, workingCopyOwner);
+ case JEM_IMPORTDECLARATION :
+ if (memento.hasMoreTokens()) {
+ String exportName = memento.nextToken();
+ JavaElement exportDecl = (JavaElement) getExport(exportName);
+ return exportDecl.getHandleFromMemento(memento, workingCopyOwner);
+ }
+ else {
+ return this;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see JavaElement#getHandleMemento()
+ */
+ protected char getHandleMementoDelimiter() {
+ return JavaElement.JEM_IMPORTDECLARATION;
+ }
+
+ /**
+ * @see IExportContainer
+ */
+ public IExportDeclaration getExport(String exportName) {
+ int index = exportName.indexOf(".*"); ///$NON-NLS-1$
+ boolean isOnDemand = index != -1;
+ if (isOnDemand)
+ // make sure to copy the string (so that it doesn't hold on the
+ // underlying char[] that might be much bigger than necessary)
+ exportName = new String(exportName.substring(0, index));
+ return new ExportDeclaration(this, exportName);
+ }
+
+ /*
+ * @see JavaElement#getPrimaryElement(boolean)
+ */
+ public IJavaScriptElement getPrimaryElement(boolean checkOwner) {
+ CompilationUnit cu = (CompilationUnit) this.parent;
+ if (checkOwner && cu.isPrimary())
+ return this;
+ return cu.getExportContainer();
+ }
+
+ /**
+ * @see ISourceReference
+ */
+ public ISourceRange getSourceRange() throws JavaScriptModelException {
+ SourceRange range;
+ IJavaScriptElement[] exports = getChildren();
+
+ if (exports.length > 0) {
+ ISourceRange firstRange = ((ISourceReference) exports[0]).getSourceRange();
+ ISourceRange lastRange = ((ISourceReference) exports[exports.length - 1]).getSourceRange();
+ range = new SourceRange(firstRange.getOffset(), lastRange.getOffset() + lastRange.getLength() - firstRange.getOffset());
+ } else {
+ range = new SourceRange(0, 0);
+ }
+
+ return range;
+ }
+
+ /**
+ */
+ public String readableName() {
+
+ return null;
+ }
+
+ /**
+ * @private Debugging purposes
+ */
+ protected void toString(int tab, StringBuffer buffer) {
+ Object info = JavaModelManager.getJavaModelManager().peekAtInfo(this);
+ if (info == null || !(info instanceof JavaElementInfo))
+ return;
+ IJavaScriptElement[] children = ((JavaElementInfo) info).getChildren();
+ for (int i = 0; i < children.length; i++) {
+ if (i > 0)
+ buffer.append("\n"); //$NON-NLS-1$
+ ((JavaElement) children[i]).toString(tab, buffer);
+ }
+ }
+
+ /**
+ * Debugging purposes
+ */
+ protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo) {
+ buffer.append(this.tabString(tab));
+ buffer.append("<export container>"); //$NON-NLS-1$
+ if (info == null) {
+ buffer.append(" (not open)"); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportDeclaration.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportDeclaration.java
new file mode 100644
index 0000000..c77430a
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportDeclaration.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Licensed Materials - Property of IBM
+ * © Copyright 2016 IBM Corporation and others. All Rights Reserved.
+ * U.S. Government Users Restricted Rights - Use, duplication or disclosure
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.internal.core;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.wst.jsdt.core.IExportDeclaration;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.JavaScriptModelException;
+
+public class ExportDeclaration extends SourceRefElement implements IExportDeclaration {
+
+ protected String name;
+
+ /**
+ * Constructs an ExportDeclaration in the given export container with the
+ * given name.
+ */
+ protected ExportDeclaration(ExportContainer parent, String name) {
+ super(parent);
+ this.name = name;
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof ExportDeclaration))
+ return false;
+ return super.equals(o);
+ }
+
+ public String getElementName() {
+ return this.name;
+ }
+
+ /**
+ * @see IJavaScriptElement
+ */
+ public int getElementType() {
+ return EXPORT_DECLARATION;
+ }
+
+ /**
+ * @see org.eclipse.wst.jsdt.core.IExportDeclaration#getFlags()
+ */
+ public int getFlags() throws JavaScriptModelException {
+ ExportDeclarationElementInfo info = (ExportDeclarationElementInfo) getElementInfo();
+ return info.getModifiers();
+ }
+
+ /**
+ * @see JavaElement#getHandleMemento(StringBuffer) For export
+ * declarations, the handle delimiter is associated to the export
+ * container already
+ */
+ protected void getHandleMemento(StringBuffer buff) {
+ ((JavaElement) getParent()).getHandleMemento(buff);
+ escapeMementoName(buff, getElementName());
+ if (this.occurrenceCount > 1) {
+ buff.append(JEM_COUNT);
+ buff.append(this.occurrenceCount);
+ }
+ }
+
+ /**
+ * @see JavaElement#getHandleMemento()
+ */
+ protected char getHandleMementoDelimiter() {
+ // For export declarations, the handle delimiter is associated to the
+ // export container already
+ Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
+ return 0;
+ }
+
+ /*
+ * @see JavaElement#getPrimaryElement(boolean)
+ */
+ public IJavaScriptElement getPrimaryElement(boolean checkOwner) {
+ CompilationUnit cu = (CompilationUnit) this.parent.getParent();
+ if (checkOwner && cu.isPrimary())
+ return this;
+ return cu.getExport(getElementName());
+ }
+
+ /**
+ */
+ public String readableName() {
+
+ return null;
+ }
+
+ /**
+ * @private Debugging purposes
+ */
+ protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo) {
+ buffer.append(this.tabString(tab));
+ buffer.append("export "); //$NON-NLS-1$
+ toStringName(buffer);
+ if (info == null) {
+ buffer.append(" (not open)"); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportDeclarationElementInfo.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportDeclarationElementInfo.java
new file mode 100644
index 0000000..e28cb75
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/ExportDeclarationElementInfo.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.internal.core;
+
+import org.eclipse.wst.jsdt.internal.compiler.env.ISourceImport;
+
+
+public class ExportDeclarationElementInfo extends MemberElementInfo implements ISourceImport{
+
+ // empty element info
+}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/SourceMapper.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/SourceMapper.java
index 945d5d4..e0a1613 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/SourceMapper.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/SourceMapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -164,6 +164,12 @@
private HashMap importsCounterTable;
/**
+ * exports references
+ */
+ private HashMap exportsTable;
+ private HashMap exportsCounterTable;
+
+ /**
* Enclosing type information
*/
IType[] types;
@@ -214,6 +220,8 @@
this.parameterNames = new HashMap();
this.importsTable = new HashMap();
this.importsCounterTable = new HashMap();
+ this.exportsTable = new HashMap();
+ this.exportsCounterTable = new HashMap();
}
/**
@@ -251,6 +259,35 @@
this.importsTable.put(this.binaryType, imports);
this.importsCounterTable.put(this.binaryType, Integer.valueOf(importsCounter));
}
+
+ /**
+ * @see ISourceElementRequestor
+ */
+ public void acceptExport(
+ int declarationStart,
+ int declarationEnd,
+ char[][] tokens) {
+ char[][] exports = (char[][]) this.exportsTable.get(this.binaryType);
+ int exportsCounter;
+ if (exports == null) {
+ exports = new char[5][];
+ exportsCounter = 0;
+ } else {
+ exportsCounter = ((Integer) this.exportsCounterTable.get(this.binaryType)).intValue();
+ }
+ if (exports.length == exportsCounter) {
+ System.arraycopy(
+ exports,
+ 0,
+ (exports = new char[exportsCounter * 2][]),
+ 0,
+ exportsCounter);
+ }
+ char[] name = CharOperation.concatWith(tokens, '.');
+ exports[exportsCounter++] = name;
+ this.exportsTable.put(this.binaryType, exports);
+ this.exportsCounterTable.put(this.binaryType, Integer.valueOf(exportsCounter));
+ }
/**
* @see ISourceElementRequestor
@@ -1158,6 +1195,8 @@
this.importsTable.remove(this.binaryType);
this.importsCounterTable.remove(this.binaryType);
+ this.exportsTable.remove(this.binaryType);
+ this.exportsCounterTable.remove(this.binaryType);
this.searchedElement = elementToFind;
this.types = new IType[1];
this.typeDeclarationStarts = new int[1];
@@ -1278,6 +1317,26 @@
}
return imports;
}
+
+ /**
+ * Return a char[][] array containing the exports of the attached source for the binary type
+ */
+ public char[][] getExports(BinaryType type) {
+ char[][] exports = (char[][]) this.exportsTable.get(type);
+ if (exports != null) {
+ int exportsCounter = ((Integer) this.exportsCounterTable.get(type)).intValue();
+ if (exports.length != exportsCounter) {
+ System.arraycopy(
+ exports,
+ 0,
+ (exports = new char[exportsCounter][]),
+ 0,
+ exportsCounter);
+ }
+ this.exportsTable.put(type, exports);
+ }
+ return exports;
+ }
private boolean hasToRetrieveSourceRangesForLocalClass(char[] eltName) {
/*
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/indexing/SourceIndexerRequestor.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/indexing/SourceIndexerRequestor.java
index 7143f3c..0db425e 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/indexing/SourceIndexerRequestor.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/search/indexing/SourceIndexerRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -54,8 +54,16 @@
* @see ISourceElementRequestor#acceptImport(int, int, char[][], boolean, int)
*/
public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand) {
- // imports have already been reported while creating the ImportRef node (see SourceElementParser#comsume*ImportDeclarationName() methods)
+ // imports have already been reported while creating the ImportRef node (see SourceElementParser#consume*ImportDeclarationName() methods)
}
+
+/**
+ * @see ISourceElementRequestor#acceptExport(int, int, char[][], int)
+ */
+public void acceptExport(int declarationStart, int declarationEnd, char[][] tokens) {
+
+}
+
/**
* @see ISourceElementRequestor#acceptLineSeparatorPositions(int[])
*/
diff --git a/bundles/org.eclipse.wst.jsdt.ui/icons/full/obj16/exp_obj.gif b/bundles/org.eclipse.wst.jsdt.ui/icons/full/obj16/exp_obj.gif
new file mode 100644
index 0000000..9e44ce5
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.ui/icons/full/obj16/exp_obj.gif
Binary files differ
diff --git a/bundles/org.eclipse.wst.jsdt.ui/icons/full/obj16/expc_obj.gif b/bundles/org.eclipse.wst.jsdt.ui/icons/full/obj16/expc_obj.gif
new file mode 100644
index 0000000..ea94702
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.ui/icons/full/obj16/expc_obj.gif
Binary files differ
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/javadoc/JavaDocLocations.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/javadoc/JavaDocLocations.java
index 2cfee5f..8a36789 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/javadoc/JavaDocLocations.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/javadoc/JavaDocLocations.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -461,6 +461,7 @@
appendIndexPath(pathBuffer);
break;
case IJavaScriptElement.IMPORT_CONTAINER :
+ case IJavaScriptElement.EXPORT_CONTAINER :
element= element.getParent();
//$FALL-THROUGH$
case IJavaScriptElement.JAVASCRIPT_UNIT :
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/RefactoringCoreMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/RefactoringCoreMessages.java
index 0c369f2..730d06c 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/RefactoringCoreMessages.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/RefactoringCoreMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2129,6 +2129,10 @@
public static String ReorgUtils_2;
public static String ReorgUtils_20;
+
+ public static String ReorgUtils_21;
+
+ public static String ReorgUtils_22;
public static String ReorgUtils_3;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/TypedSource.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/TypedSource.java
index 7b2fb2f..94ae1d2 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/TypedSource.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/TypedSource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,6 +20,7 @@
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.jsdt.core.IBuffer;
+import org.eclipse.wst.jsdt.core.IExportContainer;
import org.eclipse.wst.jsdt.core.IField;
import org.eclipse.wst.jsdt.core.IImportContainer;
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
@@ -99,6 +100,8 @@
|| type == IJavaScriptElement.TYPE
|| type == IJavaScriptElement.IMPORT_CONTAINER
|| type == IJavaScriptElement.IMPORT_DECLARATION
+ || type == IJavaScriptElement.EXPORT_CONTAINER
+ || type == IJavaScriptElement.EXPORT_DECLARATION
|| type == IJavaScriptElement.INITIALIZER
|| type == IJavaScriptElement.METHOD;
}
@@ -136,12 +139,15 @@
return null;
if (elem.getElementType() == IJavaScriptElement.IMPORT_CONTAINER)
return createTypedSourcesForImportContainer(tuple, (IImportContainer)elem);
+ else if (elem.getElementType() == IJavaScriptElement.EXPORT_CONTAINER)
+ return createTypedSourcesForExportContainer(tuple, (IExportContainer)elem);
else if (elem.getElementType() == IJavaScriptElement.FIELD)
return new TypedSource[] {create(getFieldSource((IField)elem, tuple), elem.getElementType())};
return new TypedSource[] {create(getSourceOfDeclararationNode(elem, tuple.unit), elem.getElementType())};
}
- private static TypedSource[] createTypedSourcesForImportContainer(SourceTuple tuple, IImportContainer container) throws JavaScriptModelException, CoreException {
+ private static TypedSource[] createTypedSourcesForImportContainer(SourceTuple tuple, IImportContainer container)
+ throws JavaScriptModelException, CoreException {
IJavaScriptElement[] imports= container.getChildren();
List result= new ArrayList(imports.length);
for (int i= 0; i < imports.length; i++) {
@@ -149,6 +155,16 @@
}
return (TypedSource[]) result.toArray(new TypedSource[result.size()]);
}
+
+ private static TypedSource[] createTypedSourcesForExportContainer(SourceTuple tuple, IExportContainer container)
+ throws JavaScriptModelException, CoreException {
+ IJavaScriptElement[] exports= container.getChildren();
+ List result= new ArrayList(exports.length);
+ for (int i= 0; i < exports.length; i++) {
+ result.addAll(Arrays.asList(createTypedSources(exports[i], tuple)));
+ }
+ return (TypedSource[]) result.toArray(new TypedSource[result.size()]);
+ }
private static String getFieldSource(IField field, SourceTuple tuple) throws CoreException {
if (tuple.node == null) {
@@ -170,6 +186,7 @@
private static String getSourceOfDeclararationNode(IJavaScriptElement elem, IJavaScriptUnit cu) throws JavaScriptModelException, CoreException {
Assert.isTrue(elem.getElementType() != IJavaScriptElement.IMPORT_CONTAINER);
+ Assert.isTrue(elem.getElementType() != IJavaScriptElement.EXPORT_CONTAINER);
if (elem instanceof ISourceReference) {
ISourceReference reference= (ISourceReference) elem;
String source= reference.getSource();
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/refactoring.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/refactoring.properties
index 59b041c..f5a3330 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/refactoring.properties
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/corext/refactoring/refactoring.properties
@@ -1166,6 +1166,8 @@
ReorgUtils_18=type ''{0}''
ReorgUtils_19=new {0}() '{'...}
ReorgUtils_20=anonymous type ''{0}''
+ReorgUtils_21=the export container
+ReorgUtils_22=export declaration ''{0}''
DeleteChangeCreator_1=Delete elements
DeleteRefactoring_1=Analyzing...
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPluginImages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPluginImages.java
index 3ecfac2..8d5d126 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPluginImages.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaPluginImages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -68,6 +68,8 @@
public static final String IMG_OBJS_PACKDECL= NAME_PREFIX + "packd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_IMPDECL= NAME_PREFIX + "imp_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_IMPCONT= NAME_PREFIX + "impc_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_EXPDECL= NAME_PREFIX + "exp_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_EXPCONT= NAME_PREFIX + "expc_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_JSEARCH= NAME_PREFIX + "jsearch_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_DECL= NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_REF= NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$
@@ -192,6 +194,8 @@
public static final ImageDescriptor DESC_OBJS_PACKDECL= createManagedFromKey(T_OBJ, IMG_OBJS_PACKDECL);
public static final ImageDescriptor DESC_OBJS_IMPDECL= createManagedFromKey(T_OBJ, IMG_OBJS_IMPDECL);
public static final ImageDescriptor DESC_OBJS_IMPCONT= createManagedFromKey(T_OBJ, IMG_OBJS_IMPCONT);
+ public static final ImageDescriptor DESC_OBJS_EXPDECL= createManagedFromKey(T_OBJ, IMG_OBJS_EXPDECL);
+ public static final ImageDescriptor DESC_OBJS_EXPCONT= createManagedFromKey(T_OBJ, IMG_OBJS_EXPCONT);
public static final ImageDescriptor DESC_OBJS_JSEARCH= createManagedFromKey(T_OBJ, IMG_OBJS_JSEARCH);
public static final ImageDescriptor DESC_OBJS_SEARCH_DECL= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_DECL);
public static final ImageDescriptor DESC_OBJS_SEARCH_REF= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_REF);
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.java
index 0e2c428..f77d438 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -73,6 +73,7 @@
public static String JavaElementLabels_anonym_type;
public static String JavaElementLabels_anonym;
public static String JavaElementLabels_import_container;
+ public static String JavaElementLabels_export_container;
public static String JavaElementLabels_initializer;
public static String JavaElementLabels_category;
public static String JavaElementLabels_concat_string;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.properties
index fd41121..ea48373 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.properties
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/JavaUIMessages.properties
@@ -108,6 +108,7 @@
JavaElementLabels_category_separator_string=\
JavaElementLabels_default_package=./
JavaElementLabels_import_container=import declarations
+JavaElementLabels_export_container=export declarations
JavaElementLabels_initializer={...}
StatusBarUpdater_num_elements_selected={0} items selected
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CleanUpAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CleanUpAction.java
index 498b493..8a00513 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CleanUpAction.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/CleanUpAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -127,6 +127,7 @@
case IJavaScriptElement.JAVASCRIPT_UNIT:
return true;
case IJavaScriptElement.IMPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_CONTAINER:
return true;
case IJavaScriptElement.PACKAGE_FRAGMENT:
case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
@@ -232,6 +233,9 @@
case IJavaScriptElement.IMPORT_CONTAINER:
result.add(elem.getParent());
break;
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ result.add(elem.getParent());
+ break;
case IJavaScriptElement.PACKAGE_FRAGMENT:
collectCompilationUnits((IPackageFragment)elem, result);
break;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FindBrokenNLSKeysAction.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FindBrokenNLSKeysAction.java
index b423495..2814021 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FindBrokenNLSKeysAction.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/actions/FindBrokenNLSKeysAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -190,6 +190,7 @@
case IJavaScriptElement.JAVASCRIPT_UNIT:
return true;
case IJavaScriptElement.IMPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_CONTAINER:
return false;
case IJavaScriptElement.PACKAGE_FRAGMENT:
case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
@@ -237,6 +238,7 @@
}
break;
case IJavaScriptElement.IMPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_CONTAINER:
break;
case IJavaScriptElement.PACKAGE_FRAGMENT:
IPackageFragment fragment= (IPackageFragment)elem;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingContentProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingContentProvider.java
index 84ec80b..4126f1d 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingContentProvider.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaBrowsingContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,6 +28,7 @@
import org.eclipse.wst.jsdt.core.ElementChangedEvent;
import org.eclipse.wst.jsdt.core.IClassFile;
import org.eclipse.wst.jsdt.core.IElementChangedListener;
+import org.eclipse.wst.jsdt.core.IExportContainer;
import org.eclipse.wst.jsdt.core.IImportContainer;
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
import org.eclipse.wst.jsdt.core.IJavaScriptElementDelta;
@@ -120,7 +121,8 @@
Object[] result= new Object[0];
for (int i= 0; i < sourceRefs.length; i++)
- result= concatenate(result, removeImportAndPackageDeclarations(getChildren(sourceRefs[i])));
+ result= concatenate(result, removeExportAndPackageDeclarations(
+ removeImportAndPackageDeclarations(getChildren(sourceRefs[i]))));
return concatenate(result, fragment.getNonJavaScriptResources());
}
@@ -131,6 +133,14 @@
tempResult.add(members[i]);
return tempResult.toArray();
}
+
+ private Object[] removeExportAndPackageDeclarations(Object[] members) {
+ ArrayList tempResult= new ArrayList(members.length);
+ for (int i= 0; i < members.length; i++)
+ if (!(members[i] instanceof IExportContainer))
+ tempResult.add(members[i]);
+ return tempResult.toArray();
+ }
private Object[] getChildren(IType type) throws JavaScriptModelException{
IParent parent;
@@ -142,13 +152,19 @@
if (type.getDeclaringType() != null)
return type.getChildren();
- // Add import declarations
+ // Add import and export declarations
IJavaScriptElement[] members= parent.getChildren();
ArrayList tempResult= new ArrayList(members.length);
for (int i= 0; i < members.length; i++)
if ((members[i] instanceof IImportContainer))
tempResult.add(members[i]);
+
+ for (int i= 0; i < members.length; i++)
+ if ((members[i] instanceof IExportContainer))
+ tempResult.add(members[i]);
+
tempResult.addAll(Arrays.asList(type.getChildren()));
+
return tempResult.toArray();
}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaElementTypeComparator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaElementTypeComparator.java
index 88bde5b..cabb056 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaElementTypeComparator.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/JavaElementTypeComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -77,6 +77,10 @@
return 20;
case IJavaScriptElement.IMPORT_DECLARATION:
return 10;
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ return 20;
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ return 10;
default :
return 1;
}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/MembersView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/MembersView.java
index 0ad561e..0390890 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/MembersView.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/MembersView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,6 +25,8 @@
import org.eclipse.ui.IMemento;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.wst.jsdt.core.IClassFile;
+import org.eclipse.wst.jsdt.core.IExportContainer;
+import org.eclipse.wst.jsdt.core.IExportDeclaration;
import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IImportContainer;
import org.eclipse.wst.jsdt.core.IImportDeclaration;
@@ -187,6 +189,22 @@
}
}
}
+ else if (element instanceof IExportDeclaration)
+ return isValidElement(((IJavaScriptElement)element).getParent());
+ else if (element instanceof IExportContainer) {
+ Object input = getViewer().getInput();
+ if (input instanceof IJavaScriptElement) {
+ IJavaScriptUnit cu = (IJavaScriptUnit)((IJavaScriptElement)input).getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
+ if (cu != null) {
+ IJavaScriptUnit exportContainerCu = (IJavaScriptUnit)((IJavaScriptElement)element).getAncestor(IJavaScriptElement.JAVASCRIPT_UNIT);
+ return cu.equals(exportContainerCu);
+ } else {
+ IClassFile cf = (IClassFile)((IJavaScriptElement)input).getAncestor(IJavaScriptElement.CLASS_FILE);
+ IClassFile exportContainerCf = (IClassFile)((IJavaScriptElement)element).getAncestor(IJavaScriptElement.CLASS_FILE);
+ return cf != null && cf.equals(exportContainerCf);
+ }
+ }
+ }
return false;
}
@@ -209,6 +227,7 @@
case IJavaScriptElement.INITIALIZER:
case IJavaScriptElement.FIELD:
case IJavaScriptElement.IMPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_CONTAINER:
return je;
case IJavaScriptElement.IMPORT_DECLARATION:
IJavaScriptUnit cu= (IJavaScriptUnit)je.getParent().getParent();
@@ -222,6 +241,18 @@
// return je;
}
return je;
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ cu = (IJavaScriptUnit)je.getParent().getParent();
+ try {
+ if (cu.getExports()[0].equals(je)) {
+ Object selectedElement = getSingleElementFromSelection(getViewer().getSelection());
+ if (selectedElement instanceof IExportContainer)
+ return (IExportContainer)selectedElement;
+ }
+ } catch (JavaScriptModelException ex) {
+ // return je
+ }
+ return je;
}
return null;
}
@@ -254,9 +285,19 @@
IJavaScriptElement parent= je.getParent();
if (parent instanceof IJavaScriptUnit) {
return getTypeForCU((IJavaScriptUnit)parent);
- }
- else if (parent instanceof IClassFile)
+ } else if (parent instanceof IClassFile) {
return findInputForJavaElement(parent);
+ }
+ return null;
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ return findInputForJavaElement(je.getParent());
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ parent = je.getParent();
+ if (parent instanceof IJavaScriptUnit) {
+ return getTypeForCU((IJavaScriptUnit)parent);
+ } else if (parent instanceof IClassFile) {
+ return findInputForJavaElement(parent);
+ }
return null;
default:
if (je instanceof IMember)
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TypesView.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TypesView.java
index d113b10..4f82a49 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TypesView.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/browsing/TypesView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -138,6 +138,8 @@
return findElementToSelect(((IClassFile)je).getType());
case IJavaScriptElement.IMPORT_CONTAINER:
case IJavaScriptElement.IMPORT_DECLARATION:
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_DECLARATION:
return findElementToSelect(je.getParent());
default:
if (je instanceof IMember)
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.java
index ca1f9b9..bb5b53d 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,6 +27,7 @@
public static String JavaStructureViewer_title;
public static String JavaNode_compilationUnit;
public static String JavaNode_importDeclarations;
+ public static String JavaNode_exportDeclarations;
public static String JavaNode_initializer;
public static String JavaNode_packageDeclaration;
public static String PropertiesStructureCreator_error_occurred;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.properties b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.properties
index 5fcd2e0..48ee014 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.properties
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/CompareMessages.properties
@@ -27,6 +27,7 @@
JavaStructureViewer_title= JavaScript Structure Compare
JavaNode_compilationUnit= JavaScript file
JavaNode_importDeclarations= Import Declarations
+JavaNode_exportDeclarations= Export Declarations
JavaNode_initializer= {...}
JavaNode_packageDeclaration= Package Declaration
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareUtilities.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareUtilities.java
index 743bee3..d660c06 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareUtilities.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaCompareUtilities.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -47,6 +47,8 @@
private static final char PACKAGEDECLARATION= '%';
private static final char IMPORTDECLARATION= '#';
private static final char IMPORT_CONTAINER= '<';
+ private static final char EXPORTDECLARATION = '#';
+ private static final char EXPORT_CONTAINER = '<';
private static final char FIELD= '^';
private static final char METHOD= '~';
private static final char INITIALIZER= '|';
@@ -96,6 +98,10 @@
return JavaPluginImages.DESC_OBJS_IMPDECL;
case IJavaScriptElement.IMPORT_CONTAINER:
return JavaPluginImages.DESC_OBJS_IMPCONT;
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ return JavaPluginImages.DESC_OBJS_EXPDECL;
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ return JavaPluginImages.DESC_OBJS_EXPCONT;
case IJavaScriptElement.JAVASCRIPT_UNIT:
return JavaPluginImages.DESC_OBJS_CUNIT;
}
@@ -170,6 +176,13 @@
sb.append(IMPORTDECLARATION);
sb.append(je.getElementName());
break;
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ sb.append(EXPORT_CONTAINER);
+ break;
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ sb.append(EXPORTDECLARATION);
+ sb.append(je.getElementName());
+ break;
default:
return null;
}
@@ -216,6 +229,13 @@
case JavaNode.IMPORT_CONTAINER:
sb.append(IMPORT_CONTAINER);
break;
+ case JavaNode.EXPORT:
+ sb.append(EXPORTDECLARATION);
+ sb.append(name);
+ break;
+ case JavaNode.EXPORT_CONTAINER:
+ sb.append(EXPORT_CONTAINER);
+ break;
default:
Assert.isTrue(false);
break;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaElementHistoryPageSource.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaElementHistoryPageSource.java
index 0c9a6ef..b1c7416 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaElementHistoryPageSource.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaElementHistoryPageSource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -45,6 +45,8 @@
case IJavaScriptElement.INITIALIZER:
case IJavaScriptElement.IMPORT_CONTAINER:
case IJavaScriptElement.IMPORT_DECLARATION:
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_DECLARATION:
return true;
}
return false;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaNode.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaNode.java
index 0c3ebdc..c8ba493 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaNode.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/compare/JavaNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,6 +36,8 @@
public static final int INIT= 9;
public static final int CONSTRUCTOR= 10;
public static final int METHOD= 11;
+ public static final int EXPORT_CONTAINER = 12;
+ public static final int EXPORT = 13;
private int fInitializerCount= 1;
@@ -100,6 +102,8 @@
return CompareMessages.JavaNode_initializer;
case IMPORT_CONTAINER:
return CompareMessages.JavaNode_importDeclarations;
+ case EXPORT_CONTAINER:
+ return CompareMessages.JavaNode_exportDeclarations;
case CU:
return CompareMessages.JavaNode_compilationUnit;
case PACKAGE:
@@ -134,6 +138,12 @@
case IMPORT_CONTAINER:
id= JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.IMPORT_CONTAINER);
break;
+ case EXPORT:
+ id = JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.EXPORT_DECLARATION);
+ break;
+ case EXPORT_CONTAINER:
+ id = JavaCompareUtilities.getImageDescriptor(IJavaScriptElement.EXPORT_CONTAINER);
+ break;
case CLASS:
id= JavaCompareUtilities.getTypeImageDescriptor(true);
break;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerPart.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerPart.java
index 1fe41be..003ff37 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerPart.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview/PackageExplorerPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1487,6 +1487,8 @@
switch (element2.getElementType()) {
case IJavaScriptElement.IMPORT_DECLARATION:
case IJavaScriptElement.IMPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ case IJavaScriptElement.EXPORT_CONTAINER:
case IJavaScriptElement.TYPE:
case IJavaScriptElement.METHOD:
case IJavaScriptElement.FIELD:
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaOutlineInformationControl.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaOutlineInformationControl.java
index 8cbe8e5..0ee010e 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaOutlineInformationControl.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/JavaOutlineInformationControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -215,7 +215,9 @@
TreeItem treeItem= (TreeItem)node;
if (treeItem.getParentItem() != null && treeItem.getData() instanceof IJavaScriptElement) {
IJavaScriptElement je= (IJavaScriptElement) treeItem.getData();
- if (je.getElementType() == IJavaScriptElement.IMPORT_CONTAINER || isInnerType(je)) {
+ if (je.getElementType() == IJavaScriptElement.IMPORT_CONTAINER
+ || je.getElementType() == IJavaScriptElement.EXPORT_CONTAINER
+ || isInnerType(je)) {
setExpanded(treeItem, false);
return;
}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ColoredJavaElementLabels.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ColoredJavaElementLabels.java
index 9ee81d5..4c0c108 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ColoredJavaElementLabels.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/ColoredJavaElementLabels.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -137,6 +137,8 @@
break;
case IJavaScriptElement.IMPORT_CONTAINER:
case IJavaScriptElement.IMPORT_DECLARATION:
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_DECLARATION:
getDeclarationLabel(element, flags, result);
break;
case IJavaScriptElement.JAVASCRIPT_PROJECT:
@@ -583,7 +585,9 @@
}
}
if (declaration.getElementType() == IJavaScriptElement.IMPORT_CONTAINER) {
- result.append(JavaUIMessages.JavaElementLabels_import_container);
+ result.append(JavaUIMessages.JavaElementLabels_import_container);
+ } else if (declaration.getElementType() == IJavaScriptElement.EXPORT_CONTAINER) {
+ result.append(JavaUIMessages.JavaElementLabels_export_container);
} else {
result.append(declaration.getElementName());
}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/JavaElementImageProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/JavaElementImageProvider.java
index 9ac1dd7..275316f 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/JavaElementImageProvider.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/viewsupport/JavaElementImageProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -198,6 +198,12 @@
case IJavaScriptElement.IMPORT_CONTAINER:
return JavaPluginImages.DESC_OBJS_IMPCONT;
+
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ return JavaPluginImages.DESC_OBJS_EXPDECL;
+
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ return JavaPluginImages.DESC_OBJS_EXPCONT;
case IJavaScriptElement.TYPE: {
IType type= (IType) element;
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementComparator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementComparator.java
index 7bda7ad..be13427 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementComparator.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -72,6 +72,9 @@
private static final int IMPORT_CONTAINER= 11;
private static final int IMPORT_DECLARATION= 12;
+ private static final int EXPORT_CONTAINER = 13;
+ private static final int EXPORT_DECLARATION = 14;
+
// Includes all categories ordered using the OutlineSortOrderPage:
// types, initializers, methods & fields
private static final int MEMBERSOFFSET= 15;
@@ -132,6 +135,10 @@
return IMPORT_CONTAINER;
case IJavaScriptElement.IMPORT_DECLARATION :
return IMPORT_DECLARATION;
+ case IJavaScriptElement.EXPORT_CONTAINER :
+ return EXPORT_CONTAINER;
+ case IJavaScriptElement.EXPORT_DECLARATION :
+ return EXPORT_DECLARATION;
case IJavaScriptElement.PACKAGE_FRAGMENT :
return PACKAGEFRAGMENT;
case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT :
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementLabels.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementLabels.java
index 8efa538..dcafcda 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementLabels.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementLabels.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -457,6 +457,8 @@
break;
case IJavaScriptElement.IMPORT_CONTAINER:
case IJavaScriptElement.IMPORT_DECLARATION:
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_DECLARATION:
getDeclarationLabel(element, flags, buf);
break;
case IJavaScriptElement.JAVASCRIPT_PROJECT:
@@ -889,7 +891,9 @@
}
}
if (declaration.getElementType() == IJavaScriptElement.IMPORT_CONTAINER) {
- buf.append(JavaUIMessages.JavaElementLabels_import_container);
+ buf.append(JavaUIMessages.JavaElementLabels_import_container);
+ } else if (declaration.getElementType() == IJavaScriptElement.EXPORT_CONTAINER) {
+ buf.append(JavaUIMessages.JavaElementLabels_export_container);
} else {
buf.append(declaration.getDisplayName());
}
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/PreferenceConstants.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/PreferenceConstants.java
index a14c65e..e426428 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/PreferenceConstants.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/PreferenceConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2990,6 +2990,16 @@
public static final String EDITOR_FOLDING_IMPORTS= "editor_folding_default_imports"; //$NON-NLS-1$
/**
+ * A named preference that stores the value for exports folding for the default folding provider.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ *
+ */
+ public static final String EDITOR_FOLDING_EXPORTS= "editor_folding_default_exports"; //$NON-NLS-1$
+
+ /**
* A named preference that stores the value for header comment folding for the default folding provider.
* <p>
* Value is of type <code>Boolean</code>.
@@ -3638,6 +3648,7 @@
store.setDefault(PreferenceConstants.EDITOR_FOLDING_INNERTYPES, false);
store.setDefault(PreferenceConstants.EDITOR_FOLDING_METHODS, false);
store.setDefault(PreferenceConstants.EDITOR_FOLDING_IMPORTS, true);
+ store.setDefault(PreferenceConstants.EDITOR_FOLDING_EXPORTS, true);
store.setDefault(PreferenceConstants.EDITOR_FOLDING_HEADERS, true);
// properties file editor
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/ProblemsLabelDecorator.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/ProblemsLabelDecorator.java
index 4b3dbd1..8745cb5 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/ProblemsLabelDecorator.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/ProblemsLabelDecorator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -180,6 +180,8 @@
return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
case IJavaScriptElement.IMPORT_DECLARATION:
case IJavaScriptElement.IMPORT_CONTAINER:
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ case IJavaScriptElement.EXPORT_CONTAINER:
case IJavaScriptElement.TYPE:
case IJavaScriptElement.INITIALIZER:
case IJavaScriptElement.METHOD:
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/text/folding/DefaultJavaFoldingStructureProvider.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/text/folding/DefaultJavaFoldingStructureProvider.java
index 1b7ee26..6143fae 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/text/folding/DefaultJavaFoldingStructureProvider.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/text/folding/DefaultJavaFoldingStructureProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,6 +41,8 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.jsdt.core.ElementChangedEvent;
import org.eclipse.wst.jsdt.core.IElementChangedListener;
+import org.eclipse.wst.jsdt.core.IExportContainer;
+import org.eclipse.wst.jsdt.core.IExportDeclaration;
import org.eclipse.wst.jsdt.core.IImportContainer;
import org.eclipse.wst.jsdt.core.IImportDeclaration;
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
@@ -188,6 +190,15 @@
public boolean collapseImportContainer() {
return fAllowCollapsing && fCollapseImportContainer;
}
+
+ /**
+ * Returns <code>true</code> if export containers should be collapsed.
+ *
+ * @return <code>true</code> if export containers should be collapsed
+ */
+ public boolean collapseExportContainer() {
+ return fAllowCollapsing && fCollapseExportContainer;
+ }
/**
* Returns <code>true</code> if inner types should be collapsed.
@@ -388,6 +399,15 @@
if (!(elem instanceof IImportDeclaration))
return false;
+ } else if (delta.getAffectedChildren().length == 1 &&
+ delta.getAffectedChildren()[0].getElement() instanceof IExportContainer) {
+ IJavaScriptElement elem= SelectionConverter.getElementAtOffset(
+ ast.getJavaElement(),
+ new TextSelection(editor.getCachedSelectedRange().x,
+ editor.getCachedSelectedRange().y));
+ if (!(elem instanceof IExportDeclaration))
+ return false;
+
}
} catch (JavaScriptModelException e) {
return false; // can't compute
@@ -690,6 +710,7 @@
/* preferences */
private boolean fCollapseJavadoc= false;
private boolean fCollapseImportContainer= true;
+ private boolean fCollapseExportContainer= true;
private boolean fCollapseInnerTypes= true;
private boolean fCollapseMembers= false;
private boolean fCollapseHeaderComments= true;
@@ -860,6 +881,7 @@
IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
fCollapseInnerTypes= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INNERTYPES);
fCollapseImportContainer= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_IMPORTS);
+ fCollapseExportContainer = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_EXPORTS);
fCollapseJavadoc= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_JAVADOC);
fCollapseMembers= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_METHODS);
fCollapseHeaderComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_HEADERS);
@@ -986,7 +1008,7 @@
* <li>true members (not for top-level types)</li>
* <li>the javadoc comments of any member</li>
* <li>header comments (javadoc or multi-line comments appearing before the first type's
- * javadoc or before the package or import declarations).</li>
+ * javadoc or before the package or import / export declarations).</li>
* </ul>
* </p>
*
@@ -1002,6 +1024,9 @@
case IJavaScriptElement.IMPORT_CONTAINER:
collapse= ctx.collapseImportContainer();
break;
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ collapse = ctx.collapseExportContainer();
+ break;
case IJavaScriptElement.TYPE:
collapseCode= isInnerType((IType) element);
collapse= ctx.collapseInnerTypes() && collapseCode;
@@ -1138,7 +1163,7 @@
* scan the header content up to the first type. Once a comment is
* found, accumulate any additional comments up to the stop condition.
* The stop condition is reaching a package declaration, import container,
- * or the end of the input.
+ * export container or the end of the input.
*/
IScanner scanner= ctx.getScanner();
scanner.resetTo(start, end);
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementProperties.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementProperties.java
index 69cd50f..3c1cd69 100644
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementProperties.java
+++ b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementProperties.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -597,6 +597,12 @@
case IJavaScriptElement.IMPORT_DECLARATION :
name= "IImportDeclaration";
break;
+ case IJavaScriptElement.EXPORT_CONTAINER:
+ name = "IExportContainer";
+ break;
+ case IJavaScriptElement.EXPORT_DECLARATION:
+ name = "IExportDeclaration";
+ break;
case IJavaScriptElement.LOCAL_VARIABLE :
name= "ILocalVariable";
break;
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/parser/TestSourceElementRequestor.java b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/parser/TestSourceElementRequestor.java
index c5ff6d8..141e23d 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/parser/TestSourceElementRequestor.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/parser/TestSourceElementRequestor.java
@@ -33,6 +33,10 @@
*/
public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand) {}
/**
+ * acceptExport method comment.
+ */
+public void acceptExport(int declarationStart, int declarationEnd, char[][] tokens) {}
+/**
* acceptLineSeparatorPositions method comment.
*/
public void acceptLineSeparatorPositions(int[] positions) {}
@@ -116,5 +120,9 @@
* exitType method comment.
*/
public void exitType(int declarationEnd) {}
+/* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.internal.compiler.ISourceElementRequestor#acceptExport(int, int, char[][])
+ */
+
}
diff --git a/webtools-jsdt/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportContainer.java b/webtools-jsdt/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportContainer.java
new file mode 100644
index 0000000..cd235e7
--- /dev/null
+++ b/webtools-jsdt/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportContainer.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2016, Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.core;
+
+
+/**
+ * Represents an export container; a child of a JavaScript unit that contains
+ * all (and only) the export declarations. If a JavaScript unit has no export
+ * declarations, no export container will be present.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ */
+public interface IExportContainer extends IJavaScriptElement, IParent, ISourceReference {
+ /**
+ * Returns the first export declaration in this export container with the given name.
+ * This is a handle-only method. The export declaration may or may not exist.
+ *
+ * @param name the given name
+ *
+ * @return the first export declaration in this export container with the given name
+ */
+ IExportDeclaration getExport(String name);
+}
diff --git a/webtools-jsdt/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportDeclaration.java b/webtools-jsdt/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportDeclaration.java
new file mode 100644
index 0000000..4a49bcd
--- /dev/null
+++ b/webtools-jsdt/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/IExportDeclaration.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.core;
+
+/**
+ * Represents an export declaration in JavaScript unit.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ */
+public interface IExportDeclaration extends IJavaScriptElement, ISourceReference, ISourceManipulation {
+ /**
+ * Returns the name that has been exported.
+ *
+ * @return the name that has been exported
+ */
+ String getElementName();
+}