summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpschonbac2009-02-21 18:32:56 (EST)
committer pschonbac2009-02-21 18:32:56 (EST)
commite9216b5ff47a1ebdee1f4f69a0aae89b30aa30cd (patch)
tree37b1d88d5376d515df6d0f9428c677f35c11e839
parentaa91aa99c2323362b8800d839a5409e512304f44 (diff)
downloadorg.eclipse.xpand-e9216b5ff47a1ebdee1f4f69a0aae89b30aa30cd.zip
org.eclipse.xpand-e9216b5ff47a1ebdee1f4f69a0aae89b30aa30cd.tar.gz
org.eclipse.xpand-e9216b5ff47a1ebdee1f4f69a0aae89b30aa30cd.tar.bz2
Merged changes from oAW 4.3.1
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java3
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java2
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/core/internal/builder/XpandResourceParser.java46
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java15
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/XpandEditor.java9
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandCommentRule.java78
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandPartitionScanner.java7
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/GeneratorAdvice.java26
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java2
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractXpandVisitor.java33
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java14
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java5
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java5
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java4
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java4
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java170
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java2
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java7
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java2
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java51
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java125
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java3
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java12
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java19
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java19
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java52
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java63
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java1
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java94
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoException.java3
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java8
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy2.java9
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/plugin.xml4
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/MetamodelContainer.java108
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IModelManager.java2
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IXtendXpandProject.java73
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/action/SelectionDispatchAction.java2
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandBuilder.java138
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandNature.java2
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/i18n/Messages.java6
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/JDTUtil.java4
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandModelManager.java12
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandProject.java26
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/Contributor.java26
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/MetamodelContributorRegistry.java87
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/JdtTypeImpl.java2
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/javabean/JdtJavaBeanTypeStrategy.java3
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/properties/MetamodelContributorsPropertyAndPreferencePage.java184
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/search/XtendXpandSearchEngine.java20
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/AbstractXtendXpandEditor.java14
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/IXpandXtendEditorActionDefinitionIds.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/IOawEditorActionDefinitionIds.java)4
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlink.java11
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlinkDetector.java11
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/outlineview/AbstractExtXptContentOutlinePage.java6
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/DeclarationsSearchGroup.java29
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindAction.java10
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindDeclarationsAction.java16
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindReferencesAction.java8
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/ReferencesSearchGroup.java25
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/SearchActionGroup.java2
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XpandXtendSearchDeclarationsQuery.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchDeclarationsQuery.java)8
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchQuery.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchQuery.java)12
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchReferencesQuery.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchReferencesQuery.java)8
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchResult.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchResult.java)10
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/EditorOpener.java53
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/XtendXpandSearchResultPage.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/OawSearchResultPage.java)22
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/XtendXpandTableContentProvider.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/OawTableContentProvider.java)22
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/AbstractExtXptContentAssistProcessor.java4
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java4
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/EclipseHelper.java6
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/XtendXpandProjectWizard.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/OawProjectWizard.java)61
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/XtendXpandProjectWizardPage.java (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/OawProjectWizardPage.java)8
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/example/generator.mwe (renamed from plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/example/generator.oaw)0
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java2
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java4
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/XtendXpandValidatorPluginTests.java (renamed from plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java)6
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/XtendXpandValidatorStandaloneTests.java (renamed from plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java)4
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/BuildJob.java21
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java150
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/ProjectAnalyzer.java69
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AbstractCoreModelTransformerAction.java102
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AddAnnotationsAction.java6
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java9
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java6
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java29
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java4
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java118
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java12
-rw-r--r--plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/core/internal/builder/PluginJavaExtensionStatement.java24
-rw-r--r--plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendEditor.java6
-rw-r--r--plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/scanning/XtendPartitionScanner.java6
-rw-r--r--plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java18
-rw-r--r--plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java20
-rw-r--r--plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SystemCommand.java32
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java94
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java3
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java50
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java7
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java2
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java141
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java15
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java8
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java11
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java1
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java20
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java104
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java30
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java13
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java13
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java126
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java1
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java4
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java10
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java3
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java2
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java2
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java20
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java168
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java94
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java115
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java43
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java52
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java2
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java29
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java18
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java1
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java24
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java15
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java20
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java5
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowAdvice.java4
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java2
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java60
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Callback.java6
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java2
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java2
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java66
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java10
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java1
-rw-r--r--tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/TestEnvironment.java2169
-rw-r--r--tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/ASTTest.java4
-rw-r--r--tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/AllPackageTests.java2
-rw-r--r--tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/Bug155018Test.java2
-rw-r--r--tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/XtendXpandProjectTest.java (renamed from tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/OawProjectTest.java)68
-rw-r--r--tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/emf/EmfXpandTest.java2
145 files changed, 3217 insertions, 3043 deletions
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java
index 13abaff..3d5e9ee 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java
@@ -88,8 +88,9 @@ public class XpandEditorPlugin extends AbstractUIPlugin {
public static Shell getActiveWorkbenchShell() {
final IWorkbenchWindow window = getActiveWorkbenchWindow();
- if (window != null)
+ if (window != null) {
return window.getShell();
+ }
return null;
}
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java
index 5e96382..821324d 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java
@@ -50,7 +50,7 @@ public class XpandPluginExecutionContext extends org.eclipse.xpand2.XpandExecuti
private IXtendXpandProject project;
public PluginResourceManager(final IXtendXpandProject project) {
- assert project != null;
+ assert project!=null;
this.project = project;
}
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/core/internal/builder/XpandResourceParser.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/core/internal/builder/XpandResourceParser.java
index eebdde9..d261c53 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/core/internal/builder/XpandResourceParser.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/core/internal/builder/XpandResourceParser.java
@@ -32,38 +32,41 @@ import org.eclipse.xtend.shared.ui.core.IXtendXpandResource;
public class XpandResourceParser extends ResourceContributorBase {
@Override
- public Resource parse(IStorage source, String fqn) {
+ public Resource parse(final IStorage source, final String fqn) {
Resource tpl = null;
- Reader reader = createReader(source);
+ final Reader reader = createReader(source);
if (reader == null)
return null;
try {
tpl = XpandParseFacade.file(reader, fqn, getErrorHandler(source));
- } finally {
+ }
+ finally {
try {
reader.close();
- } catch (final IOException e) {
+ }
+ catch (final IOException e) {
logError(e.getMessage(), e);
}
}
- if (tpl==null)
+ if (tpl == null)
return null;
tpl.setFullyQualifiedName(fqn);
return tpl;
}
@Override
- protected IXtendXpandResource createExtXptResource(Resource resource, IStorage source) {
+ protected IXtendXpandResource createExtXptResource(final Resource resource, final IStorage source) {
return new XpandResourceImpl((Template) resource, source, this);
}
@Override
- protected Reader createReader(IStorage resource) {
+ protected Reader createReader(final IStorage resource) {
InputStream in;
Reader reader;
try {
in = resource.getContents();
- } catch (final CoreException e1) {
+ }
+ catch (final CoreException e1) {
XpandLog.logInfo(e1.getMessage());
return null;
}
@@ -72,39 +75,38 @@ public class XpandResourceParser extends ResourceContributorBase {
String fileEncoding = ResourcesPlugin.getEncoding();
try {
if (resource instanceof IFile) {
- fileEncoding = ((IFile)resource).getCharset();
+ fileEncoding = ((IFile) resource).getCharset();
}
- } catch (CoreException e) {
- XpandLog
- .logError(
- "Could not get file encoding falling back to default...",
- e);
+ }
+ catch (final CoreException e) {
+ XpandLog.logError("Could not get file encoding falling back to default...", e);
}
if (fileEncoding == null) {
reader = new InputStreamReader(in);
- } else {
+ }
+ else {
try {
reader = new InputStreamReader(in, fileEncoding);
- } catch (UnsupportedEncodingException e) {
- XpandLog.logError(
- "Unsupported encoding falling back to default...",
- e);
+ }
+ catch (final UnsupportedEncodingException e) {
+ XpandLog.logError("Unsupported encoding falling back to default...", e);
reader = new InputStreamReader(in);
}
}
- } else {
+ }
+ else {
reader = new InputStreamReader(in);
}
return reader;
}
@Override
- protected void logError(String message, Throwable t) {
+ protected void logError(final String message, final Throwable t) {
XpandLog.logError(message, t);
}
@Override
- protected void logInfo(String message) {
+ protected void logInfo(final String message) {
XpandLog.logInfo(message);
}
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java
index f67ff7c..1c58ca7 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java
@@ -21,18 +21,7 @@ import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.mwe.ui.workflow.util.PluginConfigurationElementUtil;
-import org.eclipse.internal.xpand2.ast.AbstractDefinition;
-import org.eclipse.internal.xpand2.ast.ErrorStatement;
-import org.eclipse.internal.xpand2.ast.ExpandStatement;
-import org.eclipse.internal.xpand2.ast.ExpressionStatement;
-import org.eclipse.internal.xpand2.ast.FileStatement;
-import org.eclipse.internal.xpand2.ast.ForEachStatement;
-import org.eclipse.internal.xpand2.ast.IfStatement;
-import org.eclipse.internal.xpand2.ast.LetStatement;
-import org.eclipse.internal.xpand2.ast.ProtectStatement;
-import org.eclipse.internal.xpand2.ast.Statement;
-import org.eclipse.internal.xpand2.ast.Template;
-import org.eclipse.internal.xpand2.ast.TextStatement;
+import org.eclipse.internal.xpand2.ast.*;
import org.eclipse.internal.xpand2.debug.ExpandSpecial;
import org.eclipse.internal.xpand2.debug.ForEachSpecial;
import org.eclipse.internal.xpand2.debug.IfSpecial;
@@ -173,7 +162,7 @@ public class XpandPluginAdapter extends ExpressionPluginAdapter {
Expression sep = ((ExpandStatement) parent).getSeparator();
if(sep != null)
result.add(sep);
- }
+ }
// ExpressionStmt
else if (parent instanceof ExpressionStatement) {
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/XpandEditor.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/XpandEditor.java
index e317153..0285d78 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/XpandEditor.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/XpandEditor.java
@@ -45,15 +45,14 @@ public class XpandEditor extends AbstractXtendXpandEditor {
}
@Override
- protected void editorContextMenuAboutToShow(IMenuManager menu) {
+ protected void editorContextMenuAboutToShow(final IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
- ActionContext context = new ActionContext(getSelectionProvider().getSelection());
+ final ActionContext context = new ActionContext(getSelectionProvider().getSelection());
contextMenuRefactoringGroup.setContext(context);
contextMenuRefactoringGroup.fillContextMenu(menu);
contextMenuRefactoringGroup.setContext(null);
}
-
@Override
protected void createActions() {
@@ -66,7 +65,7 @@ public class XpandEditor extends AbstractXtendXpandEditor {
}
@Override
- protected Object handleGetObject(String key) {
+ protected Object handleGetObject(final String key) {
return null;
}
};
@@ -86,7 +85,7 @@ public class XpandEditor extends AbstractXtendXpandEditor {
public ActionGroup getActionGroup() {
return contextMenuRefactoringGroup;
}
-
+
@Override
protected void initializeKeyBindingScopes() {
setKeyBindingScopes(new String[] { "org.eclipse.internal.xtend.xpand2.editor.XpandEditorScope" }); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandCommentRule.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandCommentRule.java
index 938a4b7..f14f8b5 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandCommentRule.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandCommentRule.java
@@ -13,7 +13,7 @@ package org.eclipse.xpand.ui.editor.scanning;
import org.eclipse.internal.xpand2.codeassist.XpandTokens;
import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.Token;
@@ -22,45 +22,55 @@ import org.eclipse.jface.text.rules.Token;
*
*
*/
-public class XpandCommentRule implements IRule {
+public class XpandCommentRule implements IPredicateRule {
- private IToken token;
+ private final IToken token;
- /**
+ /**
*
*/
- public XpandCommentRule(final IToken token) {
- this.token = token;
- }
+ public XpandCommentRule(final IToken token) {
+ this.token = token;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
- */
- public IToken evaluate(final ICharacterScanner scanner) {
- final StringBuffer buff = new StringBuffer();
- boolean stopReading = false;
- int reads = 0;
- final String keyword = XpandTokens.REM + " ";
- while (!stopReading) {
- reads++;
- final char c = (char) scanner.read();
- if (buff.length() > 0 && XpandTokens.RT_CHAR == c) {
- if (buff.toString().startsWith(keyword)) {
- scanner.unread();
- return token;
- }
- }
- buff.append(c);
- stopReading = !(keyword.startsWith(buff.toString()) || buff.toString().startsWith(keyword));
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules
+ * .ICharacterScanner)
+ */
+ public IToken evaluate(final ICharacterScanner scanner) {
+ final StringBuffer buff = new StringBuffer();
+ boolean stopReading = false;
+ int reads = 0;
+ final String keyword = XpandTokens.REM + " ";
+ while (!stopReading) {
+ reads++;
+ final char c = (char) scanner.read();
+ if (buff.length() > 0 && XpandTokens.RT_CHAR == c) {
+ if (buff.toString().startsWith(keyword)) {
+ scanner.unread();
+ return token;
+ }
+ }
+ buff.append(c);
+ stopReading = !(keyword.startsWith(buff.toString()) || buff.toString().startsWith(keyword));
+
+ }
+
+ for (int i = 0; i < reads; i++) {
+ scanner.unread();
+ }
+ return Token.UNDEFINED;
+ }
- }
+ public IToken evaluate(final ICharacterScanner scanner, final boolean resume) {
+ return evaluate(scanner);
+ }
- for (int i = 0; i < reads; i++) {
- scanner.unread();
- }
- return Token.UNDEFINED;
- }
+ public IToken getSuccessToken() {
+ return token;
+ }
}
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandPartitionScanner.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandPartitionScanner.java
index 728302b..7b696d2 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandPartitionScanner.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/editor/scanning/XpandPartitionScanner.java
@@ -40,10 +40,13 @@ public class XpandPartitionScanner extends RuleBasedPartitionScanner {
final List<IRule> rules = new ArrayList<IRule>();
// TODO we need to handle whitespace like this: '<< REM .... ENDREM >>'
- rules.add(new MultiLineRule(XpandTokens.LT + XpandTokens.REM, XpandTokens.ENDREM + XpandTokens.RT, comment));
+ rules.add(new MultiLineRule(XpandTokens.LT + XpandTokens.REM, XpandTokens.ENDREM + XpandTokens.RT, comment,
+ (char) 0, true));
+ rules.add(new MultiLineRule(XpandTokens.LT + XpandTokens.REM, XpandTokens.ENDREM + "-" + XpandTokens.RT,
+ comment, (char) 0, true));
rules.add(new MultiLineRule(XpandTokens.LT, XpandTokens.RT, tag));
- setPredicateRules((IPredicateRule[]) rules.toArray(new IPredicateRule[rules.size()]));
+ setPredicateRules(rules.toArray(new IPredicateRule[rules.size()]));
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/GeneratorAdvice.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/GeneratorAdvice.java
index 6e5c2a4..de6f226 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/GeneratorAdvice.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/GeneratorAdvice.java
@@ -78,11 +78,11 @@ public class GeneratorAdvice extends AbstractExpressionsUsingWorkflowAdvice {
/** Component name. */
private static final String COMPONENT_NAME = "Xpand Generator Advice";
- /** Xpand template advices. */
- private List<String> advices = new ArrayList<String>();
+ /** Xpand template advices. */
+ private final List<String> advices = new ArrayList<String>();
/** Xtend extension advices. */
- private List<String> extensionAdvices = new ArrayList<String>();
+ private final List<String> extensionAdvices = new ArrayList<String>();
/** File encoding for reading templates. */
private String fileEncoding;
@@ -93,7 +93,7 @@ public class GeneratorAdvice extends AbstractExpressionsUsingWorkflowAdvice {
* @param advice
* the advice
*/
- public void addAdvice(String advice) {
+ public void addAdvice(final String advice) {
this.advices.add(advice);
}
@@ -103,7 +103,7 @@ public class GeneratorAdvice extends AbstractExpressionsUsingWorkflowAdvice {
* @param extensionAdvice
* the extension advice
*/
- public void addExtensionAdvice(String extensionAdvice) {
+ public void addExtensionAdvice(final String extensionAdvice) {
this.extensionAdvices.add(extensionAdvice);
}
@@ -113,15 +113,15 @@ public class GeneratorAdvice extends AbstractExpressionsUsingWorkflowAdvice {
* @param fileEncoding
* Encoding string, e.g. 'ISO-8859-1'
*/
- public void setFileEncoding(String fileEncoding) {
+ public void setFileEncoding(final String fileEncoding) {
this.fileEncoding = fileEncoding;
}
/**
- * @see org.eclipse.emf.mwe.core.ao.AbstractWorkflowAdvice#checkConfiguration(org.openarchitectureware.workflow.issues.Issues)
+ * @see org.eclipse.emf.mwe.core.ao.AbstractWorkflowAdvice#checkConfiguration(org.eclipse.emf.mwe.core.issues.Issues)
*/
@Override
- public void checkConfiguration(Issues issues) {
+ public void checkConfiguration(final Issues issues) {
super.checkConfiguration(issues);
if (advices.isEmpty() && extensionAdvices.isEmpty()) {
issues.addError("Neither 'advices' nor 'extensionAdvices' configured.");
@@ -129,21 +129,21 @@ public class GeneratorAdvice extends AbstractExpressionsUsingWorkflowAdvice {
}
/**
- * @see org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowAdvice#weave(org.openarchitectureware.workflow.WorkflowComponent,
+ * @see org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowAdvice#weave(org.eclipse.emf.mwe.core.WorkflowComponent,
* org.eclipse.emf.mwe.core.issues.Issues)
*/
@Override
- public void weave(WorkflowComponent c, Issues issues) {
+ public void weave(final WorkflowComponent c, final Issues issues) {
super.weave(c, issues);
if (!(c instanceof Generator)) {
issues.addError(this, "advice target is not a Generator component.");
}
else {
- Generator gen = (Generator) c;
- for (String advice : advices) {
+ final Generator gen = (Generator) c;
+ for (final String advice : advices) {
gen.addAdvice(advice);
}
- for (String advice : extensionAdvices) {
+ for (final String advice : extensionAdvices) {
gen.addExtensionAdvice(advice);
}
if (fileEncoding != null) {
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java
index 7f99e64..4a6490c 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java
@@ -40,7 +40,7 @@ public abstract class AbstractDefinition extends SyntaxElement implements XpandD
private Statement[] body;
- private String _stringRepresentation = null;
+ protected String _stringRepresentation = null;
protected boolean wildParams = false;
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractXpandVisitor.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractXpandVisitor.java
index 5e56b24..4997dea 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractXpandVisitor.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractXpandVisitor.java
@@ -17,9 +17,8 @@ import org.eclipse.internal.xtend.expression.ast.AbstractVisitor;
import org.eclipse.internal.xtend.expression.ast.ISyntaxElement;
import org.eclipse.internal.xtend.expression.ast.SyntaxElement;
-public class AbstractXpandVisitor extends AbstractVisitor {
+public class AbstractXpandVisitor extends AbstractVisitor{
- @Override
public final Object visit(final ISyntaxElement ele) {
Object result = null;
@@ -65,12 +64,12 @@ public class AbstractXpandVisitor extends AbstractVisitor {
return result;
}
- protected void visitChild(final SyntaxElement child) {
+ protected void visitChild(final SyntaxElement child){
if(child != null)
child.accept(this);
}
- protected void visitChildren(final List<? extends SyntaxElement> children) {
+ protected void visitChildren(final List<? extends SyntaxElement> children){
if (children != null) {
for (SyntaxElement child : children) {
visitChild(child);
@@ -78,64 +77,64 @@ public class AbstractXpandVisitor extends AbstractVisitor {
}
}
- protected Object visitAdvice(Advice node) {
+ protected Object visitAdvice(Advice node){
visitChildren(node.getBodyAsList());
return node;
}
- protected Object visitDefinition(Definition node) {
+ protected Object visitDefinition(Definition node){
visitChildren(node.getBodyAsList());
return node;
}
- protected Object visitErrorStatement(ErrorStatement node) {
+ protected Object visitErrorStatement(ErrorStatement node){
return node;
}
- protected Object visitExpandStatement(ExpandStatement node) {
+ protected Object visitExpandStatement(ExpandStatement node){
return node;
}
- protected Object visitExpressionStatement(ExpressionStatement node) {
+ protected Object visitExpressionStatement(ExpressionStatement node){
return node;
}
- protected Object visitFileStatement(FileStatement node) {
+ protected Object visitFileStatement(FileStatement node){
visitChildren(node.getBodyAsList());
return node;
}
- protected Object visitForEachStatement(ForEachStatement node) {
+ protected Object visitForEachStatement(ForEachStatement node){
visitChildren(node.getBodyAsList());
return node;
}
- protected Object visitIfStatement(IfStatement node) {
+ protected Object visitIfStatement(IfStatement node){
visitChildren(node.getBodyAsList());
visitChild(node.getElseIf());
return node;
}
- protected Object visitImportDeclaration(ImportDeclaration node) {
+ protected Object visitImportDeclaration(ImportDeclaration node){
return node;
}
- protected Object visitLetStatement(LetStatement node) {
+ protected Object visitLetStatement(LetStatement node){
visitChildren(node.getBodyAsList());
return node;
}
- protected Object visitProtectStatement(ProtectStatement node) {
+ protected Object visitProtectStatement(ProtectStatement node){
visitChildren(node.getBodyAsList());
return node;
}
- protected Object visitTemplate(Template node) {
+ protected Object visitTemplate(Template node){
visitChildren(Arrays.asList(node.getAllDefinitions()));
return node;
}
- protected Object visitTextStatement(TextStatement node) {
+ protected Object visitTextStatement(TextStatement node){
return node;
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java
index d48f094..9c808db 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java
@@ -50,10 +50,6 @@ public class Advice extends AbstractDefinition implements XpandAdvice {
private Pattern p = null;
- public boolean isWildcardParams () {
- return wildParams;
- }
-
public boolean matches(final XpandDefinition def, XpandExecutionContext ctx) {
if (p == null) {
p = Pattern.compile(getName().replaceAll("\\*", ".*"));
@@ -88,4 +84,14 @@ public class Advice extends AbstractDefinition implements XpandAdvice {
return "AROUND";
}
+ @Override
+ public String toString() {
+ if (_stringRepresentation == null) {
+ _stringRepresentation = getOwner().getFullyQualifiedName() + ": " + getName() + getParamString(false)
+ + " : " + getType().getValue();
+ }
+
+ return _stringRepresentation;
+ }
+
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java
index d1144aa..45dbd99 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java
@@ -26,7 +26,7 @@ public class ErrorStatement extends Statement {
private final Expression message;
- public ErrorStatement(final Expression msg) {
+ public ErrorStatement( final Expression msg) {
message = msg;
}
@@ -34,8 +34,7 @@ public class ErrorStatement extends Statement {
public void analyzeInternal(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) {
if (message != null) {
message.analyze(ctx, issues);
- }
- else {
+ } else {
issues.add(new AnalysationIssue(AnalysationIssue.SYNTAX_ERROR, "Error message required", this));
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java
index 80e596a..88d1816 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java
@@ -83,10 +83,9 @@ public class FileStatement extends StatementWithBody {
body[i].evaluate(ctx);
}
ctx.getOutput().closeFile();
- }
- catch (VetoException e) {
+ } catch (VetoException e) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Generation of file '" + fileName + "' on outlet '" + outletName + "' skipped due to veto.");
+ LOG.debug("Generation of file '"+fileName+"' on outlet '"+outletName+"' skipped due to veto.");
}
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java
index 9763319..bad90a1 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java
@@ -98,8 +98,6 @@ public class ForEachStatement extends StatementWithBody {
}
}
- static String indent = "";
-
@Override
public void evaluateInternal(XpandExecutionContext ctx) {
Object o = getTarget().evaluate(ctx);
@@ -115,7 +113,6 @@ public class ForEachStatement extends StatementWithBody {
if (iteratorName != null) {
ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(iteratorName.getValue(), iterator));
}
- indent += " ";
for (final Iterator<?> iter = col.iterator(); iter.hasNext();) {
final Object element = iter.next();
ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(getVariable().getValue(), element));
@@ -129,7 +126,6 @@ public class ForEachStatement extends StatementWithBody {
}
iterator.increment();
}
- indent = indent.substring(2);
}
@Override
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java
index 657d070..ba1fe90 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java
@@ -103,8 +103,4 @@ public class IfStatement extends StatementWithBody {
}
}
- public Statement getUpperIf() {
- return upperIf;
- }
-
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java
index 525b44a..06c135b 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java
@@ -27,88 +27,92 @@ import org.eclipse.xtend.expression.EvaluationException;
*/
public class ProtectStatement extends StatementWithBody {
- private Expression commentStart;
-
- private Expression commentEnd;
-
- private Expression id;
-
- private boolean disable;
-
- public ProtectStatement( final Expression commentStart,
- final Expression commentEnd, final Statement[] body, final Expression id, final boolean disable) {
- super(body);
- this.commentStart = commentStart;
- this.commentEnd = commentEnd;
- this.id = id;
- this.disable = disable;
- }
-
- public Expression getCommentEnd() {
- return commentEnd;
- }
-
- public Expression getCommentStart() {
- return commentStart;
- }
-
- public Expression getId() {
- return id;
- }
-
- public boolean getDisable () {
- return disable;
- }
-
- public void analyzeInternal(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) {
- getCommentStart().analyze(ctx, issues);
- getCommentEnd().analyze(ctx, issues);
- getId().analyze(ctx, issues);
-
- for (int i = 0; i < body.length; i++) {
- body[i].analyze(ctx, issues);
- }
- }
-
- @Override
- public void evaluateInternal(final XpandExecutionContext ctx) {
- final String cStart = nullSafe(getCommentStart().evaluate(ctx));
- if (cStart == null)
- throw new EvaluationException("NullEvaluation!", getCommentStart(), ctx);
- final String cEnd = nullSafe(getCommentEnd().evaluate(ctx));
- if (cEnd == null)
- throw new EvaluationException("NullEvaluation!", getCommentEnd(), ctx);
- final String id = nullSafe(getId().evaluate(ctx));
- if (id == null)
- throw new EvaluationException("NullEvaluation!", getId(), ctx);
-
- ProtectedRegion region = null;
- if (ctx.getProtectedRegionResolver() != null) {
- region = ctx.getProtectedRegionResolver().getProtectedRegion(id.toString());
- } else
- throw new EvaluationException("No protected region resolver configured!",this,ctx);
-
- if (region == null) {
- region = ctx.getProtectedRegionResolver().createProtectedRegion(id, disable);
- ctx.getOutput().write(region.getStartString(cStart, cEnd));
- for (int i = 0; i < body.length; i++) {
- body[i].evaluate(ctx);
- }
- ctx.getOutput().write(region.getEndString(cStart, cEnd));
- } else {
- ctx.getOutput().write(region.getStartString(cStart, cEnd));
- try {
- ctx.getOutput().write(region.getBody(cStart, cEnd));
- } catch (final ProtectedRegionSyntaxException e) {
- throw new EvaluationException(e.getMessage(), getId(), ctx);
- }
- ctx.getOutput().write(region.getEndString(cStart, cEnd));
- }
-
- }
-
- private String nullSafe(final Object string) {
- return string != null ? string.toString() : "";
- }
+ private final Expression commentStart;
+
+ private final Expression commentEnd;
+
+ private final Expression id;
+
+ private final boolean disable;
+
+ public ProtectStatement(final Expression commentStart, final Expression commentEnd, final Statement[] body,
+ final Expression id, final boolean disable) {
+ super(body);
+ this.commentStart = commentStart;
+ this.commentEnd = commentEnd;
+ this.id = id;
+ this.disable = disable;
+ }
+
+ public Expression getCommentEnd() {
+ return commentEnd;
+ }
+
+ public Expression getCommentStart() {
+ return commentStart;
+ }
+
+ public Expression getId() {
+ return id;
+ }
+
+ public boolean getDisable() {
+ return disable;
+ }
+
+ @Override
+ public void analyzeInternal(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ getCommentStart().analyze(ctx, issues);
+ getCommentEnd().analyze(ctx, issues);
+ getId().analyze(ctx, issues);
+
+ for (final Statement element : body) {
+ element.analyze(ctx, issues);
+ }
+ }
+
+ @Override
+ public void evaluateInternal(final XpandExecutionContext ctx) {
+ final String cStart = nullSafe(getCommentStart().evaluate(ctx));
+ if (cStart == null)
+ throw new EvaluationException("NullEvaluation!", getCommentStart(), ctx);
+ final String cEnd = nullSafe(getCommentEnd().evaluate(ctx));
+ if (cEnd == null)
+ throw new EvaluationException("NullEvaluation!", getCommentEnd(), ctx);
+ final String id = nullSafe(getId().evaluate(ctx));
+ if (id == null)
+ throw new EvaluationException("NullEvaluation!", getId(), ctx);
+
+ ProtectedRegion region = null;
+ if (ctx.getProtectedRegionResolver() != null) {
+ region = ctx.getProtectedRegionResolver().getProtectedRegion(id.toString());
+ }
+ else
+ throw new EvaluationException("No protected region resolver configured!", this, ctx);
+
+ if (region == null) {
+ region = ctx.getProtectedRegionResolver().createProtectedRegion(id, disable);
+ ctx.getOutput().write(region.getStartString(cStart, cEnd));
+ for (final Statement element : body) {
+ element.evaluate(ctx);
+ }
+ ctx.getOutput().write(region.getEndString(cStart, cEnd));
+ }
+ else {
+ ctx.getOutput().write(region.getStartString(cStart, cEnd));
+ try {
+ ctx.getOutput().write(region.getBody(cStart, cEnd));
+ }
+ catch (final ProtectedRegionSyntaxException e) {
+ throw new EvaluationException(e.getMessage(), getId(), ctx);
+ }
+ ctx.getOutput().write(region.getEndString(cStart, cEnd));
+ }
+
+ }
+
+ private String nullSafe(final Object string) {
+ return string != null ? string.toString() : "";
+ }
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java
index 044d71c..456325e 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java
@@ -50,7 +50,7 @@ public abstract class Statement extends SyntaxElement implements XpandAnalyzable
}
}
- public void analyze(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ public final void analyze(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) {
try {
if (ctx.getCallback() != null) {
ctx.getCallback().pre(this, ctx);
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java
index 9994307..87e59b1 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java
@@ -48,9 +48,9 @@ public class Template extends SyntaxElement implements XpandResource {
return extensions;
}
- public List<String> getImportedExtensionsAsList () {
+ public List<String> getImportedExtensionsAsList() {
final List<String> result = new ArrayList<String>();
- for (ImportDeclaration ext: extensions) {
+ for (ImportDeclaration ext : extensions) {
result.add(ext.getImportString().getValue());
}
return result;
@@ -91,7 +91,7 @@ public class Template extends SyntaxElement implements XpandResource {
l.addAll(Arrays.asList(definitions));
l.addAll(Arrays.asList(advices));
- Collections.sort(l,new Comparator<SyntaxElement>() {
+ Collections.sort(l, new Comparator<SyntaxElement>() {
public int compare(SyntaxElement o1, SyntaxElement o2) {
return new Integer(o1.getStart()).compareTo(o2.getStart());
@@ -121,6 +121,7 @@ public class Template extends SyntaxElement implements XpandResource {
for (int i = 0; i < definitions.length; i++) {
definitions[i].analyze(ctx, issues);
}
+
for (int i = 0; i < advices.length; i++) {
advices[i].analyze(ctx, issues);
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java
index 38bb147..f445bb8 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java
@@ -82,7 +82,7 @@ public class AdvicedDefinition implements XpandDefinition {
return advice.getFileName();
}
- public String getNameString(ExecutionContext context) {
+ public String getNameString(ExecutionContext context){
return advice.getNameString(context);
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java
index 5dd9216..9e34a91 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java
@@ -26,69 +26,68 @@ import org.eclipse.internal.xtend.xtend.parser.XtendError;
public final class XpandParseFacade {
private XpandParseFacade() {
}
-
- public static Template file(Reader r, String fileName) {
- return file(r,fileName,null);
+
+ public static Template file(final Reader r, final String fileName) {
+ return file(r, fileName, null);
}
- public static Template file(Reader r, String fileName,
- ErrorHandler handler) {
+ public static Template file(final Reader r, final String fileName, final ErrorHandler handler) {
ANTLRReaderStream readerStream;
try {
readerStream = new ANTLRReaderStream(r);
- } catch (IOException e2) {
+ }
+ catch (final IOException e2) {
throw new RuntimeException(e2);
}
final ErrorHandler h = getErrorHandler(handler);
try {
return getParser(fileName, readerStream, h).template();
- } catch (final RecognitionException e) {
+ }
+ catch (final RecognitionException e) {
h.handleError(createError(e, ""));
}
return null;
}
- private static XpandLocationAddingParser getParser(String fileName, ANTLRReaderStream readerStream, final ErrorHandler h) {
- XpandLexer lex = new XpandLexer(readerStream) {
+ private static XpandLocationAddingParser getParser(final String fileName, final ANTLRReaderStream readerStream,
+ final ErrorHandler h) {
+ final XpandLexer lex = new XpandLexer(readerStream) {
@Override
- public void reportError(RecognitionException e) {
- h.handleError(createError(e, this.getErrorMessage(e, this
- .getTokenNames())));
+ public void reportError(final RecognitionException e) {
+ h.handleError(createError(e, getErrorMessage(e, getTokenNames())));
}
};
- CommonTokenStream str = new CommonTokenStream();
+ final CommonTokenStream str = new CommonTokenStream();
str.setTokenSource(lex);
- XpandLocationAddingParser parser = new XpandLocationAddingParser(str,
- fileName) {
+ final XpandLocationAddingParser parser = new XpandLocationAddingParser(str, fileName) {
@Override
- public void reportError(RecognitionException e) {
- h.handleError(createError(e, this.getErrorMessage(e, this
- .getTokenNames())));
+ public void reportError(final RecognitionException e) {
+ h.handleError(createError(e, getErrorMessage(e, getTokenNames())));
}
};
return parser;
}
private static ErrorHandler getErrorHandler(ErrorHandler handler) {
- if (handler == null)
+ if (handler == null) {
handler = new ErrorHandler() {
- public void handleError(XtendError e) {
+ public void handleError(final XtendError e) {
throw new ParseException(e);
}
};
+ }
final ErrorHandler h = handler;
return h;
}
- protected static XtendError createError(RecognitionException e, String string) {
- if (e.token == null) {
+ protected static XtendError createError(final RecognitionException e, final String string) {
+ if (e.token == null)
return new SyntaxError(e.index, e.line, e.index + 1, string);
- } else {
- CommonToken t = (CommonToken) e.token;
- return new SyntaxError(t.getStartIndex(), t.getStopIndex(), t
- .getLine(), string);
+ else {
+ final CommonToken t = (CommonToken) e.token;
+ return new SyntaxError(t.getStartIndex(), t.getStopIndex(), t.getLine(), string);
}
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java
index 346c29f..716b843 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java
@@ -82,8 +82,7 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
if (body == null) {
try {
body = FSIO.readSingleFile(file, fileEncoding).substring(startIndex, endIndex);
- }
- catch (final IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException("Unexpected I/O exception (source files removed?)", e);
}
}
@@ -141,8 +140,7 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
try {
return (startComment + PROTECT_BEGIN + PROTECT_B64_BEFORE_ID + BASE64.toString(id)
+ PROTECT_B64_AFTER_ID + " " + (!disabled ? ENABLED + " " : "") + PROTECT_START_END + endComment);
- }
- catch (final IOException ie) {
+ } catch (final IOException ie) {
// fallback to old style if BASE64Encoder fails
}
}
@@ -188,25 +186,19 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
private Map<String, ProtectedRegionImpl> regionMap = null;
/**
- * All already queried Protected Region Ids. Is used for detecting ambigious
- * usage of Protected Regions.
+ * All already queried Protected Region Ids. Is used for detecting ambigious usage of
+ * Protected Regions.
*/
private Set<String> usedSet = null;
/**
* Retrieves all Protected Regions from a source file.
- *
- * @param file
- * The source file to scan.
+ * @param file The source file to scan.
* @return All found Protected Regions in the specified file.
- * @throws ProtectedRegionSyntaxException
- * If one of the Protected Regions in the file is incomplete or
- * invalid.
- * @throws IOException
- * On errors occuring when reading the file
+ * @throws ProtectedRegionSyntaxException If one of the Protected Regions in the file is incomplete or invalid.
+ * @throws IOException On errors occuring when reading the file
*/
- protected Collection<ProtectedRegionImpl> getAllRegions(final File file) throws ProtectedRegionSyntaxException,
- IOException {
+ protected Collection<ProtectedRegionImpl> getAllRegions(final File file) throws ProtectedRegionSyntaxException, IOException {
final List<ProtectedRegionImpl> regions = new ArrayList<ProtectedRegionImpl>();
final String source = FSIO.readSingleFile(file, encoding);
@@ -249,8 +241,7 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
if (isB64) {
try {
id = new String(BASE64.toByteArray(id));
- }
- catch (final IOException ie) {
+ } catch (final IOException ie) {
throw new ProtectedRegionSyntaxException("Protected region Id at index " + start + " in file '"
+ file + "' is incomplete", ie);
}
@@ -266,7 +257,7 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
if (!(type.equals("") || type.equals(ENABLED)))
throw new ProtectedRegionSyntaxException("Protected region start at index " + start + " in file "
- + file + " has illegal type '" + type + "'");
+ + file + " has illegal type '" + type+ "'");
if (type.equals(ENABLED)) {
final String body = new String(source.substring(startEnd + startEndLength, end));
regions.add(new ProtectedRegionImpl(id, false, file, encoding, useBASE64, startEnd + startEndLength,
@@ -284,9 +275,9 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
public ProtectedRegion getProtectedRegion(final String id) {
init();
- // if (!usedSet.isEmpty()) { // Fix:No error if Handle is not used
- // return null;
- // }
+// if (!usedSet.isEmpty()) { // Fix:No error if Handle is not used
+// return null;
+// }
if (!usedSet.add(id)) {
// id was not added to usedSet -> id was already queried before!
log.warn("Protected region with ID '" + id + "' referenced more than once");
@@ -296,26 +287,23 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
}
/**
- * Initializes the ProtectedRegionResolver. This starts the scan over all
- * configured paths (property 'srcPaths').
+ * Initializes the ProtectedRegionResolver. This starts the scan over all configured paths (property 'srcPaths').
* <p>
- * A second call (already initialized) to this method will return
- * immediately.
+ * A second call (already initialized) to this method will return immediately.
*
- * @throws IllegalStateException
- * If a Protected Region Id is detected the second time, i.e. it
- * is not unique.
+ * @throws IllegalStateException If a Protected Region Id is detected the second time, i.e. it is not unique.
*/
public void init() throws IllegalStateException {
// Already initialized?
- if (regionMap != null)
+ if (regionMap != null) {
return;
+ }
// Initialize the Protected Region map
regionMap = new HashMap<String, ProtectedRegionImpl>();
usedSet = new HashSet<String>();
- if (srcPaths == null) {
+ if (srcPaths==null) {
log.warn("No source paths configured for scanning.");
// abort
return;
@@ -335,8 +323,7 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
// Scan all configured paths
for (int i = 0; i < srcPaths.length; i += 1) {
try {
- // retrieve (recursive) all files from a path matching the
- // configured filter
+ // retrieve (recursive) all files from a path matching the configured filter
final File[] files = FSIO.getAllFiles(srcPaths[i], filter);
fileCount += files.length;
@@ -351,18 +338,18 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
final String id = region.getId();
// check for non-uniqueness of a Protected Region Id
- if (regionMap.containsKey(id))
- throw new IllegalStateException("Id '" + id + "' occuring in files " + region.getFile()
- + " and " + regionMap.get(id).getFile() + " is not unique");
+ if (regionMap.containsKey(id)) {
+ throw new IllegalStateException ("Id '" + id + "' occuring in files " + region.getFile()
+ + " and " + regionMap.get(id).getFile()
+ + " is not unique");
+ }
// Store this region
regionMap.put(id, region);
}
}
- }
- catch (final IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException("Unexpected I/O exception", e);
- }
- catch (final ProtectedRegionSyntaxException e) {
+ } catch (final ProtectedRegionSyntaxException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
@@ -378,11 +365,8 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
}
/**
- * Dumps all known protected regions to files. For each protected region a
- * file is created.
- *
- * @param dumpPath
- * Directory where the dump files are created within.
+ * Dumps all known protected regions to files. For each protected region a file is created.
+ * @param dumpPath Directory where the dump files are created within.
*/
public void reportRegions(final File dumpPath) {
final int unused = regionMap.size() - usedSet.size();
@@ -411,8 +395,7 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
if (encoding == null) {
writer = new FileWriter(file);
- }
- else {
+ } else {
writer = new OutputStreamWriter(new FileOutputStream(file), encoding);
}
@@ -422,11 +405,9 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
writer.close();
}
- }
- catch (final IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException("Unexpected I/O exception", e);
- }
- catch (final ProtectedRegionSyntaxException e) {
+ } catch (final ProtectedRegionSyntaxException e) {
log.error(e.getMessage(), e);
}
}
@@ -435,13 +416,9 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
}
/**
- * This flag determines whether default file exclusion patterns should be
- * used.
- *
- * @param defaultExcludes
- * <code>true</code>: Use default file exclusion patterns,
- * <code>false</code>: ignore them, just use the patterns
- * specified by {@link #setIgnoreList(String) ignoreList}
+ * This flag determines whether default file exclusion patterns should be used.
+ * @param defaultExcludes <code>true</code>: Use default file exclusion patterns, <code>false</code>: ignore them, just use
+ * the patterns specified by {@link #setIgnoreList(String) ignoreList}
* @see Xpand reference manual
*/
public void setDefaultExcludes(final boolean defaultExcludes) {
@@ -450,20 +427,16 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
/**
* Sets the file encoding to be used when reading files.
- *
- * @param encoding
- * A valid encoding string.
+ * @param encoding A valid encoding string.
*/
public void setFileEncoding(final String encoding) {
this.encoding = encoding;
}
/**
- * Sets a custom list of file patterns that should be filtered during
- * scanning of source files and directories.
- *
- * @param ignoreList
- * A comma separated list of file patterns to ignore during scan.
+ * Sets a custom list of file patterns that should be filtered during scanning of source files
+ * and directories.
+ * @param ignoreList A comma separated list of file patterns to ignore during scan.
*/
public void setIgnoreList(final String ignoreList) {
this.ignoreList = ignoreList;
@@ -471,20 +444,15 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
/**
* Sets the source paths that should be scanned.
- *
- * @param srcPathsAsString
- * A comma separated list of directory paths.
- * @throws IllegalArgumentException
- * If one of the passed arguments is not a directory or does not
- * exist
+ * @param srcPathsAsString A comma separated list of directory paths.
+ * @throws IllegalArgumentException If one of the passed arguments is not a directory or does not exist
*/
public void setSrcPathes(final String srcPathsAsString) throws IllegalArgumentException {
// Split the paths and initialize the
// file array 'srcPaths' from it
if ("".equals(srcPathsAsString)) {
this.srcPaths = new File[0];
- }
- else {
+ } else {
final String[] s = srcPathsAsString.split(",");
final List<File> validPaths = new ArrayList<File>(s.length);
for (int i = 0; i < s.length; i++) {
@@ -492,14 +460,11 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver {
// The configured path must point to an existing directory
if (dir.isDirectory()) {
validPaths.add(dir);
- }
- else {
- final String msg = "Ignoring non-existing protected region path " + dir.getAbsolutePath();
- LOG.warn(msg);
- throw new IllegalArgumentException(msg);
+ } else {
+ LOG.warn("Ignoring non-existing protected region path "+dir.getAbsolutePath());
}
}
- this.srcPaths = validPaths.toArray(new File[] {});
+ this.srcPaths = validPaths.toArray(new File[]{});
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java
index bfa13d7..42427ee 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java
@@ -88,7 +88,7 @@ public class XpandTypesMetaModel implements MetaModel {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object arg0) {
+ public boolean equals(final Object arg0) {
return arg0 instanceof XpandTypesMetaModel;
}
@@ -106,5 +106,4 @@ public class XpandTypesMetaModel implements MetaModel {
public Set<String> getNamespaces() {
return new HashSet<String>();
}
-
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java
index 26601b8..6a6698e 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java
@@ -39,7 +39,6 @@ import org.eclipse.xpand2.output.Output;
import org.eclipse.xpand2.output.OutputImpl;
import org.eclipse.xpand2.output.PostProcessor;
import org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent;
-import org.eclipse.xtend.expression.ExceptionHandler;
import org.eclipse.xtend.expression.Variable;
import org.eclipse.xtend.typesystem.MetaModel;
@@ -69,9 +68,8 @@ public class Generator extends AbstractExpressionsUsingWorkflowComponent {
private boolean automaticHyphens = false;
- private ExceptionHandler exceptionHandler = null;
-
private String collectProfileSummary = null;
+
private String verboseProfileFilename = null;
private Output output = null;
@@ -113,12 +111,12 @@ public class Generator extends AbstractExpressionsUsingWorkflowComponent {
*/
@Override
public String getLogMessage() {
- Set<String> outletDescriptions = new HashSet<String>();
- for (Outlet outlet : outlets) {
+ final Set<String> outletDescriptions = new HashSet<String>();
+ for (final Outlet outlet : outlets) {
outletDescriptions.add(outlet.toString());
}
- String outletDesc = outletDescriptions.size() == 1 ? outletDescriptions.iterator().next() : outletDescriptions
- .toString();
+ final String outletDesc = outletDescriptions.size() == 1 ? outletDescriptions.iterator().next()
+ : outletDescriptions.toString();
return "generating '" + expand + "' => " + outletDesc;
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
index 6454bbd..860df8a 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
@@ -36,23 +36,16 @@ public class XpandFacade {
/**
* @deprecated use XpandFacade.create instead
*/
- @Deprecated
public XpandFacade(final XpandExecutionContext ctx) {
this.ctx = ctx;
}
public void evaluate(final String definitionName, final Object targetObject, Object... params) {
- evaluate2(definitionName, targetObject, params!=null ? Arrays.asList(params) : null);
- }
-
- public void evaluate2(final String definitionName, final Object targetObject, List<Object> paramList) {
- if (paramList==null)
- paramList = Collections.emptyList();
+ params = params == null ? new Object[0] : params;
final Type targetType = ctx.getType(targetObject);
- final Type[] paramTypes = new Type[paramList.size()];
+ final Type[] paramTypes = new Type[params.length];
for (int i = 0; i < paramTypes.length; i++) {
- Object obj = paramList.get(i);
- paramTypes[i] = ctx.getType(obj);
+ paramTypes[i] = ctx.getType(params[i]);
}
final XpandDefinition def = ctx.findDefinition(definitionName, targetType, paramTypes);
@@ -62,8 +55,8 @@ public class XpandFacade {
ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(ExecutionContext.IMPLICIT_VARIABLE,
targetObject));
- for (int i = 0; i < paramList.size(); i++) {
- final Variable v = new Variable(def.getParams()[i].getName().getValue(), paramList.get(i));
+ for (int i = 0; i < params.length; i++) {
+ final Variable v = new Variable(def.getParams()[i].getName().getValue(), params[i]);
ctx = (XpandExecutionContext) ctx.cloneWithVariable(v);
}
ctx = (XpandExecutionContext) ctx.cloneWithResource(def.getOwner());
@@ -92,7 +85,7 @@ public class XpandFacade {
return issues.toArray(new AnalysationIssue[issues.size()]);
}
- public static XpandFacade create(XpandExecutionContext execCtx) {
+ public static XpandFacade create(XpandExecutionContextImpl execCtx) {
return new XpandFacade(execCtx);
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java
index 437a35a..d23b49e 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java
@@ -22,23 +22,15 @@ import org.eclipse.xpand2.XpandExecutionContext;
public class BlankLineSkippingOutput extends OutputImpl {
private final static char NEWLINE = '\n';
private StringBuffer buffer = null;
-
private boolean evaluateLine = false;
-
- /**
- * {@inheritDoc}
- */
public void write(final String bytes) {
if (current() != null) {
int idxNL = bytes.indexOf(NEWLINE);
- if (buffer==null && idxNL>=0) { // No buffer yet; String contains newline
+ if (buffer==null && idxNL>=0) {
buffer = new StringBuffer();
- // append string until the newline character
((StringBuffer) current().getBuffer()).append(bytes.substring(0, idxNL));
- // append the rest
if (idxNL<bytes.length()) buffer.append(bytes.substring(idxNL));
- } else if (buffer!=null && idxNL>=0) { // buffer exists; String contains newline
- // append string until the newline character
+ } else if (buffer!=null && idxNL>=0) {
buffer.append(bytes.substring(0, idxNL));
if (evaluateLine && !buffer.toString().trim().equals("")) {
((StringBuffer) current().getBuffer()).append (buffer.toString());
@@ -47,21 +39,14 @@ public class BlankLineSkippingOutput extends OutputImpl {
evaluateLine = false;
if (idxNL<bytes.length()) write(bytes.substring(idxNL));
} else if (buffer!=null) {
- // String does not contain newline, so just append
buffer.append(bytes);
} else {
- // we are not buffering yet and string does not contain newlines, so just
- // append the string to the original output buffer
((StringBuffer) current().getBuffer()).append(bytes);
}
}
}
- /**
- * {@inheritDoc}
- */
public void closeFile() {
- // append the buffer
if (buffer!=null && current()!=null) {
((StringBuffer) current().getBuffer()).append(buffer);
buffer=null;
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java
index 44ff789..a37c191 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java
@@ -19,17 +19,23 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class FileHandleImpl implements FileHandle {
- private final Log log = LogFactory.getLog(getClass());
+ private final Log log =
+ LogFactory.getLog(getClass());
- private StringBuffer buffer = new StringBuffer();
+ private StringBuffer buffer =
+ new StringBuffer();
- private File targetFile = null;
+ private File targetFile =
+ null;
- private Outlet outlet = null;
+ private Outlet outlet =
+ null;
public FileHandleImpl(final Outlet outlet, final File f) {
- this.outlet = outlet;
- targetFile = f.getAbsoluteFile();
+ this.outlet =
+ outlet;
+ targetFile =
+ f.getAbsoluteFile();
}
public Outlet getOutlet() {
@@ -41,7 +47,8 @@ public class FileHandleImpl implements FileHandle {
}
public void setBuffer(final CharSequence buffer) {
- this.buffer = new StringBuffer(buffer);
+ this.buffer =
+ new StringBuffer(buffer);
}
public File getTargetFile() {
@@ -63,35 +70,47 @@ public class FileHandleImpl implements FileHandle {
public void writeAndClose() {
try {
if (!isOverwrite() && targetFile.exists()) {
+ if (log.isDebugEnabled()) {
log.debug("Skipping file : " + targetFile.getAbsolutePath() + " cause it exists already");
+ }
return;
}
+ if (log.isDebugEnabled()) {
log.debug("Opening file : " + targetFile.getAbsolutePath());
+ }
// create all parent directories
- final File parentDir = targetFile.getParentFile();
+ final File parentDir =
+ targetFile.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
- if (!parentDir.isDirectory())
- throw new RuntimeException("Failed to create parent directories of file " + targetFile.getAbsolutePath());
+ if (!parentDir.isDirectory()) {
+ throw new RuntimeException("Failed to create parent directories of file "
+ + targetFile.getAbsolutePath());
+ }
}
outlet.beforeWriteAndClose(this);
if (outlet.shouldWrite(this)) {
- FileOutputStream out = null;
+ FileOutputStream out =
+ null;
try {
- out = new FileOutputStream(targetFile, isAppend());
+ out =
+ new FileOutputStream(targetFile, isAppend());
out.write(getBytes());
- } finally {
+ }
+ finally {
if (out != null) {
try {
out.close();
outlet.afterClose(this);
- } catch (final IOException e) {
+ }
+ catch (final IOException e) {
throw new RuntimeException(e);
}
}
}
}
- } catch (final IOException e) {
+ }
+ catch (final IOException e) {
throw new RuntimeException(e);
}
}
@@ -100,7 +119,8 @@ public class FileHandleImpl implements FileHandle {
if (getFileEncoding() != null) {
try {
return buffer.toString().getBytes(getFileEncoding());
- } catch (UnsupportedEncodingException e) {
+ }
+ catch (final UnsupportedEncodingException e) {
log.error(e.getMessage(), e);
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java
index 069661a..492db4a 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java
@@ -64,10 +64,18 @@ public class Outlet {
this.path = path;
}
- public FileHandleImpl createFileHandle(final String filePath) {
- filesCreated++;
+ public FileHandle createFileHandle(final String filePath) throws VetoException {
final File f = new File(path, filePath);
- return new FileHandleImpl(this, f);
+ FileHandleImpl fileHandle = new FileHandleImpl(this, f);
+ for (VetoStrategy vetoStrategy : vetoStrategies) {
+ if (vetoStrategy instanceof VetoStrategy2) {
+ if (((VetoStrategy2)vetoStrategy).hasVetoBeforeOpen(fileHandle)) {
+ throw new VetoException (filePath);
+ }
+ }
+ }
+ incFilesCreated();
+ return fileHandle;
}
public String getFileEncoding() {
@@ -84,14 +92,13 @@ public class Outlet {
public void addPostprocessor(final PostProcessor b) {
postprocessors.add(b);
}
- public List<VetoStrategy> vetoStartegies = new ArrayList<VetoStrategy>();
+ public List<VetoStrategy> vetoStrategies = new ArrayList<VetoStrategy>();
public void addVetoStrategy(final VetoStrategy b) {
- vetoStartegies.add(b);
+ vetoStrategies.add(b);
}
public void beforeWriteAndClose(final FileHandle impl) {
- filesWrittenAndClosed++;
for (final Iterator<PostProcessor> iter = postprocessors.iterator(); iter.hasNext();) {
final PostProcessor b = iter.next();
b.beforeWriteAndClose(impl);
@@ -99,6 +106,7 @@ public class Outlet {
}
public void afterClose(final FileHandle impl) {
+ incFilesWrittenAndClosed();
for (final Iterator<PostProcessor> iter = postprocessors.iterator(); iter.hasNext();) {
final PostProcessor b = iter.next();
b.afterClose(impl);
@@ -113,10 +121,24 @@ public class Outlet {
return filesCreated;
}
+ /**
+ * @since 4.3.1
+ */
+ protected final void incFilesCreated () {
+ filesCreated++;
+ }
+
public int getFilesWrittenAndClosed() {
return filesWrittenAndClosed;
}
+ /**
+ * @since 4.3.1
+ */
+ protected final void incFilesWrittenAndClosed () {
+ filesWrittenAndClosed++;
+ }
+
public Outlet(String path) {
this.path = path;
}
@@ -124,20 +146,31 @@ public class Outlet {
public Outlet() {
}
- public Outlet (boolean append, String encoding, String name, boolean overwrite, String path) {
- this.append = append;
- this.fileEncoding = encoding;
- this.name = name;
- this.overwrite = overwrite;
- this.path = path;
- }
-
public boolean shouldWrite(FileHandleImpl fileHandleImpl) {
- for (VetoStrategy vs : vetoStartegies) {
+ for (VetoStrategy vs : vetoStrategies) {
if (vs.hasVeto(fileHandleImpl))
return false;
}
return true;
}
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder ();
+ if (name!=null) sb.append(name+":");
+ sb.append(path);
+ if (isAppend() || !isOverwrite() || !hasDefaultEncoding()) {
+ sb
+ .append("(")
+ .append("overwrite=")
+ .append(overwrite)
+ .append(",append=")
+ .append(append)
+ .append(",fileEncoding=")
+ .append(fileEncoding)
+ .append(")");
+ }
+ return sb.toString();
+ }
+
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java
index 83f633a..1dac2cb 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java
@@ -30,5 +30,4 @@ public interface Output {
public void addOutlet(Outlet outlet);
- public Outlet getOutlet (String name);
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java
index 13e6dd0..54b4e00 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java
@@ -31,11 +31,11 @@ public class OutputImpl implements Output {
private boolean automaticHyphenation = false;
- public void setAutomaticHyphens(boolean automaticHyphenation) {
+ public void setAutomaticHyphens(final boolean automaticHyphenation) {
this.automaticHyphenation = automaticHyphenation;
}
- protected Stack<FileHandleImpl> fileHandles = new Stack<FileHandleImpl>();
+ protected Stack<FileHandle> fileHandles = new Stack<FileHandle>();
private final Map<String, Outlet> outlets = new HashMap<String, Outlet>();
@@ -44,49 +44,49 @@ public class OutputImpl implements Output {
if (outlet.getName() == null)
throw new IllegalArgumentException("A default outlet is already registered!");
else
- throw new IllegalArgumentException("An outlet with name " + outlet.getName() + " is already registered!");
+ throw new IllegalArgumentException("An outlet with name " + outlet.getName()
+ + " is already registered!");
}
outlets.put(outlet.getName(), outlet);
}
- public Outlet getOutlet (String name) {
- return outlets.get (name);
+ public Outlet getOutlet(final String name) {
+ return outlets.get(name);
}
-
+
protected FileHandle current() {
- return (fileHandles.isEmpty() ? null : fileHandles.peek());
+ return fileHandles.isEmpty() ? null : fileHandles.peek();
}
-
+
/**
* DO NOT CALL THIS METHOD - FOR TESTS ONLY
*/
public FileHandle current__testONLY() {
return current();
}
-
-
private boolean deleteLine = false;
public void write(final String bytes) {
if (current() != null) {
if (deleteLine) {
- String temp = trimUntilNewline(bytes);
+ final String temp = trimUntilNewline(bytes);
removeWSAfterLastNewline(current().getBuffer());
((StringBuffer) current().getBuffer()).append(temp);
- } else {
- ((StringBuffer)current().getBuffer()).append(bytes);
+ }
+ else {
+ ((StringBuffer) current().getBuffer()).append(bytes);
}
}
deleteLine = false;
}
- public void removeWSAfterLastNewline(CharSequence cs) {
- final StringBuffer buffer = (StringBuffer) cs;
+ public void removeWSAfterLastNewline(final CharSequence cs) {
+ final StringBuffer buffer = (StringBuffer) cs;
int i = buffer.length();
boolean wsOnly = true;
for (; i > 0 && wsOnly; i--) {
- char c = buffer.charAt(i - 1);
+ final char c = buffer.charAt(i - 1);
wsOnly = Character.isWhitespace(c);
if (wsOnly && isNewLine(c)) {
buffer.delete(i, buffer.length());
@@ -96,19 +96,20 @@ public class OutputImpl implements Output {
return;
}
- private boolean isNewLine(char c) {
+ private boolean isNewLine(final char c) {
return c == '\n' || c == '\r';
}
- public String trimUntilNewline(String bytes) {
+ public String trimUntilNewline(final String bytes) {
int i = 0;
boolean wsOnly = true;
for (; i < bytes.length() && wsOnly; i++) {
- char c = bytes.charAt(i);
+ final char c = bytes.charAt(i);
wsOnly = Character.isWhitespace(c);
if (wsOnly && isNewLine(c)) {
- if (c == '\r' && i + 1 < bytes.length() && bytes.charAt(i + 1) == '\n')
+ if (c == '\r' && i + 1 < bytes.length() && bytes.charAt(i + 1) == '\n') {
i++;
+ }
return bytes.substring(i + 1);
}
}
@@ -117,32 +118,33 @@ public class OutputImpl implements Output {
private final static Pattern p = Pattern.compile("(.+)://(.+)");
- public static Pair<Outlet, String> resolveOutlet (Map<String, Outlet> allOutlets, String path, String outletName) {
- if (outletName == null) {
- final Matcher m = p.matcher(path);
- if (m.matches()) {
- outletName = m.group(1);
- path = m.group(2);
- }
- }
- final Outlet o = allOutlets.get(outletName);
- if (o == null) {
- if (outletName == null)
- throw new IllegalArgumentException ("No default outlet was configured!");
- else
- throw new IllegalArgumentException ("No outlet with the name " + outletName + " could be found!");
- }
-
- return new Pair<Outlet, String> (o, path);
+ public static Pair<Outlet, String> resolveOutlet(final Map<String, Outlet> allOutlets, String path,
+ String outletName) {
+ if (outletName == null) {
+ final Matcher m = p.matcher(path);
+ if (m.matches()) {
+ outletName = m.group(1);
+ path = m.group(2);
+ }
+ }
+ final Outlet o = allOutlets.get(outletName);
+ if (o == null) {
+ if (outletName == null)
+ throw new IllegalArgumentException("No default outlet was configured!");
+ else
+ throw new IllegalArgumentException("No outlet with the name " + outletName + " could be found!");
+ }
+
+ return new Pair<Outlet, String>(o, path);
}
-
- public void openFile(String path, String outletName) {
- final Pair<Outlet, String> raw = resolveOutlet(outlets, path, outletName);
-
- final Outlet actualOutlet = raw.getFirst();
- final String actualPath = raw.getSecond();
-
- fileHandles.push (actualOutlet.createFileHandle (actualPath));
+
+ public void openFile(final String path, final String outletName) {
+ final Pair<Outlet, String> raw = resolveOutlet(outlets, path, outletName);
+
+ final Outlet actualOutlet = raw.getFirst();
+ final String actualPath = raw.getSecond();
+
+ fileHandles.push(actualOutlet.createFileHandle(actualPath));
}
public void closeFile() {
@@ -152,7 +154,7 @@ public class OutputImpl implements Output {
private final Stack<SyntaxElement> s = new Stack<SyntaxElement>();
- public void pushStatement(final SyntaxElement stmt, XpandExecutionContext ctx) {
+ public void pushStatement(final SyntaxElement stmt, final XpandExecutionContext ctx) {
if (stmt instanceof TextStatement) {
deleteLine = ((TextStatement) stmt).isDeleteLine();
if (automaticHyphenation) {
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoException.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoException.java
index 79ad4ed..6349a7a 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoException.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoException.java
@@ -11,8 +11,7 @@
package org.eclipse.xpand2.output;
/**
- * Signals a veto by a {@link VetoStrategy2} implementation.
- *
+ * Signals a veto by a {@link VetoStrategy2} implementation.
* @author thoms
* @since 4.3.1
*/
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java
index 9e2f5ee..3563182 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java
@@ -14,11 +14,9 @@ package org.eclipse.xpand2.output;
public interface VetoStrategy {
/**
- * Called before the file will be written and <b>after</b>
- * beforeWriteAndClose() has been invoked on all post processors.
- *
- * @param impl
- * A handle to the file that will be written
+ * Called before the file will be written
+ * and <b>after</b> beforeWriteAndClose() has been invoked on all post processors.
+ * @param impl A handle to the file that will be written
* @return if hasVeto returns true the file will not be written
*/
boolean hasVeto(FileHandle handle);
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy2.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy2.java
index 3806dfe..33ae5f6 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy2.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy2.java
@@ -19,12 +19,9 @@ public interface VetoStrategy2 extends VetoStrategy {
/**
* Called before the file will be opened and generated.
- *
- * @param impl
- * A handle to the file that will be generated
- * @return if hasVetoBeforeOpen returns true the file will not be opened nor
- * generated
+ * @param impl A handle to the file that will be generated
+ * @return if hasVetoBeforeOpen returns true the file will not be opened nor generated
*/
- boolean hasVetoBeforeOpen(FileHandle handle);
+ boolean hasVetoBeforeOpen (FileHandle handle);
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/plugin.xml b/plugins/org.eclipse.xtend.shared.ui/plugin.xml
index 9553381..7f6db47 100644
--- a/plugins/org.eclipse.xtend.shared.ui/plugin.xml
+++ b/plugins/org.eclipse.xtend.shared.ui/plugin.xml
@@ -158,8 +158,8 @@
point="org.eclipse.search.searchResultViewPages">
<viewPage
id="org.eclipse.xtend.shared.ui.editor.SearchResultPage"
- searchResultClass="org.eclipse.xtend.shared.ui.editor.search.query.OawSearchResult"
- class="org.eclipse.xtend.shared.ui.editor.search.view.OawSearchResultPage">
+ searchResultClass="org.eclipse.xtend.shared.ui.editor.search.query.XtendXpandSearchResult"
+ class="org.eclipse.xtend.shared.ui.editor.search.view.XtendXpandSearchResultPage">
</viewPage>
</extension>
</plugin>
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/MetamodelContainer.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/MetamodelContainer.java
index 1fc1434..236f321 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/MetamodelContainer.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/MetamodelContainer.java
@@ -30,67 +30,69 @@ import org.eclipse.xtend.typesystem.MetaModel;
public class MetamodelContainer implements IElementChangedListener, IResourceChangeListener {
- List<IJavaProject> projects;
+ List<IJavaProject> projects;
- boolean changed = false;
+ boolean changed = false;
- private Set<MetaModel> metaModels;
+ private final Set<MetaModel> metaModels;
- Set<IResource> resources;
+ Set<IResource> resources;
- public MetamodelContainer(final List<IJavaProject> project, final Set<IResource> resource, final Set<MetaModel> metamodels) {
- projects = project;
- metaModels = metamodels;
- resources = resource;
- }
+ public MetamodelContainer(final List<IJavaProject> project, final Set<IResource> resource,
+ final Set<MetaModel> metamodels) {
+ projects = project;
+ metaModels = metamodels;
+ resources = resource;
+ }
- public void elementChanged(final ElementChangedEvent event) {
- for (final Iterator<IJavaProject> iter = projects.iterator(); !changed && iter.hasNext();) {
- final IJavaProject project = iter.next();
- if (project.isOnClasspath(event.getDelta().getElement())) {
- changed = true;
- }
- }
- }
+ public void elementChanged(final ElementChangedEvent event) {
+ for (final Iterator<IJavaProject> iter = projects.iterator(); !changed && iter.hasNext();) {
+ final IJavaProject project = iter.next();
+ if (project.isOnClasspath(event.getDelta().getElement())) {
+ changed = true;
+ }
+ }
+ }
- public boolean hasChanged() {
- return changed;
- }
+ public boolean hasChanged() {
+ return changed;
+ }
- public Set<MetaModel> getMetaModels() {
- return metaModels;
- }
+ public Set<MetaModel> getMetaModels() {
+ return metaModels;
+ }
- public void resourceChanged(final IResourceChangeEvent event) {
- if (changed)
- return;
- // we are only interested in POST_CHANGE events
- if (event.getType() != IResourceChangeEvent.POST_CHANGE)
- return;
- final IResourceDelta rootDelta = event.getDelta();
- try {
- rootDelta.accept(new IResourceDeltaVisitor() {
+ public void resourceChanged(final IResourceChangeEvent event) {
+ if (changed)
+ return;
+ // we are only interested in POST_CHANGE events
+ if (event.getType() != IResourceChangeEvent.POST_CHANGE)
+ return;
+ final IResourceDelta rootDelta = event.getDelta();
+ try {
+ rootDelta.accept(new IResourceDeltaVisitor() {
- public boolean visit(final IResourceDelta delta) throws CoreException {
- if (!changed && delta.getResource() != null) {
- if (resources.contains(delta.getResource())) {
- changed = true;
- }
- if (delta.getResource() instanceof IProject) {
- for (final Iterator<IJavaProject> iter = projects.iterator(); !changed && iter.hasNext();) {
- final IJavaProject project = iter.next();
- if (project.getProject().equals(delta.getResource())) {
- changed = true;
- }
- }
- }
- }
- return true;
- }
- });
- } catch (final CoreException e) {
- XtendLog.logError(e);
- }
- }
+ public boolean visit(final IResourceDelta delta) throws CoreException {
+ if (!changed && delta.getResource() != null) {
+ if (resources.contains(delta.getResource())) {
+ changed = true;
+ }
+ if (delta.getResource() instanceof IProject) {
+ for (final Iterator<IJavaProject> iter = projects.iterator(); !changed && iter.hasNext();) {
+ final IJavaProject project = iter.next();
+ if (project.getProject().equals(delta.getResource())) {
+ changed = true;
+ }
+ }
+ }
+ }
+ return true;
+ }
+ });
+ }
+ catch (final CoreException e) {
+ XtendLog.logError(e);
+ }
+ }
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IModelManager.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IModelManager.java
index 5ff3601..48488b6 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IModelManager.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IModelManager.java
@@ -26,6 +26,6 @@ public interface IModelManager {
public abstract void analyze(IProgressMonitor monitor);
- public IXtendXpandResource findOawResource(String oawNamespace, String extension);
+ public IXtendXpandResource findXtendXpandResource(String extxptNamespace, String extension);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IXtendXpandProject.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IXtendXpandProject.java
index b5cd618..2632f6d 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IXtendXpandProject.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/IXtendXpandProject.java
@@ -16,47 +16,58 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
/**
- * Represents a project containing openArchitectureWare resources. These are Xpand template, Xtend
- * files, Workflow files etc.
+ * Represents a project containing openArchitectureWare resources. These are
+ * Xpand template, Xtend files, Workflow files etc.
+ *
* @since 4.0
*/
public interface IXtendXpandProject {
/**
- * Finds an oAW resource by its fully qualified name and file extension.
- * @param fqn The full qualified name in oAW syntax. For example: my::templates::Main
+ * Finds an Xtend resource by its fully qualified name and file extension.
+ *
+ * @param fqn
+ * The full qualified name in Xtend syntax. For example:
+ * my::templates::Main
* @return The resource or null if the resource could not be located.
*/
- IXtendXpandResource findExtXptResource(String fqn, String extension);
-
- /**
- * Finds an oAW resource by it's underlying IStorage instance
- * @param
- * @return The resource or null if the resource could not be located (i.e it's not an oaw resource).
- */
- IXtendXpandResource findOawResource(IStorage file);
+ IXtendXpandResource findExtXptResource(String fqn, String extension);
- /**
- * Returns all registered resources within the project.
- * @return
- */
- IXtendXpandResource[] getRegisteredResources();
+ /**
+ * Finds an Xtend resource by it's underlying IStorage instance
+ *
+ * @param
+ * @return The resource or null if the resource could not be located (i.e
+ * it's not an Xtend/Xpand resource).
+ */
+ IXtendXpandResource findXtendXpandResource(IStorage file);
- /**
- * Returns the corresponding {@link IJavaProject Java Project}.
- */
- IJavaProject getProject();
+ /**
+ * Returns all registered resources within the project.
+ *
+ * @return
+ */
+ IXtendXpandResource[] getRegisteredResources();
- /**
- * Unregisters a resource from the project.
- * @param res Resource which should be unregistered.
- */
- void unregisterOawResource(IXtendXpandResource res);
+ /**
+ * Returns the corresponding {@link IJavaProject Java Project}.
+ */
+ IJavaProject getProject();
- /**
- * Analyzes the project's resources and marks erraneous resources.
- * @param monitor (optional) A monitor for the progress of the analysis.
- */
- void analyze(IProgressMonitor monitor);
+ /**
+ * Unregisters a resource from the project.
+ *
+ * @param res
+ * Resource which should be unregistered.
+ */
+ void unregisterXtendXpandResource(IXtendXpandResource res);
+
+ /**
+ * Analyzes the project's resources and marks erraneous resources.
+ *
+ * @param monitor
+ * (optional) A monitor for the progress of the analysis.
+ */
+ void analyze(IProgressMonitor monitor);
public IXtendXpandResource[] getAllRegisteredResources();
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/action/SelectionDispatchAction.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/action/SelectionDispatchAction.java
index a62c034..756e336 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/action/SelectionDispatchAction.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/action/SelectionDispatchAction.java
@@ -39,7 +39,7 @@ import org.eclipse.ui.IWorkbenchSite;
* selectionChanged(ISelection)}.</li>
* </ul>
*
- * Note: This class is not intended to be subclassed outside the oAW UI plug-in.
+ * Note: This class is not intended to be subclassed outside the Xtend UI plug-in.
*/
public abstract class SelectionDispatchAction extends Action implements ISelectionChangedListener {
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandBuilder.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandBuilder.java
index 5a5d73d..b8421a3 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandBuilder.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandBuilder.java
@@ -13,7 +13,6 @@ package org.eclipse.xtend.shared.ui.core.builder;
import java.util.Enumeration;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
@@ -43,15 +42,15 @@ import org.eclipse.xtend.shared.ui.internal.XtendLog;
public class XtendXpandBuilder extends IncrementalProjectBuilder {
- class OawDeltaVisitor implements IResourceDeltaVisitor, IResourceVisitor {
- private IProgressMonitor monitor;
- private Set<String> extensions;
+ class XtendXpandDeltaVisitor implements IResourceDeltaVisitor, IResourceVisitor {
+ private final IProgressMonitor monitor;
+ private final Set<String> extensions;
- public OawDeltaVisitor(final IProgressMonitor monitor) {
+ public XtendXpandDeltaVisitor(final IProgressMonitor monitor) {
this.monitor = monitor;
extensions = new HashSet<String>();
- ResourceContributor[] contributors = Activator.getRegisteredResourceContributors();
- for (ResourceContributor resourceContributor : contributors) {
+ final ResourceContributor[] contributors = Activator.getRegisteredResourceContributors();
+ for (final ResourceContributor resourceContributor : contributors) {
extensions.add(resourceContributor.getFileExtension());
}
}
@@ -59,38 +58,40 @@ public class XtendXpandBuilder extends IncrementalProjectBuilder {
/*
* (non-Javadoc)
*
- * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
+ * @see
+ * org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse
+ * .core.resources.IResourceDelta)
*/
public boolean visit(final IResourceDelta delta) throws CoreException {
final IResource resource = delta.getResource();
- if (isOawResource(resource)) {
+ if (isXtendXpandResource(resource)) {
switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- // handle added resource
- XtendXpandMarkerManager.deleteMarkers((IFile) resource);
- reloadResource((IFile) resource);
- break;
- case IResourceDelta.REMOVED:
- // handle removed resource
- handleRemovement((IFile) resource);
- break;
- case IResourceDelta.CHANGED:
- // handle changed resource
- reloadResource((IFile) resource);
- break;
+ case IResourceDelta.ADDED:
+ // handle added resource
+ XtendXpandMarkerManager.deleteMarkers(resource);
+ reloadResource((IFile) resource);
+ break;
+ case IResourceDelta.REMOVED:
+ // handle removed resource
+ handleRemovement((IFile) resource);
+ break;
+ case IResourceDelta.CHANGED:
+ // handle changed resource
+ reloadResource((IFile) resource);
+ break;
}
}
monitor.worked(1);
return true;
}
- private boolean isOawResource(final IResource resource) {
+ private boolean isXtendXpandResource(final IResource resource) {
return resource instanceof IFile && extensions.contains(((IFile) resource).getFileExtension())
&& isOnJavaClassPath(resource);
}
public boolean visit(final IResource resource) {
- if (isOawResource(resource)) {
+ if (isXtendXpandResource(resource)) {
reloadResource((IFile) resource);
}
monitor.worked(1);
@@ -116,7 +117,7 @@ public class XtendXpandBuilder extends IncrementalProjectBuilder {
* (non-Javadoc)
*
* @see org.eclipse.core.internal.events.InternalBuilder#build(int,
- * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
+ * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected IProject[] build(final int kind, final Map args, final IProgressMonitor monitor) throws CoreException {
@@ -124,30 +125,33 @@ public class XtendXpandBuilder extends IncrementalProjectBuilder {
try {
if (kind == FULL_BUILD) {
fullBuild(monitor);
- } else {
+ }
+ else {
final IResourceDelta delta = getDelta(getProject());
if (delta == null) {
fullBuild(monitor);
- } else {
+ }
+ else {
incrementalBuild(delta, monitor);
}
}
- } catch (final Throwable e) {
+ }
+ catch (final Throwable e) {
e.printStackTrace();
}
- for (final Iterator<?> iter = toAnalyze.iterator(); iter.hasNext();) {
- final IXtendXpandResource res = (IXtendXpandResource) iter.next();
- IStorage underlyingStorage = res.getUnderlyingStorage();
- if(underlyingStorage instanceof IResource) {
- IResource resource = (IResource) underlyingStorage;
- IProject project = resource.getProject();
- if(project.isLinked()) {
- continue;
- }
- }
+ for (final Object name : toAnalyze) {
+ final IXtendXpandResource res = (IXtendXpandResource) name;
+ final IStorage underlyingStorage = res.getUnderlyingStorage();
+ if (underlyingStorage instanceof IResource) {
+ final IResource resource = (IResource) underlyingStorage;
+ final IProject project = resource.getProject();
+ if (project.isLinked()) {
+ continue;
+ }
+ }
res.analyze();
}
- IXtendXpandProject p = Activator.getExtXptModelManager().findProject(getProject());
+ final IXtendXpandProject p = Activator.getExtXptModelManager().findProject(getProject());
p.analyze(monitor);
return null;
}
@@ -156,10 +160,11 @@ public class XtendXpandBuilder extends IncrementalProjectBuilder {
if (resource.exists()) {
final IXtendXpandProject project = Activator.getExtXptModelManager().findProject(resource);
if (project != null) {
- final IXtendXpandResource r = project.findOawResource(resource);
+ final IXtendXpandResource r = project.findXtendXpandResource(resource);
if (r != null) {
- if (r.refresh())
+ if (r.refresh()) {
resource.getLocalTimeStamp();
+ }
toAnalyze.add(r);
}
}
@@ -169,54 +174,57 @@ public class XtendXpandBuilder extends IncrementalProjectBuilder {
public void handleRemovement(final IFile resource) {
final IXtendXpandProject project = Activator.getExtXptModelManager().findProject(resource);
if (project != null) {
- project.unregisterOawResource(project.findOawResource(resource));
- } else {
- XtendLog.logInfo("No oaw project found for " + resource.getProject().getName());
+ project.unregisterXtendXpandResource(project.findXtendXpandResource(resource));
+ }
+ else {
+ XtendLog.logInfo("No Xpand project found for " + resource.getProject().getName());
}
}
protected void fullBuild(final IProgressMonitor monitor) throws CoreException {
final IXtendXpandProject project = Activator.getExtXptModelManager().findProject(getProject().getFullPath());
if (project != null) {
- getProject().accept(new OawDeltaVisitor(monitor));
- IJavaProject jp = JavaCore.create(getProject());
- IPackageFragmentRoot[] roots = jp.getPackageFragmentRoots();
- Set<String> extensions = new HashSet<String>();
- ResourceContributor[] contributors = Activator.getRegisteredResourceContributors();
- for (ResourceContributor resourceContributor : contributors) {
+ getProject().accept(new XtendXpandDeltaVisitor(monitor));
+ final IJavaProject jp = JavaCore.create(getProject());
+ final IPackageFragmentRoot[] roots = jp.getPackageFragmentRoots();
+ final Set<String> extensions = new HashSet<String>();
+ final ResourceContributor[] contributors = Activator.getRegisteredResourceContributors();
+ for (final ResourceContributor resourceContributor : contributors) {
extensions.add(resourceContributor.getFileExtension());
}
- for (int i = 0; i < roots.length; i++) {
- IPackageFragmentRoot root = roots[i];
+ for (final IPackageFragmentRoot root : roots) {
if (root.isArchive()) {
root.open(monitor);
try {
- ZipFile zip = ((JarPackageFragmentRoot) root).getJar();
- Enumeration<? extends ZipEntry> entries = zip.entries();
+ final ZipFile zip = ((JarPackageFragmentRoot) root).getJar();
+ final Enumeration<? extends ZipEntry> entries = zip.entries();
while (entries.hasMoreElements()) {
- ZipEntry entry = entries.nextElement();
- for (String ext : extensions) {
- String name = entry.getName();
+ final ZipEntry entry = entries.nextElement();
+ for (final String ext : extensions) {
+ final String name = entry.getName();
if (name.endsWith(ext)) {
- String fqn = name.substring(0, name.length() - ext.length() - 1).replaceAll("/", "::");
- ResourceID resourceID = new ResourceID(fqn, ext);
- IStorage findStorage = JDTUtil.loadFromJar(resourceID, root);
- project.findOawResource(findStorage);
+ final String fqn = name.substring(0, name.length() - ext.length() - 1).replaceAll(
+ "/", "::");
+ final ResourceID resourceID = new ResourceID(fqn, ext);
+ final IStorage findStorage = JDTUtil.loadFromJar(resourceID, root);
+ project.findXtendXpandResource(findStorage);
}
}
}
- } finally {
+ }
+ finally {
root.close();
}
}
}
- } else {
- XtendLog.logInfo("Couldn't create oawproject for project " + getProject().getName());
+ }
+ else {
+ XtendLog.logInfo("Couldn't create Xpand project for project " + getProject().getName());
}
}
protected void incrementalBuild(final IResourceDelta delta, final IProgressMonitor monitor) throws CoreException {
- final OawDeltaVisitor visitor = new OawDeltaVisitor(monitor);
+ final XtendXpandDeltaVisitor visitor = new XtendXpandDeltaVisitor(monitor);
delta.accept(visitor);
}
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandNature.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandNature.java
index 64c5821..62cfeff 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandNature.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/builder/XtendXpandNature.java
@@ -19,7 +19,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.xtend.shared.ui.Activator;
/**
- * This class configures the build configuration for oAW projects.
+ * This class configures the build configuration for Xtend projects.
*
* @author Sven Efftinge (http://www.efftinge.de)
* @author Peter Friese
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/i18n/Messages.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/i18n/Messages.java
index b6bb023..c225bcd 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/i18n/Messages.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/i18n/Messages.java
@@ -16,11 +16,11 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.internal.xtend.editor.outlineview.messages"; //$NON-NLS-1$
- public static String AbstractOawContentOutlinePage_1;
+ public static String AbstractXtendXpandContentOutlinePage_1;
- public static String AbstractOawContentOutlinePage_3;
+ public static String AbstractXtendXpandContentOutlinePage_3;
- public static String AbstractOawContentOutlinePage_4;
+ public static String AbstractXtendXpandContentOutlinePage_4;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/JDTUtil.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/JDTUtil.java
index 116d9d2..6102a66 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/JDTUtil.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/JDTUtil.java
@@ -112,7 +112,7 @@ public class JDTUtil {
return null;
}
- public static ResourceID findOawResourceID(IJavaProject project,
+ public static ResourceID findXtendXpandResourceID(IJavaProject project,
IStorage file) {
if (file == null)
return null;
@@ -167,7 +167,7 @@ public class JDTUtil {
}
public static String getQualifiedName(IStorage source) {
- ResourceID id = findOawResourceID(getJProject(source), source);
+ ResourceID id = findXtendXpandResourceID(getJProject(source), source);
if (id != null)
return id.name;
return null;
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandModelManager.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandModelManager.java
index f30c9da..175ac5d 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandModelManager.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandModelManager.java
@@ -65,7 +65,7 @@ public class XtendXpandModelManager implements IModelManager {
}
public void analyze(final IProgressMonitor monitor) {
- monitor.beginTask("Analyzing oAW4 projects...", computeAmoutOfWork());
+ monitor.beginTask("Analyzing Xtend4 projects...", computeAmoutOfWork());
for (final Iterator<?> iter = projects.getValues().iterator(); iter.hasNext();) {
if (monitor.isCanceled())
return;
@@ -76,7 +76,7 @@ public class XtendXpandModelManager implements IModelManager {
/**
* Computes the amount of work that has to be done during a build.
- * @return the number of resources registered within all oAW projects.
+ * @return the number of resources registered within all Xtend projects.
*/
private int computeAmoutOfWork() {
int i = 0;
@@ -88,7 +88,7 @@ public class XtendXpandModelManager implements IModelManager {
}
/**
- * Tries to locate an oAW resource by its underlying file.
+ * Tries to locate an Xtend resource by its underlying file.
* @param underlying IStorage
*/
public IXtendXpandResource findExtXptResource(IStorage file) {
@@ -96,7 +96,7 @@ public class XtendXpandModelManager implements IModelManager {
if (!(file instanceof IFile)) {
for (Iterator<?> it=projects.getValues().iterator(); it.hasNext(); ) {
IXtendXpandProject p = (IXtendXpandProject) it.next();
- IXtendXpandResource res = p.findOawResource(file);
+ IXtendXpandResource res = p.findXtendXpandResource(file);
if (res!=null) {
return res;
}
@@ -104,13 +104,13 @@ public class XtendXpandModelManager implements IModelManager {
} else {
final IXtendXpandProject project = findProject((IFile)file);
if (project != null) {
- return project.findOawResource(file);
+ return project.findXtendXpandResource(file);
}
}
return null;
}
- public IXtendXpandResource findOawResource(String oawNamespace, String extension) {
+ public IXtendXpandResource findXtendXpandResource(String oawNamespace, String extension) {
for (IXtendXpandProject p : projects.getValues()) {
IXtendXpandResource res = p.findExtXptResource(oawNamespace, extension);
if (res!=null)
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandProject.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandProject.java
index e6208f9..3cd3282 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandProject.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/internal/XtendXpandProject.java
@@ -179,9 +179,9 @@ public class XtendXpandProject implements IXtendXpandProject {
}
/**
- * @see IXtendXpandProject#unregisterOawResource(IXtendXpandResource)
+ * @see IXtendXpandProject#unregisterXtendXpandResource(IXtendXpandResource)
*/
- public void unregisterOawResource(final IXtendXpandResource res) {
+ public void unregisterXtendXpandResource(final IXtendXpandResource res) {
if (res != null) {
if (res.getUnderlyingStorage() instanceof IFile)
XtendXpandMarkerManager.deleteMarkers((IFile) res.getUnderlyingStorage());
@@ -198,15 +198,15 @@ public class XtendXpandProject implements IXtendXpandProject {
if (Activator.getRegisteredResourceContributorFor(extension) == null)
return null;
// for performance reasons ask the cache first
- IXtendXpandResource res = findCachedOawResource(fqn, extension);
+ IXtendXpandResource res = findCachedXtendXpandResource(fqn, extension);
if (res != null)
return res;
// ask to load the resource without looking into jars
- res = loadOawResource(fqn, extension, false);
+ res = loadXtendXpandResource(fqn, extension, false);
if (res != null)
return res;
// look into jars
- return loadOawResource(fqn, extension, true);
+ return loadXtendXpandResource(fqn, extension, true);
}
/**
@@ -219,7 +219,7 @@ public class XtendXpandProject implements IXtendXpandProject {
* @return The cached resource or <code>null</code> if the resource is not
* known
*/
- private IXtendXpandResource findCachedOawResource(String fqn, String extension) {
+ private IXtendXpandResource findCachedXtendXpandResource(String fqn, String extension) {
IXtendXpandResource res = resources.get(new ResourceID(fqn, extension));
if (res == null)
return null;
@@ -236,7 +236,7 @@ public class XtendXpandProject implements IXtendXpandProject {
}
/**
- * Loads an oAW Resource. Searches the project and all referenced projects.
+ * Loads an Xtend Resource. Searches the project and all referenced projects.
*
* @param fqn
* Qualified name of the resource, e.g. '<tt>org::eclipse::xtend::util::stdlib::io.ext'
@@ -247,7 +247,7 @@ public class XtendXpandProject implements IXtendXpandProject {
* classpath
* @return The resource or <code>null</code> if not found
*/
- private IXtendXpandResource loadOawResource(final String fqn, final String extension, boolean searchJars) {
+ private IXtendXpandResource loadXtendXpandResource(final String fqn, final String extension, boolean searchJars) {
assert (fqn != null);
assert (extension != null);
@@ -287,10 +287,10 @@ public class XtendXpandProject implements IXtendXpandProject {
final IProject[] p = project.getProject().getReferencedProjects();
for (int i = 0; i < p.length; i++) {
IProject project = p[i];
- final XtendXpandProject oawp = (XtendXpandProject) Activator.getExtXptModelManager().findProject(
+ final XtendXpandProject extxptp = (XtendXpandProject) Activator.getExtXptModelManager().findProject(
project);
- if (oawp != null) {
- IXtendXpandResource result = oawp.loadOawResource(fqn, extension, searchJars);
+ if (extxptp != null) {
+ IXtendXpandResource result = extxptp.loadXtendXpandResource(fqn, extension, searchJars);
if (result != null)
return result;
}
@@ -305,10 +305,10 @@ public class XtendXpandProject implements IXtendXpandProject {
/**
* @see IXtendXpandProject#findExtXptResource(IPath, boolean)
*/
- public IXtendXpandResource findOawResource(final IStorage file) {
+ public IXtendXpandResource findXtendXpandResource(final IStorage file) {
if (file == null)
return null;
- ResourceID id = JDTUtil.findOawResourceID(project, file);
+ ResourceID id = JDTUtil.findXtendXpandResourceID(project, file);
if (id == null) {
return null;
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/Contributor.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/Contributor.java
index 2ff2514..1290d43 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/Contributor.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/Contributor.java
@@ -21,12 +21,12 @@ import org.eclipse.xtend.shared.ui.internal.XtendLog;
* @author Peter Friese
*/
public class Contributor {
- private String displayName;
+ private final String displayName;
- private String className;
+ private final String className;
+
+ private final IConfigurationElement element;
- private IConfigurationElement element;
-
/**
* Creates a new Contributor instance.
*
@@ -34,9 +34,10 @@ public class Contributor {
* The display name of the metamodel contributor.
* @param className
* The class name of the metamodel contributor.
- * @param element
+ * @param element
*/
- public Contributor(String displayName, String className, IConfigurationElement element, boolean enabled) {
+ public Contributor(final String displayName, final String className, final IConfigurationElement element,
+ final boolean enabled) {
super();
this.displayName = displayName;
this.className = className;
@@ -52,12 +53,12 @@ public class Contributor {
}
@Override
- public boolean equals(Object other) {
+ public boolean equals(final Object other) {
if (other instanceof Contributor) {
- Contributor otherContributor = (Contributor) other;
- if (otherContributor.getClassName().equals(this.getClassName()) && otherContributor.getDisplayName().equals(this.getDisplayName())) {
+ final Contributor otherContributor = (Contributor) other;
+ if (otherContributor.getClassName().equals(getClassName())
+ && otherContributor.getDisplayName().equals(getDisplayName()))
return true;
- }
}
return false;
}
@@ -71,11 +72,12 @@ public class Contributor {
public String toString() {
return "Metamodel contributor '" + displayName + "'" + " [" + className + "]";
}
-
+
public MetamodelContributor getMetaModelContributor() {
try {
return (MetamodelContributor) element.createExecutableExtension("class");
- } catch (CoreException e) {
+ }
+ catch (final CoreException e) {
XtendLog.logError(e);
return null;
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/MetamodelContributorRegistry.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/MetamodelContributorRegistry.java
index b016a36..32a8b3c 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/MetamodelContributorRegistry.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/MetamodelContributorRegistry.java
@@ -16,7 +16,6 @@ import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -39,7 +38,7 @@ import org.eclipse.xtend.shared.ui.internal.XtendLog;
*/
public class MetamodelContributorRegistry {
- private static final String CONTRIBUTOR_ID = "org.eclipse.xtend.shared.ui.metamodelContributor";
+ private static final String CONTRIBUTOR_ID = "org.eclipse.base.metamodelContributor";
/**
* Retrieves the registered metamodel contributors.
@@ -55,15 +54,12 @@ public class MetamodelContributorRegistry {
final IExtensionPoint point = registry.getExtensionPoint(MetamodelContributorRegistry.CONTRIBUTOR_ID);
if (point != null) {
final IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- final IExtension extension = extensions[i];
+ for (final IExtension extension : extensions) {
final IConfigurationElement[] configs = extension.getConfigurationElements();
- for (int j = 0; j < configs.length; j++) {
- final IConfigurationElement element = configs[j];
-
- String label = element.getAttribute("name");
- String className = element.getAttribute("class");
- Contributor contributor = new Contributor(label, className, element, false);
+ for (final IConfigurationElement element : configs) {
+ final String label = element.getAttribute("name");
+ final String className = element.getAttribute("class");
+ final Contributor contributor = new Contributor(label, className, element, false);
contributors.put(className, contributor);
}
}
@@ -73,23 +69,25 @@ public class MetamodelContributorRegistry {
}
public static List<? extends MetamodelContributor> getActiveMetamodelContributors(final IJavaProject project) {
- ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(new InstanceScope(), Activator.getId());
- IScopeContext[] scopes = { new ProjectScope(project.getProject()), new InstanceScope() };
+ final ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(new InstanceScope(), Activator
+ .getId());
+ final IScopeContext[] scopes = { new ProjectScope(project.getProject()), new InstanceScope() };
scopedPreferenceStore.setSearchContexts(scopes);
fixMetamodelContributorPreferences(scopedPreferenceStore);
-
- String metamodelContr = scopedPreferenceStore.getString(PreferenceConstants.METAMODELCONTRIBUTORS);
- String[] mm = metamodelContr.split(",");
- List<MetamodelContributor> result = new ArrayList<MetamodelContributor>();
- for (String metamodelContributorName : mm) {
+ final String metamodelContr = scopedPreferenceStore.getString(PreferenceConstants.METAMODELCONTRIBUTORS);
+ final String[] mm = metamodelContr.split(",");
+
+ final List<MetamodelContributor> result = new ArrayList<MetamodelContributor>();
+ for (final String metamodelContributorName : mm) {
if (metamodelContributorName != null && !metamodelContributorName.equals("")) {
- MetamodelContributor metamodelContributor = MetamodelContributorRegistry.getMetamodelContributorByClassName(metamodelContributorName);
+ final MetamodelContributor metamodelContributor = MetamodelContributorRegistry
+ .getMetamodelContributorByClassName(metamodelContributorName);
if (metamodelContributor != null) {
result.add(metamodelContributor);
- } else {
- XtendLog.logInfo("Metamodel contributor '" + metamodelContributorName + "' is not available\n" +
- "Choose one of: "+ getAllAvailableMMContribsAsString());
+ }
+ else {
+ XtendLog.logInfo("Metamodel contributor '" + metamodelContributorName + "' is not available\n");
}
}
}
@@ -97,49 +95,22 @@ public class MetamodelContributorRegistry {
}
/**
- * fix: package name from UML2MetamodelContributor was wrong. For compatibility
- * reasons we fix this name here on the fly. Later we could offer a migration path.
+ * fix: package name from UML2MetamodelContributor was wrong. For
+ * compatibility reasons we fix this name here on the fly. Later we could
+ * offer a migration path.
*/
- private static void fixMetamodelContributorPreferences(IPreferenceStore prefStore) {
+ private static void fixMetamodelContributorPreferences(final IPreferenceStore prefStore) {
String metamodelContr = prefStore.getString(PreferenceConstants.METAMODELCONTRIBUTORS);
- if (metamodelContr.indexOf("openarchitecturware")>0) {
+ if (metamodelContr.indexOf("openarchitecturware") > 0) {
metamodelContr = metamodelContr.replace("openarchitecturware", "openarchitectureware");
prefStore.setValue(PreferenceConstants.METAMODELCONTRIBUTORS, metamodelContr);
}
}
-
- private static Map<String, MetamodelContributor> mmContributors = null;
- private static MetamodelContributor getMetamodelContributorByClassName(String metamodelContr) {
- if (mmContributors == null) {
- mmContributors = new HashMap<String, MetamodelContributor>();
- final IExtensionRegistry registry = Platform.getExtensionRegistry();
- final IExtensionPoint point = registry.getExtensionPoint(MetamodelContributorRegistry.CONTRIBUTOR_ID);
- if (point != null) {
- final IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- final IExtension extension = extensions[i];
- final IConfigurationElement[] configs = extension.getConfigurationElements();
- for (int j = 0; j < configs.length; j++) {
- final IConfigurationElement element = configs[j];
- try {
- mmContributors.put(element.getAttribute("class"), (MetamodelContributor) element.createExecutableExtension("class"));
- } catch (final CoreException e) {
- XtendLog.logError(e);
- }
- }
- }
- }
- }
- return mmContributors.get(metamodelContr);
- }
-
- private static String getAllAvailableMMContribsAsString() {
- StringBuffer sb = new StringBuffer();
- for (String s : mmContributors.keySet()) {
- sb.append(s);
- sb.append("\n");
- }
- return sb.toString();
+ private static MetamodelContributor getMetamodelContributorByClassName(final String metamodelContr) {
+ final Contributor contributor = getRegisteredMetamodelContributors().get(metamodelContr);
+ if (contributor == null)
+ return null;
+ return contributor.getMetaModelContributor();
}
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/JdtTypeImpl.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/JdtTypeImpl.java
index b41673d..78248c2 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/JdtTypeImpl.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/JdtTypeImpl.java
@@ -111,7 +111,7 @@ public class JdtTypeImpl extends AbstractTypeImpl implements Type {
}
/**
- * Returns the oAW Type instance for an IField instance.
+ * Returns the Xtend Type instance for an IField instance.
*
* @param field
* @return
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/javabean/JdtJavaBeanTypeStrategy.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/javabean/JdtJavaBeanTypeStrategy.java
index 5b2e652..f0ea42c 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/javabean/JdtJavaBeanTypeStrategy.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/metamodel/jdt/javabean/JdtJavaBeanTypeStrategy.java
@@ -24,8 +24,7 @@ import org.eclipse.xtend.shared.ui.core.metamodel.jdt.JdtTypeStrategy;
public class JdtJavaBeanTypeStrategy implements JdtTypeStrategy {
- public JdtJavaBeanTypeStrategy(
- final IJavaProject project) {
+ public JdtJavaBeanTypeStrategy (final IJavaProject project) {
super();
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/properties/MetamodelContributorsPropertyAndPreferencePage.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/properties/MetamodelContributorsPropertyAndPreferencePage.java
index c958545..92b5424 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/properties/MetamodelContributorsPropertyAndPreferencePage.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/properties/MetamodelContributorsPropertyAndPreferencePage.java
@@ -61,8 +61,8 @@ import org.eclipse.xtend.shared.ui.internal.XtendLog;
* @author Peter Friese
* @author Dennis Huebner
*/
-public class MetamodelContributorsPropertyAndPreferencePage extends
- PropertyAndPreferencePage {
+@SuppressWarnings("restriction")
+public class MetamodelContributorsPropertyAndPreferencePage extends PropertyAndPreferencePage {
private Button downButton;
private Button upButton;
@@ -70,17 +70,16 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
/**
* Renders a human readable representation of the meta model contributors.
*/
- class TableLabelProvider extends LabelProvider implements
- ITableLabelProvider {
- public String getColumnText(Object element, int columnIndex) {
+ class TableLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(final Object element, final int columnIndex) {
if (element instanceof Contributor) {
- Contributor contributor = (Contributor) element;
+ final Contributor contributor = (Contributor) element;
return contributor.getDisplayName();
}
return element.toString();
}
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(final Object element, final int columnIndex) {
return null;
}
}
@@ -92,33 +91,31 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
private List<Contributor> availableMetamodelContributors;
private Table table;
- private List<Contributor> getMetamodelContributors(boolean includeDisabled) {
- Map<String, Contributor> availableMetamodelContributors = MetamodelContributorRegistry
+ private List<Contributor> getMetamodelContributors(final boolean includeDisabled) {
+ final Map<String, Contributor> availableMetamodelContributors = MetamodelContributorRegistry
.getRegisteredMetamodelContributors();
// retrieve all configured metamodels
prefStore = getPreferenceStore();
fixMetamodelContributorPreferences(prefStore);
- String rawString = prefStore
- .getString(PreferenceConstants.METAMODELCONTRIBUTORS);
+ final String rawString = prefStore.getString(PreferenceConstants.METAMODELCONTRIBUTORS);
- List<Contributor> result = new ArrayList<Contributor>();
+ final List<Contributor> result = new ArrayList<Contributor>();
// first, get all enabled contributors
if (isNotEmpty(rawString)) {
- String[] selected = rawString.split(",");
+ final String[] selected = rawString.split(",");
- for (String metaModelContributorClassName : selected) {
- Contributor contributor = availableMetamodelContributors
- .get(metaModelContributorClassName);
- if (contributor != null)
+ for (final String metaModelContributorClassName : selected) {
+ final Contributor contributor = availableMetamodelContributors.get(metaModelContributorClassName);
+ if (contributor != null) {
result.add(contributor);
+ }
}
}
if (includeDisabled) {
// now, get disabled contributors
- for (Contributor contributor : availableMetamodelContributors
- .values()) {
+ for (final Contributor contributor : availableMetamodelContributors.values()) {
if (!result.contains(contributor)) {
result.add(contributor);
}
@@ -133,19 +130,15 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
* compatibility reasons we fix this name here on the fly. Later we could
* offer a migration path.
*/
- private static void fixMetamodelContributorPreferences(
- IPreferenceStore prefStore) {
- String metamodelContr = prefStore
- .getString(PreferenceConstants.METAMODELCONTRIBUTORS);
+ private static void fixMetamodelContributorPreferences(final IPreferenceStore prefStore) {
+ String metamodelContr = prefStore.getString(PreferenceConstants.METAMODELCONTRIBUTORS);
if (metamodelContr.indexOf("openarchitecturware") > 0) {
- metamodelContr = metamodelContr.replace("openarchitecturware",
- "openarchitectureware");
- prefStore.setValue(PreferenceConstants.METAMODELCONTRIBUTORS,
- metamodelContr);
+ metamodelContr = metamodelContr.replace("openarchitecturware", "openarchitectureware");
+ prefStore.setValue(PreferenceConstants.METAMODELCONTRIBUTORS, metamodelContr);
}
}
- private boolean isNotEmpty(String rawString) {
+ private boolean isNotEmpty(final String rawString) {
return rawString != null && !rawString.equals("");
}
@@ -154,33 +147,34 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
IPreferenceStore store;
if (isProjectPreferencePage()) {
// get java project
- IProject project = getProject();
- store = new ScopedPreferenceStore(new ProjectScope(project),
- Activator.getId());
- } else {
- store = new ScopedPreferenceStore(new InstanceScope(), Activator
- .getId());
+ final IProject project = getProject();
+ store = new ScopedPreferenceStore(new ProjectScope(project), Activator.getId());
+ }
+ else {
+ store = new ScopedPreferenceStore(new InstanceScope(), Activator.getId());
}
return store;
}
private void updateButtonStates() {
- int index = table.getSelectionIndex();
+ final int index = table.getSelectionIndex();
if (index == 0) {
upButton.setEnabled(false);
- } else {
+ }
+ else {
upButton.setEnabled(true);
}
if (index >= checkboxTableViewer.getTable().getItemCount() - 1) {
downButton.setEnabled(false);
- } else {
+ }
+ else {
downButton.setEnabled(true);
}
}
@Override
- protected Control createPreferenceContent(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
+ protected Control createPreferenceContent(final Composite parent) {
+ final Composite container = new Composite(parent, SWT.NULL);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.marginHeight = 0;
@@ -188,19 +182,17 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
gridLayout.marginWidth = 0;
container.setLayout(gridLayout);
- final Label activatedMetamodelContributorsLabel = new Label(container,
- SWT.NONE);
- activatedMetamodelContributorsLabel
- .setText("&Activated metamodel contributors:");
+ final Label activatedMetamodelContributorsLabel = new Label(container, SWT.NONE);
+ activatedMetamodelContributorsLabel.setText("&Activated metamodel contributors:");
new Label(container, SWT.NONE);
- checkboxTableViewer = CheckboxTableViewer.newCheckList(container,
- SWT.BORDER);
+ checkboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER);
checkboxTableViewer.setLabelProvider(new TableLabelProvider());
checkboxTableViewer.setContentProvider(new ArrayContentProvider());
table = checkboxTableViewer.getTable();
table.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
updateButtonStates();
}
@@ -208,59 +200,54 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final Composite composite = new Composite(container, SWT.NONE);
- composite
- .setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
+ composite.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
final GridLayout gridLayout_1 = new GridLayout();
composite.setLayout(gridLayout_1);
upButton = new Button(composite, SWT.NONE);
upButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- ISelection selection = checkboxTableViewer.getSelection();
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ final ISelection selection = checkboxTableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object firstElement = structuredSelection.getFirstElement();
+ final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ final Object firstElement = structuredSelection.getFirstElement();
if (firstElement instanceof Contributor) {
- Contributor contributor = (Contributor) firstElement;
- int index = availableMetamodelContributors
- .indexOf(contributor);
+ final Contributor contributor = (Contributor) firstElement;
+ final int index = availableMetamodelContributors.indexOf(contributor);
availableMetamodelContributors.remove(contributor);
- availableMetamodelContributors.add(index - 1,
- contributor);
+ availableMetamodelContributors.add(index - 1, contributor);
checkboxTableViewer.refresh();
}
}
updateButtonStates();
}
});
- final GridData gridData_1 = new GridData(SWT.FILL, SWT.CENTER, false,
- false);
+ final GridData gridData_1 = new GridData(SWT.FILL, SWT.CENTER, false, false);
gridData_1.widthHint = 75;
upButton.setLayoutData(gridData_1);
upButton.setText("&Up");
downButton = new Button(composite, SWT.NONE);
downButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- ISelection selection = checkboxTableViewer.getSelection();
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ final ISelection selection = checkboxTableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object firstElement = structuredSelection.getFirstElement();
+ final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ final Object firstElement = structuredSelection.getFirstElement();
if (firstElement instanceof Contributor) {
- Contributor contributor = (Contributor) firstElement;
- int index = availableMetamodelContributors
- .indexOf(contributor);
+ final Contributor contributor = (Contributor) firstElement;
+ final int index = availableMetamodelContributors.indexOf(contributor);
availableMetamodelContributors.remove(contributor);
- availableMetamodelContributors.add(index + 1,
- contributor);
+ availableMetamodelContributors.add(index + 1, contributor);
checkboxTableViewer.refresh();
}
}
updateButtonStates();
}
});
- final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, false,
- false);
+ final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
gridData.widthHint = 75;
downButton.setLayoutData(gridData);
downButton.setText("&Down");
@@ -277,9 +264,8 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
availableMetamodelContributors = getMetamodelContributors(true);
checkboxTableViewer.setInput(availableMetamodelContributors);
- Collection<Contributor> enabledMetamodelContributors = getMetamodelContributors(false);
- checkboxTableViewer.setCheckedElements(enabledMetamodelContributors
- .toArray());
+ final Collection<Contributor> enabledMetamodelContributors = getMetamodelContributors(false);
+ checkboxTableViewer.setCheckedElements(enabledMetamodelContributors.toArray());
}
@Override
@@ -293,23 +279,21 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
}
@Override
- protected boolean hasProjectSpecificOptions(IProject project) {
- IPreferenceStore preferenceStore = getPreferenceStore();
- return preferenceStore
- .getBoolean(PreferenceConstants.PROJECT_SPECIFIC_METAMODEL);
+ protected boolean hasProjectSpecificOptions(final IProject project) {
+ final IPreferenceStore preferenceStore = getPreferenceStore();
+ return preferenceStore.getBoolean(PreferenceConstants.PROJECT_SPECIFIC_METAMODEL);
}
@Override
public boolean performOk() {
if (isProjectPreferencePage()) {
- prefStore.setValue(PreferenceConstants.PROJECT_SPECIFIC_METAMODEL,
- useProjectSettings());
+ prefStore.setValue(PreferenceConstants.PROJECT_SPECIFIC_METAMODEL, useProjectSettings());
}
- prefStore.setValue(PreferenceConstants.METAMODELCONTRIBUTORS,
- createStoreString());
+ prefStore.setValue(PreferenceConstants.METAMODELCONTRIBUTORS, createStoreString());
try {
((ScopedPreferenceStore) prefStore).save();
- } catch (IOException e1) {
+ }
+ catch (final IOException e1) {
XtendLog.logError(e1);
}
@@ -317,39 +301,37 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
final IProject project = getProject();
final Job job = new Job("Analyzing " + project.getName() + " ...") {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ protected IStatus run(final IProgressMonitor monitor) {
try {
new WorkspaceModifyOperation() {
@Override
- protected void execute(IProgressMonitor monitor)
- throws CoreException,
- java.lang.reflect.InvocationTargetException,
- InterruptedException {
- IXtendXpandProject p = Activator
- .getExtXptModelManager().findProject(
- project);
+ protected void execute(final IProgressMonitor monitor) throws CoreException,
+ java.lang.reflect.InvocationTargetException, InterruptedException {
+ final IXtendXpandProject p = Activator.getExtXptModelManager().findProject(project);
if (p != null) {
- monitor.beginTask("...", p
- .getRegisteredResources().length);
+ monitor.beginTask("...", p.getRegisteredResources().length);
p.analyze(monitor);
monitor.done();
}
}
}.run(monitor);
- } catch (InvocationTargetException e) {
+ }
+ catch (final InvocationTargetException e) {
XtendLog.logError(e);
- } catch (InterruptedException e) {
+ }
+ catch (final InterruptedException e) {
XtendLog.logError(e);
}
return Status.OK_STATUS;
}
};
job.schedule();
- } else {
- final Job job = new Job("Analyzing all oAW projects...") {
+ }
+ else {
+ final Job job = new Job("Analyzing all Xtend projects...") {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ protected IStatus run(final IProgressMonitor monitor) {
Activator.getExtXptModelManager().analyze(monitor);
return Status.OK_STATUS;
}
@@ -365,13 +347,13 @@ public class MetamodelContributorsPropertyAndPreferencePage extends
* @return
*/
private String createStoreString() {
- Object[] checkedElements = checkboxTableViewer.getCheckedElements();
+ final Object[] checkedElements = checkboxTableViewer.getCheckedElements();
String result = "";
for (int i = 0; i < checkedElements.length; i++) {
- Object object = checkedElements[i];
+ final Object object = checkedElements[i];
if (object instanceof Contributor) {
- Contributor contributor = (Contributor) object;
- String className = contributor.getClassName();
+ final Contributor contributor = (Contributor) object;
+ final String className = contributor.getClassName();
result += className;
}
if (i < checkedElements.length - 1) {
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/search/XtendXpandSearchEngine.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/search/XtendXpandSearchEngine.java
index 189e37f..56bed88 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/search/XtendXpandSearchEngine.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/core/search/XtendXpandSearchEngine.java
@@ -38,7 +38,7 @@ import org.eclipse.xtend.shared.ui.core.IXtendXpandResource;
import org.eclipse.xtend.shared.ui.internal.XtendLog;
/**
- * Search engine for oAW.
+ * Search engine for Xtend.
*
* @author Sven Efftinge (http://www.efftinge.de)
* @author Peter Friese
@@ -103,9 +103,9 @@ public class XtendXpandSearchEngine {
}
for (IProject p : project.getProject().getProject().getReferencingProjects()) {
- IXtendXpandProject oawp = Activator.getExtXptModelManager().findProject(p);
- if (oawp != null) {
- matches.addAll(findAllOccurrences(oawp, identifier));
+ IXtendXpandProject extxptp = Activator.getExtXptModelManager().findProject(p);
+ if (extxptp != null) {
+ matches.addAll(findAllOccurrences(extxptp, identifier));
}
}
return sort(matches);
@@ -130,9 +130,9 @@ public class XtendXpandSearchEngine {
}
}
for (IProject p : project.getProject().getProject().getReferencingProjects()) {
- IXtendXpandProject oawp = Activator.getExtXptModelManager().findProject(p);
- if (oawp != null) {
- matches.addAll(findReferences(oawp, identifier));
+ IXtendXpandProject extxptp = Activator.getExtXptModelManager().findProject(p);
+ if (extxptp != null) {
+ matches.addAll(findReferences(extxptp, identifier));
}
}
return sort(matches);
@@ -180,9 +180,9 @@ public class XtendXpandSearchEngine {
}
try {
for (IProject p : project.getProject().getProject().getReferencedProjects()) {
- IXtendXpandProject oawp = Activator.getExtXptModelManager().findProject(p);
- if (oawp != null) {
- matches.addAll(findDeclarations(oawp, identifier));
+ IXtendXpandProject extxptp = Activator.getExtXptModelManager().findProject(p);
+ if (extxptp != null) {
+ matches.addAll(findDeclarations(extxptp, identifier));
}
}
} catch (CoreException e) {
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/AbstractXtendXpandEditor.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/AbstractXtendXpandEditor.java
index 20b2a5f..5324690 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/AbstractXtendXpandEditor.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/AbstractXtendXpandEditor.java
@@ -47,7 +47,7 @@ public abstract class AbstractXtendXpandEditor extends TextEditor {
}
@Override
- public void doSave(IProgressMonitor aMonitor) {
+ public void doSave(final IProgressMonitor aMonitor) {
super.doSave(aMonitor);
if (outlinePage != null) {
this.outlinePage.refresh();
@@ -63,11 +63,11 @@ public abstract class AbstractXtendXpandEditor extends TextEditor {
}
@Override
- protected void editorContextMenuAboutToShow(IMenuManager menu) {
+ protected void editorContextMenuAboutToShow(final IMenuManager menu) {
menu.add(new Separator("mwe"));
super.editorContextMenuAboutToShow(menu);
- ActionContext context = new ActionContext(getSelectionProvider().getSelection());
+ final ActionContext context = new ActionContext(getSelectionProvider().getSelection());
searchActionGroup.setContext(context);
searchActionGroup.fillContextMenu(menu);
searchActionGroup.setContext(null);
@@ -104,7 +104,7 @@ public abstract class AbstractXtendXpandEditor extends TextEditor {
}
@Override
- protected Object handleGetObject(String key) {
+ protected Object handleGetObject(final String key) {
return null;
}
};
@@ -119,7 +119,7 @@ public abstract class AbstractXtendXpandEditor extends TextEditor {
setAction("ContentAssistTip", a);
// hyperlinking and F3 support
- OpenAction openAction = new OpenAction(this);
+ final OpenAction openAction = new OpenAction(this);
openAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR);
setAction(JdtActionConstants.OPEN, openAction);
@@ -131,8 +131,8 @@ public abstract class AbstractXtendXpandEditor extends TextEditor {
}
@Override
- protected void rulerContextMenuAboutToShow(IMenuManager menu) {
- menu.add(new Separator("oaw")); //$NON-NLS-1$
+ protected void rulerContextMenuAboutToShow(final IMenuManager menu) {
+ menu.add(new Separator("Xpand")); //$NON-NLS-1$
super.rulerContextMenuAboutToShow(menu);
bpActionGroup.fillContextMenu(menu);
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/IOawEditorActionDefinitionIds.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/IXpandXtendEditorActionDefinitionIds.java
index 87d7901..14e930f 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/IOawEditorActionDefinitionIds.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/IXpandXtendEditorActionDefinitionIds.java
@@ -21,7 +21,7 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
*
* @since 2.0
*/
-public interface IOawEditorActionDefinitionIds extends ITextEditorActionDefinitionIds {
+public interface IXpandXtendEditorActionDefinitionIds extends ITextEditorActionDefinitionIds {
// search
@@ -30,7 +30,7 @@ public interface IOawEditorActionDefinitionIds extends ITextEditorActionDefiniti
* (value
* <code>"org.eclipse.jdt.ui.edit.text.java.search.references.in.workspace"</code>).
*/
- public static final String SEARCH_REFERENCES_IN_WORKSPACE = "org.eclipse.internal.xtend.editor.search.references.in.workspace"; //$NON-NLS-1$
+ public static final String SEARCH_REFERENCES_IN_WORKSPACE = "org.eclipse.editor.search.references.in.workspace"; //$NON-NLS-1$
/**
* Action definition ID of the search -> references in project action (value
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlink.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlink.java
index d34ed99..1f7e049 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlink.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlink.java
@@ -22,7 +22,7 @@ import org.eclipse.xtend.shared.ui.core.search.SearchMatch;
import org.eclipse.xtend.shared.ui.internal.XtendLog;
/**
- * GenericHyperlink is used by oAW editors to support hyperlinking and F3
+ * GenericHyperlink is used by Xtend editors to support hyperlinking and F3
* lookup.
*
* @author Peter Friese
@@ -38,8 +38,8 @@ public class GenericHyperlink implements IHyperlink {
/**
* Creates a new Generic hyperlink.
*/
- public GenericHyperlink(IWorkbenchPage workbenchPage, SearchMatch searchMatch, IRegion region,
- String identifierString) {
+ public GenericHyperlink(final IWorkbenchPage workbenchPage, final SearchMatch searchMatch, final IRegion region,
+ final String identifierString) {
Assert.isNotNull(workbenchPage);
Assert.isNotNull(identifierString);
Assert.isNotNull(region);
@@ -55,12 +55,13 @@ public class GenericHyperlink implements IHyperlink {
public void open() {
try {
if (searchMatch.getFile() != null) {
- IEditorPart opened = IDE.openEditor(workbenchPage, searchMatch.getFile());
+ final IEditorPart opened = IDE.openEditor(workbenchPage, searchMatch.getFile());
if (opened instanceof ITextEditor) {
((ITextEditor) opened).selectAndReveal(searchMatch.getOffSet(), searchMatch.getLength());
}
}
- } catch (PartInitException e) {
+ }
+ catch (final PartInitException e) {
XtendLog.logError(e);
}
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlinkDetector.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlinkDetector.java
index 8ec163d..d1fd25d 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlinkDetector.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/navigation/GenericHyperlinkDetector.java
@@ -27,7 +27,7 @@ import org.eclipse.xtend.shared.ui.core.search.SearchMatch;
import org.eclipse.xtend.shared.ui.core.search.XtendXpandSearchEngine;
/**
- * GenericHyperlinkDetector is used to detect hyperlinkable words inside oAW
+ * GenericHyperlinkDetector is used to detect hyperlinkable words inside Xtend
* editors.
*
* @author Peter Friese
@@ -58,7 +58,7 @@ public class GenericHyperlinkDetector implements IHyperlinkDetector {
String hyperlinkedWord = textViewer.getDocument().get().substring(hyperlinkRegion.getOffset(),
hyperlinkRegion.getOffset() + hyperlinkRegion.getLength());
- IXtendXpandProject project = getOawProject();
+ IXtendXpandProject project = getXtendXpandProject();
if (project != null) {
List<SearchMatch> matches = XtendXpandSearchEngine.findDeclarations(project, hyperlinkedWord);
List<GenericHyperlink> links = new ArrayList<GenericHyperlink>();
@@ -67,12 +67,15 @@ public class GenericHyperlinkDetector implements IHyperlinkDetector {
hyperlinkRegion, hyperlinkedWord);
links.add(genericHyperlink);
}
+ // must return null if no links found
+ if (!links.isEmpty()) {
if (canShowMultipleHyperlinks) {
return links.toArray(new IHyperlink[links.size()]);
- } else if (!links.isEmpty()) {
+ } else {
return new IHyperlink[] { links.get(0) };
}
}
+ }
return null;
}
@@ -80,7 +83,7 @@ public class GenericHyperlinkDetector implements IHyperlinkDetector {
return editor.getSite().getWorkbenchWindow().getActivePage();
}
- private IXtendXpandProject getOawProject() {
+ private IXtendXpandProject getXtendXpandProject() {
IFile file = getFile();
if (file == null) {
return null;
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/outlineview/AbstractExtXptContentOutlinePage.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/outlineview/AbstractExtXptContentOutlinePage.java
index 7ac3ca2..fe1060b 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/outlineview/AbstractExtXptContentOutlinePage.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/outlineview/AbstractExtXptContentOutlinePage.java
@@ -237,11 +237,11 @@ public abstract class AbstractExtXptContentOutlinePage extends ContentOutlinePag
super();
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, LEXICAL_SORTING_OUTLINE_ACTION);
- setText(Messages.AbstractOawContentOutlinePage_1);
+ setText(Messages.AbstractXtendXpandContentOutlinePage_1);
this.setImageDescriptor(Activator.getImageDescriptor("icons/alphab_sort_co.gif")); //$NON-NLS-1$
- setToolTipText(Messages.AbstractOawContentOutlinePage_3);
- setDescription(Messages.AbstractOawContentOutlinePage_4);
+ setToolTipText(Messages.AbstractXtendXpandContentOutlinePage_3);
+ setDescription(Messages.AbstractXtendXpandContentOutlinePage_4);
boolean checked = Activator.getDefault().getPreferenceStore().getBoolean("LexicalSortingAction.isChecked"); //$NON-NLS-1$
valueChanged(checked, false);
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/DeclarationsSearchGroup.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/DeclarationsSearchGroup.java
index 369c1bb..99af885 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/DeclarationsSearchGroup.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/DeclarationsSearchGroup.java
@@ -29,7 +29,7 @@ import org.eclipse.ui.navigator.ICommonMenuConstants;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.xtend.shared.ui.core.action.SelectionDispatchAction;
import org.eclipse.xtend.shared.ui.editor.AbstractXtendXpandEditor;
-import org.eclipse.xtend.shared.ui.editor.IOawEditorActionDefinitionIds;
+import org.eclipse.xtend.shared.ui.editor.IXpandXtendEditorActionDefinitionIds;
/**
* Action group that adds the search for declarations actions to a context menu
@@ -54,17 +54,17 @@ public class DeclarationsSearchGroup extends ActionGroup {
* @param site
* The workbench site that owns this action group
*/
- public DeclarationsSearchGroup(IWorkbenchSite site) {
+ public DeclarationsSearchGroup(final IWorkbenchSite site) {
this.site = site;
groupId = ICommonMenuConstants.GROUP_SEARCH;
findDeclarationsAction = new FindDeclarationsAction(site);
- findDeclarationsAction.setActionDefinitionId(IOawEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKSPACE);
+ findDeclarationsAction.setActionDefinitionId(IXpandXtendEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKSPACE);
// register the actions as selection listeners
- ISelectionProvider provider = site.getSelectionProvider();
- ISelection selection = provider.getSelection();
+ final ISelectionProvider provider = site.getSelectionProvider();
+ final ISelection selection = provider.getSelection();
registerAction(findDeclarationsAction, provider, selection);
}
@@ -73,9 +73,9 @@ public class DeclarationsSearchGroup extends ActionGroup {
* this constructor.
*
* @param editor
- * The oAW editor
+ * the editor
*/
- protected DeclarationsSearchGroup(AbstractXtendXpandEditor editor) {
+ protected DeclarationsSearchGroup(final AbstractXtendXpandEditor editor) {
Assert.isNotNull(editor);
site = editor.getSite();
groupId = ITextEditorActionConstants.GROUP_FIND;
@@ -86,19 +86,20 @@ public class DeclarationsSearchGroup extends ActionGroup {
}
- private void addAction(IAction action, IMenuManager manager) {
+ private void addAction(final IAction action, final IMenuManager manager) {
if (action.isEnabled()) {
manager.add(action);
}
}
- private void registerAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection) {
+ private void registerAction(final SelectionDispatchAction action, final ISelectionProvider provider,
+ final ISelection selection) {
action.update(selection);
provider.addSelectionChangedListener(action);
}
@Override
- public void fillActionBars(IActionBars actionBars) {
+ public void fillActionBars(final IActionBars actionBars) {
Assert.isNotNull(actionBars);
super.fillActionBars(actionBars);
this.actionBars = actionBars;
@@ -106,8 +107,8 @@ public class DeclarationsSearchGroup extends ActionGroup {
}
@Override
- public void fillContextMenu(IMenuManager manager) {
- IMenuManager menuManager = new MenuManager("Dec&larations", IContextMenuConstants.GROUP_SEARCH);
+ public void fillContextMenu(final IMenuManager manager) {
+ final IMenuManager menuManager = new MenuManager("Dec&larations", IContextMenuConstants.GROUP_SEARCH);
addAction(findDeclarationsAction, menuManager);
menuManager.add(new Separator());
@@ -119,7 +120,7 @@ public class DeclarationsSearchGroup extends ActionGroup {
@Override
public void dispose() {
- ISelectionProvider provider = site.getSelectionProvider();
+ final ISelectionProvider provider = site.getSelectionProvider();
if (provider != null) {
disposeAction(findDeclarationsAction, provider);
}
@@ -135,7 +136,7 @@ public class DeclarationsSearchGroup extends ActionGroup {
}
}
- private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) {
+ private void disposeAction(final ISelectionChangedListener action, final ISelectionProvider provider) {
if (action != null) {
provider.removeSelectionChangedListener(action);
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindAction.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindAction.java
index a2a28dc..75ffa44 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindAction.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindAction.java
@@ -21,7 +21,7 @@ import org.eclipse.xtend.shared.ui.core.action.SelectionDispatchAction;
import org.eclipse.xtend.shared.ui.editor.AbstractXtendXpandEditor;
/**
- * Abstract class for oAW search actions.
+ * Abstract class for Xtend search actions.
*
* Note: This class is for internal use only. Clients should not use this class.
*/
@@ -59,11 +59,11 @@ public abstract class FindAction extends SelectionDispatchAction {
abstract void init();
/**
- * Returns the oAW project associated with the currently edited file.
+ * Returns the Xtend project associated with the currently edited file.
*
- * @return A reference to the current oAW project.
+ * @return A reference to the current Xtend project.
*/
- protected IXtendXpandProject getOawProject() {
+ protected IXtendXpandProject getXtendXpandProject() {
IFile file = getActiveFile();
if (file == null) {
return null;
@@ -92,7 +92,7 @@ public abstract class FindAction extends SelectionDispatchAction {
@Override
public void run(ITextSelection selection) {
String selectedText = selection.getText();
- IXtendXpandProject project = getOawProject();
+ IXtendXpandProject project = getXtendXpandProject();
ISearchQuery query = createSearchQuery(selectedText, project);
NewSearchUI.runQuery(query);
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindDeclarationsAction.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindDeclarationsAction.java
index 254ab8c..c1b75a2 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindDeclarationsAction.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindDeclarationsAction.java
@@ -14,12 +14,12 @@ import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.xtend.shared.ui.core.IXtendXpandProject;
import org.eclipse.xtend.shared.ui.editor.AbstractXtendXpandEditor;
-import org.eclipse.xtend.shared.ui.editor.search.query.OawSearchDeclarationsQuery;
+import org.eclipse.xtend.shared.ui.editor.search.query.XpandXtendSearchDeclarationsQuery;
import org.eclipse.xtend.shared.ui.expression.editor.EditorImages;
/**
* Finds declarations of the selected element in the workspace. The action is
- * applicable to selections representing an oAW element.
+ * applicable to selections representing an Xtend element.
*
* This class may be instantiated; it is not intended to be subclassed.
*/
@@ -29,9 +29,9 @@ public class FindDeclarationsAction extends FindAction {
* Creates a new {@link FindDeclarationsAction}.
*
* @param editor
- * The oAW editor.
+ * thr editor
*/
- public FindDeclarationsAction(AbstractXtendXpandEditor editor) {
+ public FindDeclarationsAction(final AbstractXtendXpandEditor editor) {
super(editor);
}
@@ -39,9 +39,9 @@ public class FindDeclarationsAction extends FindAction {
* Creates a new {@link FindDeclarationsAction}.
*
* @param site
- * The workbench site that owns this action.
+ * the workbench site that owns this action
*/
- public FindDeclarationsAction(IWorkbenchSite site) {
+ public FindDeclarationsAction(final IWorkbenchSite site) {
super(site);
}
@@ -53,8 +53,8 @@ public class FindDeclarationsAction extends FindAction {
}
@Override
- protected ISearchQuery createSearchQuery(String selectedText, IXtendXpandProject project) {
- ISearchQuery query = new OawSearchDeclarationsQuery(project, selectedText);
+ protected ISearchQuery createSearchQuery(final String selectedText, final IXtendXpandProject project) {
+ final ISearchQuery query = new XpandXtendSearchDeclarationsQuery(project, selectedText);
return query;
}
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindReferencesAction.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindReferencesAction.java
index df70f8f..56842fa 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindReferencesAction.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/FindReferencesAction.java
@@ -14,12 +14,12 @@ import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.xtend.shared.ui.core.IXtendXpandProject;
import org.eclipse.xtend.shared.ui.editor.AbstractXtendXpandEditor;
-import org.eclipse.xtend.shared.ui.editor.search.query.OawSearchReferencesQuery;
+import org.eclipse.xtend.shared.ui.editor.search.query.XtendXpandSearchReferencesQuery;
import org.eclipse.xtend.shared.ui.expression.editor.EditorImages;
/**
* Finds references to the selected element in the workspace. The action is
- * applicable to selections representing an oAW element.
+ * applicable to selections representing an Xtend element.
*
* This class may be instantiated; it is not intended to be subclassed.
*/
@@ -29,7 +29,7 @@ public class FindReferencesAction extends FindAction {
* Creates a new {@link FindDeclarationsAction}.
*
* @param editor
- * The oAW editor.
+ * The Xtend editor.
*/
public FindReferencesAction(AbstractXtendXpandEditor editor) {
super(editor);
@@ -54,7 +54,7 @@ public class FindReferencesAction extends FindAction {
@Override
protected ISearchQuery createSearchQuery(String selectedText, IXtendXpandProject project) {
- ISearchQuery query = new OawSearchReferencesQuery(project, selectedText);
+ ISearchQuery query = new XtendXpandSearchReferencesQuery(project, selectedText);
return query;
}
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/ReferencesSearchGroup.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/ReferencesSearchGroup.java
index d97f76e..c74f2b1 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/ReferencesSearchGroup.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/ReferencesSearchGroup.java
@@ -52,7 +52,7 @@ public class ReferencesSearchGroup extends ActionGroup {
* @param site
* The workbench site that owns this action group
*/
- public ReferencesSearchGroup(IWorkbenchSite site) {
+ public ReferencesSearchGroup(final IWorkbenchSite site) {
this.site = site;
groupId = IContextMenuConstants.GROUP_SEARCH;
@@ -60,8 +60,8 @@ public class ReferencesSearchGroup extends ActionGroup {
findReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKSPACE);
// register the actions as selection listeners
- ISelectionProvider provider = site.getSelectionProvider();
- ISelection selection = provider.getSelection();
+ final ISelectionProvider provider = site.getSelectionProvider();
+ final ISelection selection = provider.getSelection();
registerAction(findReferencesAction, provider, selection);
}
@@ -70,9 +70,9 @@ public class ReferencesSearchGroup extends ActionGroup {
* this constructor.
*
* @param editor
- * The oAW editor
+ * ehe editor
*/
- protected ReferencesSearchGroup(AbstractXtendXpandEditor editor) {
+ protected ReferencesSearchGroup(final AbstractXtendXpandEditor editor) {
Assert.isNotNull(editor);
site = editor.getSite();
groupId = ITextEditorActionConstants.GROUP_FIND;
@@ -83,19 +83,20 @@ public class ReferencesSearchGroup extends ActionGroup {
}
- private void registerAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection) {
+ private void registerAction(final SelectionDispatchAction action, final ISelectionProvider provider,
+ final ISelection selection) {
action.update(selection);
provider.addSelectionChangedListener(action);
}
- private void addAction(IAction action, IMenuManager manager) {
+ private void addAction(final IAction action, final IMenuManager manager) {
if (action.isEnabled()) {
manager.add(action);
}
}
@Override
- public void fillActionBars(IActionBars actionBars) {
+ public void fillActionBars(final IActionBars actionBars) {
Assert.isNotNull(actionBars);
super.fillActionBars(actionBars);
this.actionBars = actionBars;
@@ -103,8 +104,8 @@ public class ReferencesSearchGroup extends ActionGroup {
}
@Override
- public void fillContextMenu(IMenuManager manager) {
- IMenuManager menuManager = new MenuManager("Re&ferences", IContextMenuConstants.GROUP_SEARCH);
+ public void fillContextMenu(final IMenuManager manager) {
+ final IMenuManager menuManager = new MenuManager("Re&ferences", IContextMenuConstants.GROUP_SEARCH);
addAction(findReferencesAction, menuManager);
menuManager.add(new Separator());
@@ -116,7 +117,7 @@ public class ReferencesSearchGroup extends ActionGroup {
@Override
public void dispose() {
- ISelectionProvider provider = site.getSelectionProvider();
+ final ISelectionProvider provider = site.getSelectionProvider();
if (provider != null) {
disposeAction(findReferencesAction, provider);
}
@@ -131,7 +132,7 @@ public class ReferencesSearchGroup extends ActionGroup {
}
}
- private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) {
+ private void disposeAction(final ISelectionChangedListener action, final ISelectionProvider provider) {
if (action != null) {
provider.removeSelectionChangedListener(action);
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/SearchActionGroup.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/SearchActionGroup.java
index 208a71a..314d6d4 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/SearchActionGroup.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/actions/SearchActionGroup.java
@@ -26,7 +26,7 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.xtend.shared.ui.editor.AbstractXtendXpandEditor;
/**
- * Action group that adds the oAW search actions to a context menu and the
+ * Action group that adds the Xtend search actions to a context menu and the
* global menu bar.
*
* This class may be instantiated; it is not intended to be subclassed.
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchDeclarationsQuery.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XpandXtendSearchDeclarationsQuery.java
index 4b28959..c1669ae 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchDeclarationsQuery.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XpandXtendSearchDeclarationsQuery.java
@@ -17,22 +17,22 @@ import org.eclipse.xtend.shared.ui.core.search.SearchMatch;
import org.eclipse.xtend.shared.ui.core.search.XtendXpandSearchEngine;
/**
- * <code>OawSearchReferencesQuery</code> performs a query for declarations of
+ * <code>XtendXpandSearchReferencesQuery</code> performs a query for declarations of
* a given identifier.
*
* @author Peter Friese
*/
-public class OawSearchDeclarationsQuery extends OawSearchQuery {
+public class XpandXtendSearchDeclarationsQuery extends XtendXpandSearchQuery {
/**
- * Creates a new <code>OawSearchReferencesQuery</code>.
+ * Creates a new <code>XtendXpandSearchReferencesQuery</code>.
*
* @param project
* The project to operate on.
* @param identifier
* The identifier to look for.
*/
- public OawSearchDeclarationsQuery(IXtendXpandProject project, String identifier) {
+ public XpandXtendSearchDeclarationsQuery(IXtendXpandProject project, String identifier) {
super(project, identifier);
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchQuery.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchQuery.java
index aa8c618..f7e8aa4 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchQuery.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchQuery.java
@@ -25,27 +25,27 @@ import org.eclipse.xtend.shared.ui.core.IXtendXpandProject;
import org.eclipse.xtend.shared.ui.core.search.SearchMatch;
/**
- * <code>OawSearchQuery</code> is a base class for search queries. Queries
+ * <code>XtendXpandSearchQuery</code> is a base class for search queries. Queries
* contain the search parameters for the search and the code that performs the
* query as well.
*
* @author Peter Friese
*/
-public abstract class OawSearchQuery implements ISearchQuery {
+public abstract class XtendXpandSearchQuery implements ISearchQuery {
private final String identifier;
private final IXtendXpandProject project;
- private OawSearchResult result;
+ private XtendXpandSearchResult result;
/**
- * Creates a new <code>OawSearchQuery</code>.
+ * Creates a new <code>XtendXpandSearchQuery</code>.
*
* @param project
* The project to run this query on.
* @param identifier
* The identifier to look for.
*/
- public OawSearchQuery(IXtendXpandProject project, String identifier) {
+ public XtendXpandSearchQuery(IXtendXpandProject project, String identifier) {
this.project = project;
this.identifier = identifier;
}
@@ -98,7 +98,7 @@ public abstract class OawSearchQuery implements ISearchQuery {
*/
public ISearchResult getSearchResult() {
if (result == null) {
- result = new OawSearchResult(this);
+ result = new XtendXpandSearchResult(this);
}
return result;
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchReferencesQuery.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchReferencesQuery.java
index e13385d..5941658 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchReferencesQuery.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchReferencesQuery.java
@@ -17,22 +17,22 @@ import org.eclipse.xtend.shared.ui.core.search.SearchMatch;
import org.eclipse.xtend.shared.ui.core.search.XtendXpandSearchEngine;
/**
- * <code>OawSearchReferencesQuery</code> performs a query for references of a
+ * <code>XtendXpandSearchReferencesQuery</code> performs a query for references of a
* given identifier.
*
* @author Peter Friese
*/
-public class OawSearchReferencesQuery extends OawSearchQuery {
+public class XtendXpandSearchReferencesQuery extends XtendXpandSearchQuery {
/**
- * Creates a new <code>OawSearchReferencesQuery</code>.
+ * Creates a new <code>XtendXpandSearchReferencesQuery</code>.
*
* @param project
* The project to operate on.
* @param identifier
* The identifier to look for.
*/
- public OawSearchReferencesQuery(IXtendXpandProject project, String identifier) {
+ public XtendXpandSearchReferencesQuery(IXtendXpandProject project, String identifier) {
super(project, identifier);
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchResult.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchResult.java
index 859a48f..f3d9fc8 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/OawSearchResult.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/query/XtendXpandSearchResult.java
@@ -23,24 +23,24 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.xtend.shared.ui.expression.editor.EditorImages;
/**
- * <code>OawSearchResult</code> contains a list of text-based matches for a
+ * <code>XtendXpandSearchResult</code> contains a list of text-based matches for a
* given query.
*
* @author Peter Friese
*/
-public class OawSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
+public class XtendXpandSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
- private final OawSearchQuery query;
+ private final XtendXpandSearchQuery query;
private final Match[] EMPTY_ARR = new Match[0];
/**
- * Creates a new <code>OawSearchResult</code>.
+ * Creates a new <code>XtendXpandSearchResult</code>.
*
* @param query
* The query that yielded this result.
*/
- public OawSearchResult(OawSearchQuery query) {
+ public XtendXpandSearchResult(XtendXpandSearchQuery query) {
super();
this.query = query;
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/EditorOpener.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/EditorOpener.java
index 3b3f8fe..efa39f3 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/EditorOpener.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/EditorOpener.java
@@ -31,69 +31,68 @@ public class EditorOpener {
private IEditorPart fEditor;
- public IEditorPart open(IFile file, boolean activate) throws PartInitException {
- IWorkbenchPage wbPage = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if (NewSearchUI.reuseEditor()) {
+ public IEditorPart open(final IFile file, final boolean activate) throws PartInitException {
+ final IWorkbenchPage wbPage = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (NewSearchUI.reuseEditor())
return showWithReuse(file, wbPage, activate);
- }
return showWithoutReuse(file, wbPage, activate);
}
- private IEditorPart showWithoutReuse(IFile file, IWorkbenchPage wbPage, boolean activate) throws PartInitException {
+ private IEditorPart showWithoutReuse(final IFile file, final IWorkbenchPage wbPage, final boolean activate)
+ throws PartInitException {
return IDE.openEditor(wbPage, file, activate);
}
- private IEditorPart showWithReuse(IFile file, IWorkbenchPage wbPage, boolean activate) throws PartInitException {
- String editorID = getEditorID(file);
+ private IEditorPart showWithReuse(final IFile file, final IWorkbenchPage wbPage, final boolean activate)
+ throws PartInitException {
+ final String editorID = getEditorID(file);
return showInEditor(wbPage, file, editorID, activate);
}
- private String getEditorID(IFile file) throws PartInitException {
- IEditorDescriptor desc = IDE.getEditorDescriptor(file);
- if (desc == null) {
+ private String getEditorID(final IFile file) throws PartInitException {
+ final IEditorDescriptor desc = IDE.getEditorDescriptor(file);
+ if (desc == null)
return Activator.getDefault().getWorkbench().getEditorRegistry().findEditor(
IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).getId();
- }
return desc.getId();
}
- private boolean isPinned(IEditorPart editor) {
- if (editor == null) {
+ private boolean isPinned(final IEditorPart editor) {
+ if (editor == null)
return false;
- }
- IEditorReference[] editorRefs = editor.getEditorSite().getPage().getEditorReferences();
+ final IEditorReference[] editorRefs = editor.getEditorSite().getPage().getEditorReferences();
int i = 0;
while (i < editorRefs.length) {
- if (editor.equals(editorRefs[i].getEditor(false))) {
+ if (editor.equals(editorRefs[i].getEditor(false)))
return editorRefs[i].isPinned();
- }
i++;
}
return false;
}
- private IEditorPart showInEditor(IWorkbenchPage page, IFile file, String editorId, boolean activate)
- throws PartInitException {
- IFileEditorInput input = new FileEditorInput(file);
+ private IEditorPart showInEditor(final IWorkbenchPage page, final IFile file, final String editorId,
+ final boolean activate) throws PartInitException {
+ final IFileEditorInput input = new FileEditorInput(file);
IEditorPart editor = page.findEditor(input);
if (editor != null) {
page.bringToTop(editor);
if (activate) {
page.activate(editor);
}
- } else {
+ }
+ else {
boolean isOpen = false;
if (fEditor != null) {
- IEditorReference[] parts = page.getEditorReferences();
+ final IEditorReference[] parts = page.getEditorReferences();
int i = 0;
while (!isOpen && i < parts.length) {
isOpen = fEditor == parts[i++].getEditor(false);
}
}
- boolean canBeReused = isOpen && !fEditor.isDirty() && !isPinned(fEditor);
- boolean showsSameInputType = fEditor != null && fEditor.getSite().getId().equals(editorId);
+ final boolean canBeReused = isOpen && !fEditor.isDirty() && !isPinned(fEditor);
+ final boolean showsSameInputType = fEditor != null && fEditor.getSite().getId().equals(editorId);
if (canBeReused && !showsSameInputType) {
page.closeEditor(fEditor, false);
fEditor = null;
@@ -106,11 +105,13 @@ public class EditorOpener {
if (activate) {
page.activate(editor);
}
- } else {
+ }
+ else {
editor = IDE.openEditor(page, file, activate);
if (editor instanceof IReusableEditor) {
fEditor = editor;
- } else {
+ }
+ else {
fEditor = null;
}
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/OawSearchResultPage.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/XtendXpandSearchResultPage.java
index 6c75f65..0d4e2e6 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/OawSearchResultPage.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/XtendXpandSearchResultPage.java
@@ -47,15 +47,15 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.xtend.shared.ui.editor.search.query.OawSearchQuery;
+import org.eclipse.xtend.shared.ui.editor.search.query.XtendXpandSearchQuery;
/**
- * <code>OawSearchResultPage </code> displays the search results of an oAW
+ * <code>XtendXpandSearchResultPage </code> displays the search results of an Xtend
* related query.
*
* @author Peter Friese
*/
-public class OawSearchResultPage extends AbstractTextSearchViewPage implements IAdaptable {
+public class XtendXpandSearchResultPage extends AbstractTextSearchViewPage implements IAdaptable {
public static class DecoratorIgnoringViewerSorter extends ViewerComparator {
private final ILabelProvider labelProvider;
@@ -72,6 +72,7 @@ public class OawSearchResultPage extends AbstractTextSearchViewPage implements I
return 2;
}
+ @SuppressWarnings("unchecked")
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
int cat1 = category(e1);
@@ -97,18 +98,18 @@ public class OawSearchResultPage extends AbstractTextSearchViewPage implements I
private static final String KEY_SORTING = "org.eclipse.search.resultpage.sorting"; //$NON-NLS-1$
private ActionGroup actionGroup;
- private OawTableContentProvider contentProvider;
+ private XtendXpandTableContentProvider contentProvider;
private final EditorOpener editorOpener = new EditorOpener();
private static final String[] SHOW_IN_TARGETS = new String[] { IPageLayout.ID_RES_NAV };
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() {
public String[] getShowInTargetIds() {
- return OawSearchResultPage.SHOW_IN_TARGETS;
+ return XtendXpandSearchResultPage.SHOW_IN_TARGETS;
}
};
- public OawSearchResultPage() {
+ public XtendXpandSearchResultPage() {
super(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
}
@@ -130,9 +131,9 @@ public class OawSearchResultPage extends AbstractTextSearchViewPage implements I
WorkbenchLabelProvider innerLabelProvider = new WorkbenchLabelProvider();
viewer.setLabelProvider(new DecoratingLabelProvider(innerLabelProvider, PlatformUI.getWorkbench()
.getDecoratorManager().getLabelDecorator()));
- viewer.setContentProvider(new OawTableContentProvider(this));
+ viewer.setContentProvider(new XtendXpandTableContentProvider(this));
viewer.setComparator(new DecoratorIgnoringViewerSorter(innerLabelProvider));
- contentProvider = (OawTableContentProvider) viewer.getContentProvider();
+ contentProvider = (XtendXpandTableContentProvider) viewer.getContentProvider();
addDragAdapters(viewer);
}
@@ -195,7 +196,7 @@ public class OawSearchResultPage extends AbstractTextSearchViewPage implements I
actionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
actionGroup.fillContextMenu(mgr);
@SuppressWarnings("unused")
- OawSearchQuery query = (OawSearchQuery) getInput().getQuery();
+ XtendXpandSearchQuery query = (XtendXpandSearchQuery) getInput().getQuery();
}
private void addSortActions(IMenuManager mgr) {
@@ -241,9 +242,10 @@ public class OawSearchResultPage extends AbstractTextSearchViewPage implements I
}
}
+ @SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
if (IShowInTargetList.class.equals(adapter)) {
- return OawSearchResultPage.SHOW_IN_TARGET_LIST;
+ return XtendXpandSearchResultPage.SHOW_IN_TARGET_LIST;
}
return null;
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/OawTableContentProvider.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/XtendXpandTableContentProvider.java
index 7a9d9e5..72bd13d 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/OawTableContentProvider.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/search/view/XtendXpandTableContentProvider.java
@@ -14,29 +14,29 @@ import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.xtend.shared.ui.editor.search.query.OawSearchResult;
+import org.eclipse.xtend.shared.ui.editor.search.query.XtendXpandSearchResult;
/**
- * <code>OawTableContentProvider</code> is a chnage/aware content provider for
+ * <code>XtendXpandTableContentProvider</code> is a chnage/aware content provider for
* the search result list view.
*
* @author Peter Friese
*/
-public class OawTableContentProvider implements IStructuredContentProvider, IFileSearchContentProvider {
+public class XtendXpandTableContentProvider implements IStructuredContentProvider, IFileSearchContentProvider {
private final Object[] EMPTY_ARR = new Object[0];
- private final OawSearchResultPage page;
+ private final XtendXpandSearchResultPage page;
private AbstractTextSearchResult result;
/**
- * Creates a new <code>OawTableContentProvider</code>.
+ * Creates a new <code>XtendXpandTableContentProvider</code>.
*
* @param page
- * The oAW search result page this content provider is associated
+ * The Xtend search result page this content provider is associated
* with.
*/
- public OawTableContentProvider(OawSearchResultPage page) {
+ public XtendXpandTableContentProvider(XtendXpandSearchResultPage page) {
this.page = page;
}
@@ -44,9 +44,9 @@ public class OawTableContentProvider implements IStructuredContentProvider, IFil
* {@inheritDoc}
*/
public Object[] getElements(Object inputElement) {
- if (inputElement instanceof OawSearchResult) {
+ if (inputElement instanceof XtendXpandSearchResult) {
int elementLimit = 1000; // getElementLimit();
- Object[] elements = ((OawSearchResult) inputElement).getElements();
+ Object[] elements = ((XtendXpandSearchResult) inputElement).getElements();
if (elementLimit != -1 && elements.length > elementLimit) {
Object[] shownElements = new Object[elementLimit];
System.arraycopy(elements, 0, shownElements, 0, elementLimit);
@@ -61,8 +61,8 @@ public class OawTableContentProvider implements IStructuredContentProvider, IFil
* {@inheritDoc}
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof OawSearchResult) {
- result = (OawSearchResult) newInput;
+ if (newInput instanceof XtendXpandSearchResult) {
+ result = (XtendXpandSearchResult) newInput;
}
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/AbstractExtXptContentAssistProcessor.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/AbstractExtXptContentAssistProcessor.java
index 1f10cf3..0eed241 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/AbstractExtXptContentAssistProcessor.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/AbstractExtXptContentAssistProcessor.java
@@ -53,8 +53,8 @@ public abstract class AbstractExtXptContentAssistProcessor implements IContentAs
return null;
try {
if (!p.isNatureEnabled(XtendXpandNature.NATURE_ID)) {
- if (MessageDialog.openQuestion(editor.getEditorSite().getShell(), "oAW Nature not configured",
- "Do you want to add the oAW nature to project '" + p.getName() + "'?")) {
+ if (MessageDialog.openQuestion(editor.getEditorSite().getShell(), "Xtend Nature not configured",
+ "Do you want to add the Xtend nature to project '" + p.getName() + "'?")) {
XtendXpandNatureUtil.addExtXptNature(jp);
} else
return null;
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java
index 60e4aba..6406836 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java
@@ -68,8 +68,9 @@ public class ProposalFactoryEclipseImpl implements ProposalFactory {
}
private String computeReturnType(Type returnType, final boolean onOperation) {
- if (returnType == null)
+ if (returnType == null) {
return "unknown";
+ }
if (onOperation) {
if (returnType instanceof ParameterizedType) {
returnType = ((ParameterizedType) returnType).getInnerType();
@@ -204,6 +205,7 @@ public class ProposalFactoryEclipseImpl implements ProposalFactory {
if (nameCache == null || proposal == null)
throw new IllegalArgumentException();
+
CompletionProposal p = castToProposal(proposal);
if (p != null) {
if (nameCache.contains(p.getDisplayString()))
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/EclipseHelper.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/EclipseHelper.java
index 66b985d..7d9f790 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/EclipseHelper.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/EclipseHelper.java
@@ -101,10 +101,10 @@ public class EclipseHelper {
ICommand schema = projectDescription.newCommand();
schema.setBuilderName("org.eclipse.pde.SchemaBuilder");
- ICommand oaw = projectDescription.newCommand();
- oaw.setBuilderName(XtendXpandBuilder.getBUILDER_ID());
+ ICommand extxpt = projectDescription.newCommand();
+ extxpt.setBuilderName(XtendXpandBuilder.getBUILDER_ID());
- projectDescription.setBuildSpec(new ICommand[] { java, manifest, schema, oaw });
+ projectDescription.setBuildSpec(new ICommand[] { java, manifest, schema, extxpt });
project.open(new SubProgressMonitor(progressMonitor, 1));
project.setDescription(projectDescription, new SubProgressMonitor(progressMonitor, 1));
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/OawProjectWizard.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/XtendXpandProjectWizard.java
index bc48d52..d72aa77 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/OawProjectWizard.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/XtendXpandProjectWizard.java
@@ -36,21 +36,21 @@ import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
import org.eclipse.xtend.shared.ui.internal.XtendLog;
-public class OawProjectWizard extends Wizard implements INewWizard, IExecutableExtension {
- private OawProjectWizardPage page;
+public class XtendXpandProjectWizard extends Wizard implements INewWizard, IExecutableExtension {
+ private XtendXpandProjectWizardPage page;
private ISelection selection;
private IConfigurationElement configElement;
- public OawProjectWizard() {
+ public XtendXpandProjectWizard() {
super();
setNeedsProgressMonitor(true);
}
@Override
public void addPages() {
- page = new OawProjectWizardPage(selection);
+ page = new XtendXpandProjectWizardPage(selection);
addPage(page);
}
@@ -58,21 +58,24 @@ public class OawProjectWizard extends Wizard implements INewWizard, IExecutableE
public boolean performFinish() {
final String name = page.getProjectName();
final boolean genExample = page.isCreateExample();
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ final IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(final IProgressMonitor monitor) throws InvocationTargetException {
try {
doFinish(name, genExample, monitor);
- } finally {
+ }
+ finally {
monitor.done();
}
}
};
try {
getContainer().run(true, false, op);
- } catch (InterruptedException e) {
+ }
+ catch (final InterruptedException e) {
return false;
- } catch (InvocationTargetException e) {
- Throwable realException = e.getTargetException();
+ }
+ catch (final InvocationTargetException e) {
+ final Throwable realException = e.getTargetException();
MessageDialog.openError(getShell(), "Error", realException.getMessage());
return false;
}
@@ -80,40 +83,41 @@ public class OawProjectWizard extends Wizard implements INewWizard, IExecutableE
return true;
}
- void doFinish(String name, boolean genExample, IProgressMonitor monitor) {
- String projectName = name;
- monitor.beginTask("Creating oaw generator project " + name, 2);
+ void doFinish(final String name, final boolean genExample, final IProgressMonitor monitor) {
+ final String projectName = name;
+ monitor.beginTask("Creating Xpand generator project " + name, 2);
- Set<String> refs = new HashSet<String>();
- List<String> srcfolders = new ArrayList<String>();
+ final Set<String> refs = new HashSet<String>();
+ final List<String> srcfolders = new ArrayList<String>();
srcfolders.add("src");
srcfolders.add("src-gen");
- IProject p = EclipseHelper.createExtXptProject(projectName, srcfolders, Collections.<IProject> emptyList(), refs,
- null, monitor, getShell());
+ final IProject p = EclipseHelper.createExtXptProject(projectName, srcfolders, Collections
+ .<IProject> emptyList(), refs, null, monitor, getShell());
- if (p == null) {
+ if (p == null)
return;
- }
if (genExample) {
EclipseHelper.createFile("src/metamodel/Checks.chk", p, getContents("Checks.chk"), monitor);
EclipseHelper.createFile("src/metamodel/Extensions.ext", p, getContents("Extensions.ext"), monitor);
EclipseHelper.createFile("src/metamodel/metamodel.ecore", p, getContents("metamodel.ecore"), monitor);
- EclipseHelper.createFile("src/template/GeneratorExtensions.ext", p, getContents("GeneratorExtensions.ext"), monitor);
+ EclipseHelper.createFile("src/template/GeneratorExtensions.ext", p, getContents("GeneratorExtensions.ext"),
+ monitor);
EclipseHelper.createFile("src/template/Template.xpt", p, getContents("Template.xpt"), monitor);
- EclipseHelper.createFile("src/workflow/generator.oaw", p, getContents("generator.oaw").replace("PROJECTNAME", projectName), monitor);
+ EclipseHelper.createFile("src/workflow/generator.mwe", p, getContents("generator.mwe").replace(
+ "PROJECTNAME", projectName), monitor);
EclipseHelper.createFile("src/Model.xmi", p, getContents("Model.xmi"), monitor);
}
monitor.worked(1);
}
- private String getContents(String resource) {
+ private String getContents(final String resource) {
try {
- InputStream inputStream = getClass().getClassLoader().getResourceAsStream(
+ final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(
"org/openarchitectureware/wizards/example/" + resource);
- byte[] buffer = new byte[4096];
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ final byte[] buffer = new byte[4096];
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
while (true) {
int read;
@@ -130,7 +134,8 @@ public class OawProjectWizard extends Wizard implements INewWizard, IExecutableE
inputStream.close();
return outputStream.toString("iso-8859-1");
- } catch (IOException e) {
+ }
+ catch (final IOException e) {
XtendLog.logError(e);
return "";
}
@@ -142,11 +147,11 @@ public class OawProjectWizard extends Wizard implements INewWizard, IExecutableE
*
* @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
*/
- public void init(IWorkbench workbench, IStructuredSelection selection) {
+ public void init(final IWorkbench workbench, final IStructuredSelection selection) {
this.selection = selection;
}
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ public void setInitializationData(final IConfigurationElement config, final String propertyName, final Object data)
throws CoreException {
this.configElement = config;
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/OawProjectWizardPage.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/XtendXpandProjectWizardPage.java
index 6bb7e7b..ca90b92 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/OawProjectWizardPage.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/XtendXpandProjectWizardPage.java
@@ -30,7 +30,7 @@ import org.eclipse.swt.widgets.Text;
* as the file name. The page will only accept file name without the extension
* OR with the extension that matches the expected one (xtxt).
*/
-public class OawProjectWizardPage extends WizardPage {
+public class XtendXpandProjectWizardPage extends WizardPage {
private Text projectText;
private Button generateSimpleExample;
@@ -40,10 +40,10 @@ public class OawProjectWizardPage extends WizardPage {
*
* @param pageName
*/
- public OawProjectWizardPage(ISelection selection) {
+ public XtendXpandProjectWizardPage(ISelection selection) {
super("wizardPage");
- setTitle("oAW Project");
- setDescription("This wizard creates a simple oAW generator project including the references to the required libraries.");
+ setTitle("Xtend Project");
+ setDescription("This wizard creates a simple Xtend generator project including the references to the required libraries.");
}
/**
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/example/generator.oaw b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/example/generator.mwe
index 564016a..564016a 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/example/generator.oaw
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/wizards/example/generator.mwe
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java
index 66c95d9..3da6d8c 100644
--- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java
@@ -15,7 +15,7 @@ import java.util.regex.Matcher;
import junit.framework.TestCase;
public class EvaluationExceptionTest extends TestCase {
- public void testOawID() throws Exception {
+ public void testExtXptID() throws Exception {
Matcher m =EvaluationException.P.matcher(" dsvdfgv df df gvd fgdf stuff::Test.ext[3,56] dnvfd gvdf bvdfgbvd");
assertTrue(m.find());
String text = m.group();
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java
index baa3b58..9c436dc 100644
--- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java
@@ -19,8 +19,8 @@ public class AllTests {
TestSuite suite = new TestSuite("Test for org.eclipse.xtend.typesystem.emf.check");
// $JUnit-BEGIN$
// TODO create an plugin test suit and put this test in
- // suite.addTestSuite(OawValidatorPluginTests.class);
- suite.addTestSuite(OawValidatorStandaloneTests.class);
+ // suite.addTestSuite(XtendXpandValidatorPluginTests.class);
+ suite.addTestSuite(XtendXpandValidatorStandaloneTests.class);
// $JUnit-END$
return suite;
}
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/XtendXpandValidatorPluginTests.java
index 69afb78..9ea2e81 100644
--- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/XtendXpandValidatorPluginTests.java
@@ -28,14 +28,14 @@ import org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage;
/**
* @author Jan Köhnlein
*/
-public class OawValidatorPluginTests extends TestCase {
+public class XtendXpandValidatorPluginTests extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
CheckRegistry.getInstance();
}
- public void testOawValidator() {
+ public void testExtXptValidator() {
// Plugin test
EValidator validator = EValidator.Registry.INSTANCE.getEValidator(TestPackage.eINSTANCE);
assertNotNull("Validator registration failed", validator);
@@ -55,7 +55,7 @@ public class OawValidatorPluginTests extends TestCase {
assertEquals("Validation should have a warning", Diagnostic.WARNING, diagnostic.getSeverity());
}
- public void testOawValidatorFeatureScope() {
+ public void testExtXptValidatorFeatureScope() {
MyMetaClass objectUnderTest = TestFactory.eINSTANCE.createMyMetaClass();
Diagnostic diagnostic = Diagnostician.INSTANCE.validate(objectUnderTest);
assertEquals("Validation should have failed", Diagnostic.ERROR, diagnostic.getSeverity());
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/XtendXpandValidatorStandaloneTests.java
index 14e59f9..ba470c4 100644
--- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/XtendXpandValidatorStandaloneTests.java
@@ -29,9 +29,9 @@ import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePa
/**
* @author Jan Köhnlein
*/
-public class OawValidatorStandaloneTests extends TestCase {
+public class XtendXpandValidatorStandaloneTests extends TestCase {
- public void testOawValidator() {
+ public void testExtXptValidator() {
// workaround for MacOSX classloader bug
ClassLoader classLoader = this.getClass().getClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
diff --git a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/BuildJob.java b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/BuildJob.java
index 666073d..2226739 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/BuildJob.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/BuildJob.java
@@ -21,25 +21,28 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.xtend.shared.ui.core.builder.XtendXpandBuilder;
public class BuildJob extends Job {
- private IProject project;
+ private final IProject project;
- public BuildJob(IProject project) {
+ public BuildJob(final IProject project) {
super("Building " + project.getName());
setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
this.project = project;
}
@Override
- protected IStatus run(IProgressMonitor monitor) {
- if (EmfToolsPlugin.trace)
- System.out.println("Running oAW builder for project " + project.getName());
+ protected IStatus run(final IProgressMonitor monitor) {
+ if (EmfToolsPlugin.trace) {
+ System.out.println("Running Xtend/Xpand builder for project " + project.getName());
+ }
try {
- project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD,
- XtendXpandBuilder.getBUILDER_ID(), null, monitor);
- } catch (CoreException e) {
- if (EmfToolsPlugin.trace)
+ project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, XtendXpandBuilder.getBUILDER_ID(), null,
+ monitor);
+ }
+ catch (final CoreException e) {
+ if (EmfToolsPlugin.trace) {
e.printStackTrace();
+ }
}
return Status.OK_STATUS;
}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java
index e7a1823..7a73dbd 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/EmfToolsPlugin.java
@@ -45,21 +45,21 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
// The shared instance.
private static EmfToolsPlugin plugin;
-
+
// project analyzer per project
private final Map<IJavaProject, ProjectAnalyzer> projectAnalyzerCache = new HashMap<IJavaProject, ProjectAnalyzer>();
// get trace state
public static boolean trace = false;
static {
- String value = Platform.getDebugOption("org.eclipse.internal.xtend.emftools/trace");
+ final String value = Platform.getDebugOption("org.eclipse.internal.xtend.emftools/trace");
if (value != null && value.equals("true")) {
trace = true;
}
}
-
- public ProjectAnalyzer getProjectAnalyzer(IProject p) {
- IJavaProject jp = JavaCore.create(p);
+
+ public ProjectAnalyzer getProjectAnalyzer(final IProject p) {
+ final IJavaProject jp = JavaCore.create(p);
if (jp == null || !jp.exists())
return null;
ProjectAnalyzer analyzer = projectAnalyzerCache.get(jp);
@@ -71,19 +71,20 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
}
private final IResourceChangeListener resourceListener = new IResourceChangeListener() {
- public void resourceChanged(IResourceChangeEvent event) {
+ public void resourceChanged(final IResourceChangeEvent event) {
try {
// under special circumstances (e.g. renaming a project) the
// event.getDelta() can be null. Avoid NPE.
if (event.getDelta() == null)
return;
- // collect changed projects. only ecore files and jars in the classpath are relevant
+ // collect changed projects. only ecore files and jars in the
+ // classpath are relevant
final Set<IProject> changedProjects = new HashSet<IProject>();
event.getDelta().accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- if ((isEcoreFile(delta.getResource()) || isJarFile(delta.getResource())) &&
- JavaCore.create(delta.getResource().getProject()).isOnClasspath(delta.getResource())) {
+ public boolean visit(final IResourceDelta delta) throws CoreException {
+ if ((isEcoreFile(delta.getResource()) || isJarFile(delta.getResource()))
+ && JavaCore.create(delta.getResource().getProject()).isOnClasspath(delta.getResource())) {
changedProjects.add(delta.getResource().getProject());
}
return true;
@@ -91,32 +92,33 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
});
analyzeAndRebuildProjects(changedProjects);
- } catch (CoreException e) {
+ }
+ catch (final CoreException e) {
EmfToolsLog.logError(e);
}
- }
+ }
};
private final IElementChangedListener classpathListener = new IElementChangedListener() {
- public void elementChanged(ElementChangedEvent event) {
- Set<IProject> projects = new HashSet<IProject>();
+ public void elementChanged(final ElementChangedEvent event) {
+ final Set<IProject> projects = new HashSet<IProject>();
collectChangedProjects(event.getDelta(), projects);
analyzeAndRebuildProjects(projects);
}
- private void collectChangedProjects(IJavaElementDelta delta, Set<IProject> projects) {
+ private void collectChangedProjects(final IJavaElementDelta delta, final Set<IProject> projects) {
// we're interested in classpath changes. classpath reordering is
// not of interest since we wont find any other metamodels than
// before
if ((delta.getFlags() & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0
|| (delta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0
|| (delta.getFlags() & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0) {
- IJavaProject javaProject = delta.getElement().getJavaProject();
+ final IJavaProject javaProject = delta.getElement().getJavaProject();
if (javaProject != null) {
projects.add(javaProject.getProject());
}
}
- for (IJavaElementDelta d : delta.getAffectedChildren()) {
+ for (final IJavaElementDelta d : delta.getAffectedChildren()) {
collectChangedProjects(d, projects);
}
}
@@ -138,11 +140,12 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
- // traverse all oaw projects in workspace and analyze their MMs in classpath
- for (IProject p : workspace.getRoot().getProjects()) {
+ // traverse all Xpans projects in workspace and analyze their MMs in
+ // classpath
+ for (final IProject p : workspace.getRoot().getProjects()) {
if (Activator.getExtXptModelManager().findProject(p) != null) {
- ProjectAnalyzer pa = getProjectAnalyzer(p);
- if (pa!=null) {
+ final ProjectAnalyzer pa = getProjectAnalyzer(p);
+ if (pa != null) {
if (pa.getState() != Job.WAITING) {
pa.schedule();
}
@@ -174,14 +177,14 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
*
* @param project
* The project to retrieve the metamodels for. Must not be null,
- * @return The metamodels for the given project. An empty array if none
- * are accessible.
+ * @return The metamodels for the given project. An empty array if none are
+ * accessible.
*/
- public EPackage[] getMetamodelsForProject(IJavaProject project) {
- Set<String> visited = new HashSet<String>();
- return getMetamodelsForProjectInternal(project, visited);
- }
-
+ public EPackage[] getMetamodelsForProject(final IJavaProject project) {
+ final Set<String> visited = new HashSet<String>();
+ return getMetamodelsForProjectInternal(project, visited);
+ }
+
/**
* Retrieves the list of EPackages that are accessible for the given
* project, i.e. that are in the project's classpath. The referenced
@@ -194,38 +197,40 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
* @return The metamodels for the given project. An empty array if none are
* accessible.
*/
- private EPackage[] getMetamodelsForProjectInternal(IJavaProject project, Set<String> visited) {
+ private EPackage[] getMetamodelsForProjectInternal(final IJavaProject project, final Set<String> visited) {
if (visited.contains(project.getProject().getName()))
return new EPackage[0];
visited.add(project.getProject().getName());
-
- ProjectAnalyzer projectAnalyzer = getProjectAnalyzer(project.getProject());
- if (projectAnalyzer == null) {
+
+ final ProjectAnalyzer projectAnalyzer = getProjectAnalyzer(project.getProject());
+ if (projectAnalyzer == null)
return new EPackage[0];
- }
// wait if analyzation is currently executed
- while (projectAnalyzer.getState() == Job.RUNNING ||
- projectAnalyzer.getState() == Job.WAITING) {
+ while (projectAnalyzer.getState() == Job.RUNNING || projectAnalyzer.getState() == Job.WAITING) {
try {
Thread.sleep(500l);
- if (EmfToolsPlugin.trace)
- System.out.println("Waiting 500ms for ProjectAnalyzer of project " + project.getProject().getName() + " to finish.");
- } catch (InterruptedException e) {
+ if (EmfToolsPlugin.trace) {
+ System.out.println("Waiting 500ms for ProjectAnalyzer of project " + project.getProject().getName()
+ + " to finish.");
+ }
+ }
+ catch (final InterruptedException e) {
EmfToolsLog.logError(e);
}
}
- Map<String, EPackage> packages = new HashMap<String, EPackage>(projectAnalyzer.getNamedEPackageMap());
+ final Map<String, EPackage> packages = new HashMap<String, EPackage>(projectAnalyzer.getNamedEPackageMap());
try {
- for (IProject p : project.getProject().getReferencedProjects()) {
- IJavaProject jp = JavaCore.create(p);
- EPackage[] ps = getMetamodelsForProjectInternal(jp, visited);
- for (EPackage package1 : ps) {
+ for (final IProject p : project.getProject().getReferencedProjects()) {
+ final IJavaProject jp = JavaCore.create(p);
+ final EPackage[] ps = getMetamodelsForProjectInternal(jp, visited);
+ for (final EPackage package1 : ps) {
if (!packages.containsKey(package1.getNsURI())) {
packages.put(package1.getNsURI(), package1);
}
}
}
- } catch (CoreException e) {
+ }
+ catch (final CoreException e) {
EmfToolsLog.logError(e);
}
return packages.values().toArray(new EPackage[packages.values().size()]);
@@ -259,23 +264,31 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
}
protected boolean isJarFile(final IResource f) {
- return f instanceof IFile && !f.isDerived() && "jar".equalsIgnoreCase(f.getFileExtension());
+ return f instanceof IFile && !f.isDerived() && "jar".equalsIgnoreCase(f.getFileExtension());
}
/**
- * Finds oaw projects that depend on the given project, recursively. Uses a Map to collect projects
- * since sometimes the same project is referenced through different IProject objects.
- * @param project The project whose referenced projects should be retrieved
- * @param referencingProjects Result map where the assignment of a project to its referencing projects is stored
- * @param visited All project names that where already visited during this recursion. This is to avoid loops when having
- * circular dependencies.
+ * Finds Xpand projects that depend on the given project, recursively. Uses
+ * a Map to collect projects since sometimes the same project is referenced
+ * through different IProject objects.
+ *
+ * @param project
+ * The project whose referenced projects should be retrieved
+ * @param referencingProjects
+ * Result map where the assignment of a project to its
+ * referencing projects is stored
+ * @param visited
+ * All project names that where already visited during this
+ * recursion. This is to avoid loops when having circular
+ * dependencies.
*/
- private void collectReferencingExtXptProjects(IProject project, Map<String, IProject> referencingProjects, Set<String> visited) {
+ private void collectReferencingExtXptProjects(final IProject project,
+ final Map<String, IProject> referencingProjects, final Set<String> visited) {
if (visited.contains(project.getName()))
return;
visited.add(project.getName());
-
- for (IProject p : project.getReferencingProjects()) {
+
+ for (final IProject p : project.getReferencingProjects()) {
if (Activator.getExtXptModelManager().findProject(p) != null) {
referencingProjects.put(p.getName(), p);
}
@@ -284,28 +297,31 @@ public class EmfToolsPlugin extends AbstractUIPlugin {
}
/**
- * Analyzes the given projects, finds all oaw projects that depend on these, and rebuild those.
- * The given projects themselves are built in their ProjectAnalyers
- *
- * @param projects The projects to analyze.
+ * Analyzes the given projects, finds all Xpand projects that depend on
+ * these, and rebuild those. The given projects themselves are built in
+ * their ProjectAnalyers
+ *
+ * @param projects
+ * The projects to analyze.
*/
- private void analyzeAndRebuildProjects(Set<IProject> projects) {
- Map<String, IProject> referencingProjects = new HashMap<String, IProject>();
- Set<String> visited = new HashSet<String>();
- for (IProject p : projects) {
- ProjectAnalyzer pa = getProjectAnalyzer(p);
- if (pa!=null) {
+ private void analyzeAndRebuildProjects(final Set<IProject> projects) {
+ final Map<String, IProject> referencingProjects = new HashMap<String, IProject>();
+ final Set<String> visited = new HashSet<String>();
+ for (final IProject p : projects) {
+ final ProjectAnalyzer pa = getProjectAnalyzer(p);
+ if (pa != null) {
if (pa.getState() != Job.WAITING) {
pa.schedule();
}
}
collectReferencingExtXptProjects(p, referencingProjects, visited);
}
- // remove those projects that we just analyzed. they will be built in their ProjectAnalyzer.
+ // remove those projects that we just analyzed. they will be built in
+ // their ProjectAnalyzer.
// so we shouldn't start another builder here.
- ArrayList<IProject> relevantProjects = new ArrayList<IProject>(referencingProjects.values());
+ final ArrayList<IProject> relevantProjects = new ArrayList<IProject>(referencingProjects.values());
relevantProjects.removeAll(projects);
- for (IProject refProject : relevantProjects) {
+ for (final IProject refProject : relevantProjects) {
new BuildJob(refProject).schedule();
}
}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/ProjectAnalyzer.java b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/ProjectAnalyzer.java
index 97735d8..aa6e6fd 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/ProjectAnalyzer.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/ProjectAnalyzer.java
@@ -62,20 +62,21 @@ import org.eclipse.xtend.typesystem.emf.ui.internal.EmfToolsLog;
* </p>
*/
final class ProjectAnalyzer extends Job {
- private IJavaProject project;
+ private final IJavaProject project;
private ResourceSet rs;
private Map<IStorage, Resource> mapping;
private Map<String, EPackage> packages;
- public ProjectAnalyzer(IJavaProject project) {
+ public ProjectAnalyzer(final IJavaProject project) {
super("Analyzing accessible EMF metamodels for project " + project.getProject().getProject().getName());
this.project = project;
}
@Override
- protected IStatus run(IProgressMonitor monitor) {
- if (EmfToolsPlugin.trace)
+ protected IStatus run(final IProgressMonitor monitor) {
+ if (EmfToolsPlugin.trace) {
System.out.println("Analyzing EMF metamodels for project " + project.getProject().getProject().getName());
+ }
// load models
rs = new ResourceSetImpl();
@@ -86,7 +87,7 @@ final class ProjectAnalyzer extends Job {
packages.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
// done. now trigger build for the project.
- // only do this if it is an oaw project
+ // only do this if it is an Xpand project
// do not build referencing projects. the EmfToolsPlugin will take care
// of this
if (Activator.getExtXptModelManager().findProject(project.getProject()) != null) {
@@ -96,11 +97,11 @@ final class ProjectAnalyzer extends Job {
return Status.OK_STATUS;
}
- @SuppressWarnings("restriction")
- private void loadMetamodelsForProject(IJavaProject javaProject, final ResourceSet rs, IProgressMonitor monitor) {
+ private void loadMetamodelsForProject(final IJavaProject javaProject, final ResourceSet rs,
+ final IProgressMonitor monitor) {
try {
final String ext = "ecore";
- for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
+ for (final IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
if (!root.isArchive()) {
IResource rootResource = null;
if (root instanceof ExternalPackageFragmentRoot) {
@@ -112,7 +113,7 @@ final class ProjectAnalyzer extends Job {
if (rootResource != null) {
try {
rootResource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
+ public boolean visit(final IResource resource) throws CoreException {
if (resource instanceof IFile && ext.equals(((IFile) resource).getFileExtension())) {
loadModelFromStorage(rs, (IFile) resource);
}
@@ -120,7 +121,7 @@ final class ProjectAnalyzer extends Job {
}
});
}
- catch (CoreException e) {
+ catch (final CoreException e) {
EmfToolsLog.logError(e);
}
}
@@ -128,29 +129,32 @@ final class ProjectAnalyzer extends Job {
else {
// skip JRE jars
if (((JarPackageFragmentRoot) root).getPath().toString().contains("jre/lib")) {
- if (EmfToolsPlugin.trace)
+ if (EmfToolsPlugin.trace) {
System.out.println("Skipping " + ((JarPackageFragmentRoot) root).getPath().toString());
+ }
continue;
}
root.open(monitor);
try {
- ZipFile zip = ((JarPackageFragmentRoot) root).getJar();
+ final ZipFile zip = ((JarPackageFragmentRoot) root).getJar();
- Enumeration<? extends ZipEntry> entries = zip.entries();
+ final Enumeration<? extends ZipEntry> entries = zip.entries();
while (entries.hasMoreElements()) {
- ZipEntry entry = entries.nextElement();
- String name = entry.getName();
+ final ZipEntry entry = entries.nextElement();
+ final String name = entry.getName();
if (name.endsWith(ext)) {
- String fqn = name.substring(0, name.length() - ext.length() - 1).replaceAll("/", "::");
- ResourceID resourceID = new ResourceID(fqn, ext);
- IStorage findStorage = JDTUtil.loadFromJar(resourceID, root);
- if (findStorage != null)
+ final String fqn = name.substring(0, name.length() - ext.length() - 1).replaceAll("/",
+ "::");
+ final ResourceID resourceID = new ResourceID(fqn, ext);
+ final IStorage findStorage = JDTUtil.loadFromJar(resourceID, root);
+ if (findStorage != null) {
loadModelFromStorage(rs, findStorage);
+ }
}
}
}
- catch (CoreException e) {
+ catch (final CoreException e) {
EmfToolsLog.logError(e);
}
finally {
@@ -159,15 +163,16 @@ final class ProjectAnalyzer extends Job {
}
}
}
- catch (JavaModelException e) {
+ catch (final JavaModelException e) {
EmfToolsLog.logError(e);
}
}
- private void loadModelFromStorage(ResourceSet rs, IStorage storage) {
- URI uri = URI.createPlatformResourceURI(storage.getFullPath().toString(), true);
- if (EmfToolsPlugin.trace)
+ private void loadModelFromStorage(final ResourceSet rs, final IStorage storage) {
+ final URI uri = URI.createPlatformResourceURI(storage.getFullPath().toString(), true);
+ if (EmfToolsPlugin.trace) {
System.out.println("Loading EMF metamodel " + storage.getFullPath().toString());
+ }
final Resource r = rs.createResource(uri);
if (r.isLoaded() && !r.isModified())
@@ -175,32 +180,34 @@ final class ProjectAnalyzer extends Job {
try {
r.load(storage.getContents(), Collections.EMPTY_MAP);
mapping.put(storage, r);
- Collection<EPackage> packages = EcoreUtil.getObjectsByType(r.getContents(), EcorePackage.Literals.EPACKAGE);
- for (EPackage pack : packages) {
+ final Collection<EPackage> packages = EcoreUtil.getObjectsByType(r.getContents(),
+ EcorePackage.Literals.EPACKAGE);
+ for (final EPackage pack : packages) {
registerPackage(storage, pack);
}
}
- catch (IOException e) {
+ catch (final IOException e) {
EmfToolsLog.logError(e);
}
- catch (CoreException e) {
+ catch (final CoreException e) {
EmfToolsLog.logError(e);
}
}
- private void registerPackage(IStorage storage, EPackage pack) {
+ private void registerPackage(final IStorage storage, final EPackage pack) {
// finding duplicates by nsURI is better than by name since package
// names may be used across MMs
if (this.packages.containsKey(pack.getNsURI())) {
- if (EmfToolsPlugin.trace)
+ if (EmfToolsPlugin.trace) {
System.out.println("Did not register '" + pack.getName() + "' from " + storage.getFullPath()
+ " because an EPackage with the same nsURI has already been registered.");
+ }
}
else {
this.packages.put(pack.getNsURI(), pack);
}
// recurse into subpackages
- for (EPackage p : pack.getESubpackages()) {
+ for (final EPackage p : pack.getESubpackages()) {
registerPackage(storage, p);
}
}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AbstractCoreModelTransformerAction.java b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AbstractCoreModelTransformerAction.java
index 424bb7e..9a566db 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AbstractCoreModelTransformerAction.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AbstractCoreModelTransformerAction.java
@@ -28,64 +28,66 @@ import org.eclipse.ui.IWorkbenchPart;
public abstract class AbstractCoreModelTransformerAction implements IObjectActionDelegate {
- private IFile file;
+ private IFile file;
- protected static final String ANNO_SOURCE = GenModelPackage.eNS_URI;
+ protected static final String ANNO_SOURCE = GenModelPackage.eNS_URI;
- protected static final String ANNO_KEY = "body";
+ protected static final String ANNO_KEY = "body";
- /**
- * Constructor for Action1.
- */
- public AbstractCoreModelTransformerAction() {
- super();
- }
+ /**
+ * Constructor for Action1.
+ */
+ public AbstractCoreModelTransformerAction() {
+ super();
+ }
- /**
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(final IAction action, final IWorkbenchPart targetPart) {
- }
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(final IAction action, final IWorkbenchPart targetPart) {
+ }
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(final IAction action) {
- final URI fileURI = URI.createFileURI(file.getFullPath().toPortableString());
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(final IAction action) {
+ final URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toPortableString(), true);
- final Resource r = new ResourceSetImpl().createResource(fileURI);
- try {
- r.load(null);
- } catch (final IOException e) {
- throwE(e);
- }
- transform(r);
- try {
- r.save(null);
- } catch (final IOException e) {
- throwE(e);
- }
- }
+ final Resource r = new ResourceSetImpl().createResource(fileURI);
+ try {
+ r.load(null);
+ }
+ catch (final IOException e) {
+ throwE(e);
+ }
+ transform(r);
+ try {
+ r.save(null);
+ }
+ catch (final IOException e) {
+ throwE(e);
+ }
+ }
- public abstract void transform(Resource r);
+ public abstract void transform(Resource r);
- public void throwE(final IOException e) {
- final Shell shell = new Shell();
- MessageDialog.openError(shell, "oAW EMF Eclipse Plug-in", e.getMessage());
- throw new RuntimeException(e);
- }
+ public void throwE(final IOException e) {
+ final Shell shell = new Shell();
+ MessageDialog.openError(shell, "Xtend EMF Eclipse Plug-in", e.getMessage());
+ throw new RuntimeException(e);
+ }
- /**
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(final IAction action, final ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- final Object object = structuredSelection.getFirstElement();
- if (object instanceof IFile) {
- file = (IFile) object;
- }
- }
- }
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(final IAction action, final ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ final Object object = structuredSelection.getFirstElement();
+ if (object instanceof IFile) {
+ file = (IFile) object;
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AddAnnotationsAction.java b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AddAnnotationsAction.java
index a4505b2..71265d3 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AddAnnotationsAction.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf.ui/src/org/eclipse/xtend/typesystem/emf/ui/actions/AddAnnotationsAction.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.ecore.resource.Resource;
public class AddAnnotationsAction extends AbstractCoreModelTransformerAction {
+ @SuppressWarnings("unchecked")
@Override
public void transform(final Resource r) {
final Iterator<EObject> iter = r.getAllContents();
@@ -52,9 +53,8 @@ public class AddAnnotationsAction extends AbstractCoreModelTransformerAction {
final List<EParameter> params = op.getEParameters();
for (final Iterator<EParameter> iter = params.iterator(); iter.hasNext();) {
final EParameter element = iter.next();
- buff.append(element.getName());
- buff.append(", ");
- }
+ buff.append(element.getName());
+ }
return buff.append("this);").toString();
}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java
index 4006e76..341c28b 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java
@@ -43,9 +43,9 @@ public class EClassType extends AbstractTypeImpl {
private final static Log log = LogFactory.getLog(EClassType.class);
- private EmfRegistryMetaModel emfMetaModel;
+ private final EmfRegistryMetaModel emfMetaModel;
- private EClass eClass;
+ private final EClass eClass;
public EClassType(final EmfRegistryMetaModel model, final String name, final EClass class1) {
super(model.getTypeSystem(), name);
@@ -57,7 +57,7 @@ public class EClassType extends AbstractTypeImpl {
public Feature[] getContributedFeatures() {
final Set<FeatureImpl> result = new HashSet<FeatureImpl>();
// Attributes
- List<EStructuralFeature> list = eClass.getEStructuralFeatures();
+ final List<EStructuralFeature> list = eClass.getEStructuralFeatures();
for (final EStructuralFeature feature : list) {
final Type t = emfMetaModel.getTypeForETypedElement(feature);
if (t == null) {
@@ -166,9 +166,10 @@ public class EClassType extends AbstractTypeImpl {
return result.toArray(new Feature[result.size()]);
}
- private String getTypeName(EClassifier type) {
+ private String getTypeName(final EClassifier type) {
if (type == null)
return "null";
+
return type.getName();
}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java
index db81cff..1c38d41 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java
@@ -251,11 +251,9 @@ public class EcoreUtil2 {
uri = URI.createURI(url.toExternalForm());
- // this is the old implementation of this block, but it caused
- // errors:
+ // this is the old implementation of this block, but it caused errors:
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=256833
- // I'm leaving this here for a while to make sure unforeseen
- // side effects can be understood
+ // I'm leaving this here for a while to make sure unforeseen side effects can be understood
// if (url.getProtocol().equals("file")) {
// uri = URI.createFileURI(url.getFile());
// }
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java
index e7c88fc..d8bb721 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java
@@ -25,29 +25,44 @@ public class EmfMetaModel extends EmfRegistryMetaModel implements MetaModel {
this.metamodel = metamodel;
}
+ /**
+ * Sets the metamodel descriptor.
+ *
+ * @param ePackageDescriptor
+ * the descriptor
+ */
public void setMetaModelDescriptor(final String ePackageDescriptor) {
metamodel = EcoreUtil2.getEPackageByDescriptorClassName(ePackageDescriptor);
- if (metamodel == null) {
+ if (metamodel == null)
throw new ConfigurationException("Couldn't find ePackage Descriptor '" + ePackageDescriptor);
}
- }
+ /**
+ * Sets the metamodel package.
+ *
+ * @param ePackage
+ * the package
+ */
public void setMetaModelPackage(final String ePackage) {
metamodel = EcoreUtil2.getEPackageByClassName(ePackage);
- if (metamodel == null) {
+ if (metamodel == null)
throw new ConfigurationException("Couldn't find ePackage '" + ePackage);
}
- }
+ /**
+ * Sets the name of the metamodel file.
+ *
+ * @param metaModelFile
+ * the metamodel filename
+ */
public void setMetaModelFile(final String metaModelFile) {
metamodel = EcoreUtil2.getEPackage(metaModelFile);
- if (metamodel == null) {
+ if (metamodel == null)
throw new ConfigurationException("Couldn't load ecore file '" + metaModelFile);
}
- }
@Override
protected EPackage[] allPackages() {
- return new EPackage[]{metamodel};
+ return new EPackage[] { metamodel };
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java
index 910fbe3..a7f6dd9 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java
@@ -116,7 +116,7 @@ public class XmiReader extends AbstractWorkflowComponent {
}
/**
- * @see org.eclipse.emf.mwe.core.WorkflowComponent#checkConfiguration(org.openarchitectureware.workflow.issues.Issues)
+ * @see org.eclipse.emf.mwe.core.WorkflowComponent#checkConfiguration(org.eclipse.emf.mwe.core.issues.Issues)
*/
public void checkConfiguration(final Issues issues) {
loadFile(issues);
@@ -156,7 +156,7 @@ public class XmiReader extends AbstractWorkflowComponent {
return null;
}
final URL url = ResourceLoaderFactory.createResourceLoader().getResource(modelFile);
- if ((url == null) || (url.getFile() == null)) {
+ if (url == null || url.getFile() == null) {
issues.addError(this, "cannot find file: " + modelFile);
return null;
}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java
index 6fee3ac..1def5ee 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java
@@ -44,7 +44,7 @@ import org.eclipse.xtend.typesystem.emf.EmfMetaModel;
/**
* An implementation of {@link org.eclipse.emf.ecore.EValidator} that executes
- * oAW checks. Further EValidators can be nested.
+ * Xtend checks. Further EValidators can be nested.
*
* Check files can be added with reparse option. If true, the check files are
* reparse on each validation.
@@ -55,145 +55,135 @@ public class CheckEValidatorAdapter implements EValidator {
private final Log log = LogFactory.getLog(CheckEValidatorAdapter.class);
- private List<CheckFileWithContext> _checkFiles;
+ private final List<CheckFileWithContext> _checkFiles;
private EValidator _nestedValidator;
- private EPackage _ePackage;
-
+ private final EPackage _ePackage;
+
private ResourceManager _externalResourceManager;
- public CheckEValidatorAdapter(EPackage ePackage) {
+ public CheckEValidatorAdapter(final EPackage ePackage) {
_ePackage = ePackage;
_checkFiles = new ArrayList<CheckFileWithContext>();
}
- public CheckEValidatorAdapter(EPackage ePackage,
- EValidator existingValidator) {
+ public CheckEValidatorAdapter(final EPackage ePackage, final EValidator existingValidator) {
this(ePackage);
if (existingValidator != null) {
_nestedValidator = existingValidator;
}
}
- public void addCheckFile(CheckFileWithContext checkFile) {
+ public void addCheckFile(final CheckFileWithContext checkFile) {
_checkFiles.add(checkFile);
}
- public boolean validate(EObject eObject, DiagnosticChain diagnostics,
- Map<Object, Object> context) {
+ public boolean validate(final EObject eObject, final DiagnosticChain diagnostics, final Map<Object, Object> context) {
return validate(eObject.eClass(), eObject, diagnostics, context);
}
- public boolean validate(EClass eClass, EObject eObject,
- DiagnosticChain diagnostics, Map<Object, Object> context) {
- List<EObject> allElements = Collections.singletonList(eObject);
- boolean isValid = runOawCheck(diagnostics, allElements);
+ public boolean validate(final EClass eClass, final EObject eObject, final DiagnosticChain diagnostics,
+ final Map<Object, Object> context) {
+ final List<EObject> allElements = Collections.singletonList(eObject);
+ boolean isValid = runExtXptCheck(diagnostics, allElements);
if (_nestedValidator != null) {
- isValid &= _nestedValidator.validate(eClass, eObject, diagnostics,
- context);
+ isValid &= _nestedValidator.validate(eClass, eObject, diagnostics, context);
}
return isValid;
}
- public boolean validate(EDataType dataType, Object value,
- DiagnosticChain diagnostics, Map<Object, Object> context) {
- List<?> allElements = Collections.singletonList(dataType);
- boolean isValid = runOawCheck(diagnostics, allElements);
+ public boolean validate(final EDataType dataType, final Object value, final DiagnosticChain diagnostics,
+ final Map<Object, Object> context) {
+ final List<?> allElements = Collections.singletonList(dataType);
+ boolean isValid = runExtXptCheck(diagnostics, allElements);
if (_nestedValidator != null) {
- isValid &= _nestedValidator.validate(dataType, value, diagnostics,
- context);
+ isValid &= _nestedValidator.validate(dataType, value, diagnostics, context);
}
return isValid;
}
-
- public void setExternalResourceManager(ResourceManager externalResourceManager) {
+ public void setExternalResourceManager(final ResourceManager externalResourceManager) {
_externalResourceManager = externalResourceManager;
}
-
+
private ResourceManager getResourceManager() {
- if(_externalResourceManager != null) {
+ if (_externalResourceManager != null)
return _externalResourceManager;
- }
return new ResourceManagerDefaultImpl();
}
- private ExecutionContext createExecutionContext(
- CheckFileWithContext checkFile, ResourceManager resourceManager) {
+ private ExecutionContext createExecutionContext(final CheckFileWithContext checkFile,
+ final ResourceManager resourceManager) {
final Set<EPackage> allEPackages = new HashSet<EPackage>();
allEPackages.add(_ePackage);
- for (String nsURI : checkFile.getImportedEPackageNsUris()) {
+ for (final String nsURI : checkFile.getImportedEPackageNsUris()) {
try {
- EPackage importedEPackage = EPackage.Registry.INSTANCE
- .getEPackage(nsURI);
+ final EPackage importedEPackage = EPackage.Registry.INSTANCE.getEPackage(nsURI);
if (importedEPackage != null) {
allEPackages.add(importedEPackage);
}
- } catch (Exception exc) {
+ }
+ catch (final Exception exc) {
log.error(exc);
}
}
- TypeSystemImpl typeSystem = new TypeSystemImpl();
+ final TypeSystemImpl typeSystem = new TypeSystemImpl();
typeSystem.registerMetaModel(new EmfMetaModel() {
- private EPackage[] _allEPackages = allEPackages
- .toArray(new EPackage[allEPackages.size()]);
+ private final EPackage[] _allEPackages = allEPackages.toArray(new EPackage[allEPackages.size()]);
@Override
protected EPackage[] allPackages() {
return _allEPackages;
}
});
- ExecutionContext executionContext = new ExecutionContextImpl(
- resourceManager, typeSystem, null);
+ final ExecutionContext executionContext = new ExecutionContextImpl(resourceManager, typeSystem, null);
return executionContext;
}
- private boolean runOawCheck(DiagnosticChain diagnostics, List<?> allElements) {
+ private boolean runExtXptCheck(final DiagnosticChain diagnostics, final List<?> allElements) {
boolean isValid = true;
- ResourceLoader current = ResourceLoaderFactory.getCurrentThreadResourceLoader();
+ final ResourceLoader current = ResourceLoaderFactory.getCurrentThreadResourceLoader();
try {
ResourceLoaderFactory.setCurrentThreadResourceLoader(new ResourceLoaderImpl(getClass().getClassLoader()));
- for (CheckFileWithContext checkFile : _checkFiles) {
- Issues issues = new IssuesImpl();
- ResourceManager resourceManager = getResourceManager();
- ExtensionFile parsedCheckFile = (ExtensionFile) resourceManager
- .loadResource(checkFile.getFileName(),
- CheckUtils.FILE_EXTENSION);
- if (parsedCheckFile==null)
- throw new IllegalArgumentException("Couldn't find file "+checkFile.getFileName()+"."+CheckUtils.FILE_EXTENSION+". Maybe it has been misspelled or it's not on the classpath?");
- ExecutionContext executionContext = createExecutionContext(checkFile, resourceManager);
- runOawCheck(parsedCheckFile, allElements, diagnostics,
- executionContext);
+ for (final CheckFileWithContext checkFile : _checkFiles) {
+ final Issues issues = new IssuesImpl();
+ final ResourceManager resourceManager = getResourceManager();
+ final ExtensionFile parsedCheckFile = (ExtensionFile) resourceManager.loadResource(checkFile
+ .getFileName(), CheckUtils.FILE_EXTENSION);
+ if (parsedCheckFile == null)
+ throw new IllegalArgumentException("Couldn't find file " + checkFile.getFileName() + "."
+ + CheckUtils.FILE_EXTENSION
+ + ". Maybe it has been misspelled or it's not on the classpath?");
+ final ExecutionContext executionContext = createExecutionContext(checkFile, resourceManager);
+ runOawCheck(parsedCheckFile, allElements, diagnostics, executionContext);
isValid &= issues.hasErrors();
}
- } finally {
+ }
+ finally {
ResourceLoaderFactory.setCurrentThreadResourceLoader(current);
}
return isValid;
}
- private Issues runOawCheck(ExtensionFile parsedCheckFile,
- List<?> allElements, DiagnosticChain diagnostics,
- ExecutionContext executionContext) {
- Issues issues = new IssuesImpl();
+ private Issues runOawCheck(final ExtensionFile parsedCheckFile, final List<?> allElements,
+ final DiagnosticChain diagnostics, final ExecutionContext executionContext) {
+ final Issues issues = new IssuesImpl();
parsedCheckFile.check(executionContext, allElements, issues, false);
addDiagnosticFromIssues(diagnostics, issues);
return issues;
}
- private void addDiagnosticFromIssues(
- DiagnosticChain allDiagnostics, Issues issues) {
- MWEDiagnostic[] errors = issues.getErrors();
+ private void addDiagnosticFromIssues(final DiagnosticChain allDiagnostics, final Issues issues) {
+ final MWEDiagnostic[] errors = issues.getErrors();
addDiagnostics(allDiagnostics, errors);
-
- MWEDiagnostic[] warnings = issues.getWarnings();
+
+ final MWEDiagnostic[] warnings = issues.getWarnings();
addDiagnostics(allDiagnostics, warnings);
}
- private void addDiagnostics(DiagnosticChain allDiagnostics,
- MWEDiagnostic[] issues) {
- for (MWEDiagnostic issue : issues) {
+ private void addDiagnostics(final DiagnosticChain allDiagnostics, final MWEDiagnostic[] issues) {
+ for (final MWEDiagnostic issue : issues) {
allDiagnostics.add(issue);
}
}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java
index 5e8ac8c..d760e29 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java
@@ -56,23 +56,23 @@ public class CheckRegistry {
public void registerCheckFile(EPackage ePackage, String checkFileName, boolean isWrapExistingValidator,
List<String> referencedEPackageNsURIs) {
- CheckEValidatorAdapter oawValidator;
+ CheckEValidatorAdapter extxptValidator;
if (isWrapExistingValidator) {
EValidator validator = EValidator.Registry.INSTANCE.getEValidator(ePackage);
if (validator instanceof CheckEValidatorAdapter)
- oawValidator = (CheckEValidatorAdapter) validator;
+ extxptValidator = (CheckEValidatorAdapter) validator;
else
- oawValidator = new CheckEValidatorAdapter(ePackage, validator);
+ extxptValidator = new CheckEValidatorAdapter(ePackage, validator);
}
else {
- oawValidator = new CheckEValidatorAdapter(ePackage);
+ extxptValidator = new CheckEValidatorAdapter(ePackage);
}
CheckFileWithContext checkFile = new CheckFileWithContext(checkFileName);
for (String referencedEPackageNsURI : referencedEPackageNsURIs) {
checkFile.addImportedEPackageNsUri(referencedEPackageNsURI);
}
- oawValidator.addCheckFile(checkFile);
- EValidator.Registry.INSTANCE.put(ePackage, oawValidator);
+ extxptValidator.addCheckFile(checkFile);
+ EValidator.Registry.INSTANCE.put(ePackage, extxptValidator);
}
private void registerExtensions() {
diff --git a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/core/internal/builder/PluginJavaExtensionStatement.java b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/core/internal/builder/PluginJavaExtensionStatement.java
index 9d3d090..0547874 100644
--- a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/core/internal/builder/PluginJavaExtensionStatement.java
+++ b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/core/internal/builder/PluginJavaExtensionStatement.java
@@ -30,21 +30,24 @@ public class PluginJavaExtensionStatement extends JavaExtensionStatement {
private IJavaProject jp;
- public PluginJavaExtensionStatement(final IJavaProject jp,
- final Identifier name, final List formalParameters, final Identifier returnType, final Identifier javaType, final Identifier javaMethod, final List javaParamTypes,
- final boolean cached, final boolean isPriv) {
- super(name, formalParameters, returnType,javaType, javaMethod, javaParamTypes,
- cached, isPriv);
+ @SuppressWarnings("unchecked")
+ public PluginJavaExtensionStatement(final IJavaProject jp, final Identifier name, final List formalParameters,
+ final Identifier returnType, final Identifier javaType, final Identifier javaMethod,
+ final List javaParamTypes, final boolean cached, final boolean isPriv) {
+ super(name, formalParameters, returnType, javaType, javaMethod, javaParamTypes, cached, isPriv);
this.jp = jp;
}
+ @SuppressWarnings("unchecked")
@Override
public void analyzeInternal(final ExecutionContext ctx, final Set issues) {
+ checkForAmbiguousDefinitions(ctx, issues);
boolean everythingFine = true;
IType it = null;
try {
it = jp.findType(getJavaType().getValue());
- } catch (final JavaModelException e) {
+ }
+ catch (final JavaModelException e) {
XtendLog.logError(e);
}
if (it == null) {
@@ -59,7 +62,8 @@ public class PluginJavaExtensionStatement extends JavaExtensionStatement {
final Identifier typeName = (Identifier) l.get(i);
try {
pts[i] = jp.findType(typeName.getValue());
- } catch (final JavaModelException e) {
+ }
+ catch (final JavaModelException e) {
issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, typeName.getValue() + " not found",
typeName));
everythingFine = false;
@@ -68,7 +72,8 @@ public class PluginJavaExtensionStatement extends JavaExtensionStatement {
issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, typeName.getValue() + " not found",
typeName));
everythingFine = false;
- } else {
+ }
+ else {
signs[i] = Signature.createTypeSignature(pts[i].getFullyQualifiedName(), true);
}
}
@@ -84,7 +89,8 @@ public class PluginJavaExtensionStatement extends JavaExtensionStatement {
int f = 0;
try {
f = ms[0].getFlags();
- } catch (final JavaModelException e) {
+ }
+ catch (final JavaModelException e) {
XtendLog.logError(e);
return;
}
diff --git a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendEditor.java b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendEditor.java
index 5838d15..2757a42 100644
--- a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendEditor.java
+++ b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/XtendEditor.java
@@ -23,11 +23,13 @@ public class XtendEditor extends AbstractXtendXpandEditor {
setDocumentProvider(new XtendDocumentProvider());
}
-
@Override
protected AbstractExtXptContentOutlinePage createOutlinePage() {
return new XtendContentOutlinePage(this);
}
-
+ @Override
+ protected void initializeKeyBindingScopes() {
+ setKeyBindingScopes(new String[] { "org.eclipse.xtend.editor.XtendEditorScope" }); //$NON-NLS-1$
+ }
}
diff --git a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/scanning/XtendPartitionScanner.java b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/scanning/XtendPartitionScanner.java
index f873044..c4057f4 100644
--- a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/scanning/XtendPartitionScanner.java
+++ b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/editor/scanning/XtendPartitionScanner.java
@@ -38,11 +38,11 @@ public class XtendPartitionScanner extends RuleBasedPartitionScanner {
final List<IPredicateRule> rules = new ArrayList<IPredicateRule>();
- rules.add(new MultiLineRule("/*", "*/", comment));
+ rules.add(new MultiLineRule("/*", "*/", comment, (char) 0, true));
rules.add(new SingleLineRule("//", "", comment));
- rules.add(new MultiLineRule("'", "'", stringLit,'\\'));
- rules.add(new MultiLineRule("\"", "\"", stringLit,'\\'));
+ rules.add(new MultiLineRule("'", "'", stringLit, '\\', true));
+ rules.add(new MultiLineRule("\"", "\"", stringLit, '\\', true));
setPredicateRules(rules.toArray(new IPredicateRule[rules.size()]));
}
diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java
index c580be5..c17f7ec 100644
--- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java
+++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java
@@ -18,29 +18,17 @@ import org.apache.commons.logging.LogFactory;
* Contains extension functions for logging messages and errors.
*/
public class IOExtensions {
- private final static Log log = LogFactory.getLog(IOExtensions.class);
-
- public final static void syserr(final Object s) {
- System.err.println(s);
- }
-
- public final static void syserr(final Object s, String prefix) {
- System.err.println("["+prefix+"] "+s);
- }
public final static void debug(final Object s) {
- log.debug(s);
+ System.out.println(s);
}
public final static void info(final Object s) {
- log.info(s);
+ System.out.println("info: "+s);
}
public final static void error(final Object s) {
- log.error(s);
- }
- public final static void throwError(final Object s) {
- throw new IllegalStateException(""+s);
+ System.err.println(s);
}
}
diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java
index cca2867..03c66b3 100644
--- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java
+++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java
@@ -48,7 +48,7 @@ import org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory;
* <h2>Example</h2> Workflow configuration:
*
* <pre>
- * &lt;component class=&quot;oaw.util.stdlib.PropertiesReader&quot;&gt;
+ * &lt;component class=&quot;org.eclipse.xtend.util.stdlib.PropertiesReader&quot;&gt;
* &lt;propertiesFile value=&quot;src/config1.properties&quot;/&gt;
* &lt;propertiesFile value=&quot;src/config2.properties&quot;/&gt;
* &lt;/component&gt;
@@ -76,13 +76,13 @@ public class PropertiesReader extends AbstractWorkflowComponent2 {
private List<String> propertiesFile;
@Override
- protected void checkConfigurationInternal(Issues issues) {
+ protected void checkConfigurationInternal(final Issues issues) {
if (propertiesFile == null || propertiesFile.isEmpty()) {
issues.addError("propertiesFile not set. ");
}
else {
- for (String uri : propertiesFile) {
- URL url = ResourceLoaderFactory.createResourceLoader().getResource(uri);
+ for (final String uri : propertiesFile) {
+ final URL url = ResourceLoaderFactory.createResourceLoader().getResource(uri);
if (url == null) {
issues.addError("propertiesFile '" + uri + "' not found.");
}
@@ -91,18 +91,18 @@ public class PropertiesReader extends AbstractWorkflowComponent2 {
}
@Override
- protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
- ResourceLoader rl = ResourceLoaderFactory.createResourceLoader();
- for (String uri : propertiesFile) {
+ protected void invokeInternal(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) {
+ final ResourceLoader rl = ResourceLoaderFactory.createResourceLoader();
+ for (final String uri : propertiesFile) {
try {
- Properties p = new Properties();
+ final Properties p = new Properties();
if (LOG.isDebugEnabled()) {
LOG.debug("Reading properties file " + uri);
}
p.load(rl.getResourceAsStream(uri));
PropertiesExtension.setProperties(p);
}
- catch (Exception e) {
+ catch (final Exception e) {
issues.addError(e.getMessage(), e);
}
}
@@ -114,7 +114,7 @@ public class PropertiesReader extends AbstractWorkflowComponent2 {
* @param propertiesFile
* A properties file
*/
- public final void addPropertiesFile(String propFile) {
+ public final void addPropertiesFile(final String propFile) {
if (propertiesFile == null) {
propertiesFile = new ArrayList<String>();
}
diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SystemCommand.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SystemCommand.java
index afbccb6..f67d454 100644
--- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SystemCommand.java
+++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SystemCommand.java
@@ -62,7 +62,7 @@ import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;
* <h2>Example</h2>
*
* <pre>
- * &lt;component class=&quot;oaw.util.stdlib.SystemCommand&quot;&gt;
+ * &lt;component class=&quot;org.ecipse.xtend.util.stdlib.SystemCommand&quot;&gt;
* &lt;directory value=&quot;src-gen&quot;/&gt;
* &lt;command value=&quot;sh&quot;/&gt;
* &lt;arg value=&quot;processdot.sh&quot;/&gt;
@@ -82,31 +82,31 @@ public class SystemCommand extends AbstractWorkflowComponent2 {
private File directory;
- private boolean inheritEnvironment = false;
+ private final boolean inheritEnvironment = false;
- private List<String> args = new ArrayList<String>();
- private List<String> enventry = new ArrayList<String>();
+ private final List<String> args = new ArrayList<String>();
+ private final List<String> enventry = new ArrayList<String>();
@Override
- protected void checkConfigurationInternal(Issues issues) {
+ protected void checkConfigurationInternal(final Issues issues) {
if (command == null) {
issues.addError("command not specified");
}
}
@Override
- protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
+ protected void invokeInternal(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) {
try {
int rc;
- List<String> pbArgs = new ArrayList<String>();
+ final List<String> pbArgs = new ArrayList<String>();
pbArgs.add(command);
pbArgs.addAll(args);
- ProcessBuilder pb = new ProcessBuilder(pbArgs);
+ final ProcessBuilder pb = new ProcessBuilder(pbArgs);
if (directory != null) {
pb.directory(directory);
}
- for (String env : enventry) {
- String[] keyvalue = env.split(",");
+ for (final String env : enventry) {
+ final String[] keyvalue = env.split(",");
pb.environment().put(keyvalue[0], keyvalue[1]);
}
if (inheritEnvironment) {
@@ -121,7 +121,7 @@ public class SystemCommand extends AbstractWorkflowComponent2 {
log
.info("Running command '" + pb.command() + "' in directory " + pb.directory().getAbsolutePath()
+ " ...");
- Process p = pb.start();
+ final Process p = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String lineRead;
@@ -147,7 +147,7 @@ public class SystemCommand extends AbstractWorkflowComponent2 {
log.info("Execution of command was successful.");
}
}
- catch (Exception re) {
+ catch (final Exception re) {
issues.addError("Runtime error: " + re.getMessage());
}
}
@@ -156,19 +156,19 @@ public class SystemCommand extends AbstractWorkflowComponent2 {
return command;
}
- public void setCommand(String command) {
+ public void setCommand(final String command) {
this.command = command;
}
- public void setDirectory(File directory) {
+ public void setDirectory(final File directory) {
this.directory = directory;
}
- public void addArg(String arg) {
+ public void addArg(final String arg) {
args.add(arg);
}
- public void addEnv(String entry) {
+ public void addEnv(final String entry) {
if (!entry.matches("\\A[^,]+,.+\\z"))
throw new IllegalArgumentException(entry);
enventry.add(entry);
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java
index 1abc1db..287f5ef 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java
@@ -10,9 +10,8 @@
*******************************************************************************/
package org.eclipse.internal.xtend.expression.ast;
-public abstract class AbstractExpressionVisitor extends AbstractVisitor {
+public abstract class AbstractExpressionVisitor extends AbstractVisitor{
- @Override
public final Object visit(final ISyntaxElement ele) {
Object result = null;
if (result == null && ele instanceof BooleanOperation) {
@@ -72,139 +71,120 @@ public abstract class AbstractExpressionVisitor extends AbstractVisitor {
return result;
}
- protected Object visitBooleanOperation(BooleanOperation node) {
- if (node.getLeft() != null) {
+ protected Object visitBooleanOperation(BooleanOperation node){
+ if(node.getLeft() != null)
node.getLeft().accept(this);
- }
- if (node.getRight() != null) {
+ if(node.getRight() != null)
node.getRight().accept(this);
- }
return node;
}
- protected Object visitCast(Cast node) {
- if (node.getTarget() != null) {
+ protected Object visitCast(Cast node){
+ if(node.getTarget() != null)
node.getTarget().accept(this);
- }
return node;
}
- protected Object visitConstructorCallExpression(ConstructorCallExpression node) {
+ protected Object visitConstructorCallExpression(ConstructorCallExpression node){
return node;
}
- protected Object visitGlobalVarExpression(GlobalVarExpression node) {
+ protected Object visitGlobalVarExpression(GlobalVarExpression node){
return node;
}
protected Object visitChainExpression(ChainExpression ce) {
- if (ce.getFirst() != null) {
+ if(ce.getFirst() != null)
ce.getFirst().accept(this);
- }
- if (ce.getNext() != null) {
+ if(ce.getNext() != null)
ce.getNext().accept(this);
- }
return ce;
}
protected Object visitFeatureCall(FeatureCall fc) {
- if (fc.getTarget() != null) {
+ if(fc.getTarget() != null)
fc.getTarget().accept(this);
- }
return fc;
}
- protected Object visitCollectionExpression(CollectionExpression node) {
- if (node.getClosure() != null) {
+ protected Object visitCollectionExpression(CollectionExpression node){
+ if(node.getClosure() != null)
node.getClosure().accept(this);
- }
- if (node.getTarget() != null) {
+ if(node.getTarget() != null)
node.getTarget().accept(this);
- }
return node;
}
protected Object visitOperationCall(OperationCall oc) {
- if (oc.getTarget() != null) {
+ if(oc.getTarget() != null)
oc.getTarget().accept(this);
- }
- if (oc.getParamsAsList() != null) {
- for (Expression expr : oc.getParamsAsList()) {
+ if(oc.getParamsAsList() != null){
+ for(Expression expr: oc.getParamsAsList()){
expr.accept(this);
}
}
return oc;
}
- protected Object visitTypeSelectExpression(TypeSelectExpression node) {
- if (node.getTarget() != null) {
+ protected Object visitTypeSelectExpression(TypeSelectExpression node){
+ if(node.getTarget() != null)
node.getTarget().accept(this);
- }
return node;
}
- protected Object visitIfExpression(IfExpression node) {
- if (node.getCondition() != null) {
+ protected Object visitIfExpression(IfExpression node){
+ if(node.getCondition() != null)
node.getCondition().accept(this);
- }
- if (node.getThenPart() != null) {
+ if(node.getThenPart() != null)
node.getThenPart().accept(this);
- }
- if (node.getElsePart() != null) {
+ if(node.getElsePart() != null)
node.getElsePart().accept(this);
- }
return node;
}
- protected Object visitLetExpression(LetExpression node) {
- if (node.getTargetExpression() != null) {
+ protected Object visitLetExpression(LetExpression node){
+ if(node.getTargetExpression() != null)
node.getTargetExpression().accept(this);
- }
- if (node.getVarExpression() != null) {
+ if(node.getVarExpression() != null)
node.getVarExpression().accept(this);
- }
return node;
}
- protected Object visitSwitchExpression(SwitchExpression node) {
+ protected Object visitSwitchExpression(SwitchExpression node){
for (Case caze : node.getCases()) {
- if (caze.getCondition() != null) {
+ if(caze.getCondition() != null)
caze.getCondition().accept(this);
- }
- if (caze.getThenPart() != null) {
+ if(caze.getThenPart() != null)
caze.getThenPart().accept(this);
}
- }
- if (node.getSwitchExpr() != null) {
+ if(node.getSwitchExpr() != null)
node.getSwitchExpr().accept(this);
- }
- if (node.getDefaultExpr() != null) {
+ if(node.getDefaultExpr() != null)
node.getDefaultExpr().accept(this);
- }
return node;
}
- protected Object visitListLiteral(ListLiteral node) {
+ protected Object visitListLiteral(ListLiteral node){
return node;
}
- protected Object visitBooleanLiteral(BooleanLiteral node) {
+ protected Object visitBooleanLiteral(BooleanLiteral node){
return node;
}
- protected Object visitIntegerLiteral(IntegerLiteral node) {
+ protected Object visitIntegerLiteral(IntegerLiteral node){
return node;
}
- protected Object visitNullLiteral(NullLiteral node) {
+ protected Object visitNullLiteral(NullLiteral node){
return node;
}
- protected Object visitRealLiteral(RealLiteral node) {
+ protected Object visitRealLiteral(RealLiteral node){
return node;
}
- protected Object visitStringLiteral(StringLiteral node) {
+ protected Object visitStringLiteral(StringLiteral node){
return node;
}
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java
index cf86724..4a3c0ab 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java
@@ -23,7 +23,7 @@ import org.eclipse.xtend.typesystem.Type;
*/
public class BooleanLiteral extends Literal {
- public BooleanLiteral(final Identifier literalValue) {
+ public BooleanLiteral( final Identifier literalValue) {
super(literalValue);
}
@@ -32,7 +32,6 @@ public class BooleanLiteral extends Literal {
return new Boolean(getLiteralValue().getValue());
}
- @Override
public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
return ctx.getBooleanType();
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java
index 6085e70..4c520eb 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java
@@ -41,7 +41,7 @@ public class CollectionExpression extends FeatureCall {
private Identifier eleName;
public CollectionExpression(final Identifier name, final Identifier eleName, final Expression closure) {
- super(name, null);
+ super(name,null);
this.eleName = eleName;
this.closure = closure;
}
@@ -51,7 +51,7 @@ public class CollectionExpression extends FeatureCall {
return super.toStringInternal() + "(" + (eleName != null ? eleName.getValue() + "|" : "") + closure + ")";
}
- public Expression getClosure() {
+ public Expression getClosure () {
return closure;
}
@@ -63,15 +63,14 @@ public class CollectionExpression extends FeatureCall {
if (v != null) {
targetObj = v.getValue();
}
- }
- else {
+ } else {
targetObj = getTarget().evaluate(ctx);
}
if (targetObj == null)
return ctx.handleNullEvaluation(this);
- if (!(targetObj instanceof Collection))
- throw new EvaluationException("Couldn't call '" + toString() + "' on an object of java type "
- + targetObj.getClass().getName(), this, ctx);
+ if (!(targetObj instanceof Collection)) {
+ throw new EvaluationException("Couldn't call '"+this.toString()+"' on an object of java type "+targetObj.getClass().getName(),this, ctx);
+ }
if (getName().getValue().equals(SyntaxConstants.COLLECT))
return executeCollect((Collection) targetObj, ctx);
@@ -98,23 +97,22 @@ public class CollectionExpression extends FeatureCall {
private Object executeSortBy(Collection collection, final ExecutionContext ctx) {
List<Object> result = new ArrayList<Object>();
result.addAll(collection);
- Collections.sort(result, new Comparator<Object>() {
+ Collections.sort(result, new Comparator<Object> () {
@SuppressWarnings("unchecked")
public int compare(Object o1, Object o2) {
final Object a = closure.evaluate(ctx.cloneWithVariable(new Variable(getElementName(), o1)));
final Object b = closure.evaluate(ctx.cloneWithVariable(new Variable(getElementName(), o2)));
- if (a == b)
+ if (a==b)
return 0;
- if (a == null)
+ if (a==null)
return -1;
- if (b == null)
+ if (b==null)
return 1;
if (a instanceof Comparable)
- return ((Comparable) a).compareTo(b);
+ return ((Comparable)a).compareTo(b);
return a.toString().compareTo(b.toString());
- }
- });
+ }});
return result;
}
@@ -185,8 +183,7 @@ public class CollectionExpression extends FeatureCall {
resultCol.add(ele);
}
}
- if (resultCol.size() == 0)
- return null;
+ if ( resultCol.size() == 0 ) return null;
return resultCol.iterator().next();
}
@@ -209,8 +206,7 @@ public class CollectionExpression extends FeatureCall {
if (v != null) {
targetType = (Type) v.getValue();
}
- }
- else {
+ } else {
targetType = getTarget().analyze(ctx, issues);
}
if (targetType == null)
@@ -233,20 +229,19 @@ public class CollectionExpression extends FeatureCall {
return ctx.getListType(closureType);
else
return ctx.getCollectionType(closureType);
- }
- else if (getName().getValue().equals(SyntaxConstants.SELECT)
- || getName().getValue().equals(SyntaxConstants.REJECT))
+ } else if (getName().getValue().equals(SyntaxConstants.SELECT)
+ || getName().getValue().equals(SyntaxConstants.REJECT)
+ ) {
return targetType;
- else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST))
+ } else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) {
return innerType;
- else if (getName().getValue().equals(SyntaxConstants.SORT_BY))
+ } else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) {
return ctx.getListType(innerType);
- else if (getName().getValue().equals(SyntaxConstants.TYPE_SELECT)) {
+ }else if (getName().getValue().equals(SyntaxConstants.TYPE_SELECT)) {
if (closureType == null)
return null;
return ctx.getListType(closureType);
- }
- else if (getName().getValue().equals(SyntaxConstants.EXISTS)
+ } else if (getName().getValue().equals(SyntaxConstants.EXISTS)
|| getName().getValue().equals(SyntaxConstants.NOT_EXISTS)
|| getName().getValue().equals(SyntaxConstants.FOR_ALL)) {
if (!ctx.getBooleanType().isAssignableFrom(closureType)) {
@@ -254,8 +249,7 @@ public class CollectionExpression extends FeatureCall {
+ closureType, closure));
}
result = ctx.getBooleanType();
- }
- else {
+ } else {
issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Unknown operation : "
+ getName().getValue(), this));
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java
index 01252c2..175198f 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java
@@ -29,11 +29,7 @@ public class ConstructorCallExpression extends Expression {
this.type = type;
}
- public Identifier getType() {
- return type;
- }
-
- public String getTypeName() {
+ public String getTypeName () {
return type.getValue();
}
@@ -46,7 +42,6 @@ public class ConstructorCallExpression extends Expression {
throw new EvaluationException("Couldn't find type " + type, this, ctx);
}
- @Override
public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
final Type t = ctx.getTypeForName(type.getValue());
if (t == null) {
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java
index 00ff932..d766302 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java
@@ -31,7 +31,7 @@ public class IntegerLiteral extends Literal {
@Override
public Object evaluateInternal(final ExecutionContext ctx) {
- return new BigInteger(getLiteralValue().getValue());
+ return new Long(getLiteralValue().getValue());
}
public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java
index fdc7f99..fd92af4 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java
@@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -36,7 +35,7 @@ import org.eclipse.xtend.typesystem.Type;
*/
public class OperationCall extends FeatureCall {
- private Expression[] params;
+ private final Expression[] params;
public OperationCall(final Identifier name, final Expression target, final Expression... params) {
super(name, target);
@@ -56,7 +55,7 @@ public class OperationCall extends FeatureCall {
// evaluate from left to right
// first the target
Object targetObj = null;
- if (getTarget()!=null) {
+ if (getTarget() != null) {
targetObj = getTarget().evaluate(ctx);
}
// then the parameters in the defined order
@@ -66,7 +65,7 @@ public class OperationCall extends FeatureCall {
evaluatedParams[i] = getParams()[i].evaluate(ctx);
}
}
-
+
if (getTarget() == null) {
// extension
final Extension f = ctx.getExtension(getName().getValue(), evaluatedParams);
@@ -74,10 +73,12 @@ public class OperationCall extends FeatureCall {
ProfileCollector.getInstance().enter(f.toString());
try {
return evaluate(f, evaluatedParams, ctx);
- } catch (EvaluationException e) {
+ }
+ catch (final EvaluationException e) {
e.addStackElement(this, ctx);
throw e;
- } finally {
+ }
+ finally {
ProfileCollector.getInstance().leave();
}
}
@@ -85,10 +86,11 @@ public class OperationCall extends FeatureCall {
// implicite
final Variable var = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE);
if (var == null)
- throw new EvaluationException("Couldn't find extension '" + getName().getValue() + getParamTypes(evaluatedParams, ctx) + "'!", this, ctx);
+ throw new EvaluationException("Couldn't find extension '" + getName().getValue()
+ + getParamTypes(evaluatedParams, ctx) + "'!", this, ctx);
targetObj = var.getValue();
- }
-
+ }
+
// operation
Operation op = ctx.findOperation(getName().getValue(), targetObj, evaluatedParams);
if (op != null)
@@ -102,10 +104,12 @@ public class OperationCall extends FeatureCall {
try {
ProfileCollector.getInstance().enter(f.toString());
return evaluate(f, ps, ctx);
- } catch (EvaluationException e) {
+ }
+ catch (final EvaluationException e) {
e.addStackElement(this, ctx);
throw e;
- } finally {
+ }
+ finally {
ProfileCollector.getInstance().leave();
}
}
@@ -113,18 +117,19 @@ public class OperationCall extends FeatureCall {
if (targetObj instanceof Collection) {
final List<Object> result = new ArrayList<Object>();
final Collection<?> col = (Collection<?>) targetObj;
- for (final Iterator<?> iter = col.iterator(); iter.hasNext();) {
- final Object element = iter.next();
+ for (final Object element : col) {
// operation
op = ctx.findOperation(getName().getValue(), element, evaluatedParams);
if (op != null) {
final Object r = evaluate(op, element, evaluatedParams, ctx);
if (r instanceof Collection) {
result.addAll((Collection<?>) r);
- } else {
+ }
+ else {
result.add(r);
}
- } else {
+ }
+ else {
// extension as members
ps = new Object[evaluatedParams.length + 1];
ps[0] = element;
@@ -134,26 +139,31 @@ public class OperationCall extends FeatureCall {
Object r = null;
try {
r = evaluate(f, ps, ctx);
- } catch (EvaluationException e) {
+ }
+ catch (final EvaluationException e) {
e.addStackElement(this, ctx);
throw e;
}
if (r instanceof Collection) {
result.addAll((Collection<?>) r);
- } else {
+ }
+ else {
result.add(r);
}
- } else
- throw new EvaluationException("Couldn't find operation '" + getName().getValue() + getParamTypes(evaluatedParams, ctx) + "' for "
- + ctx.getType(targetObj).getName() + "!", this, ctx);
+ }
+ else
+ throw new EvaluationException("Couldn't find operation '" + getName().getValue()
+ + getParamTypes(evaluatedParams, ctx) + "' for " + ctx.getType(targetObj).getName()
+ + "!", this, ctx);
}
}
return result;
}
if (targetObj != null && f == null && op == null)
- throw new EvaluationException("Couldn't find operation '" + getName().getValue() + getParamTypes(evaluatedParams, ctx) + "' for "
- + ctx.getType(targetObj).getName() + ".", this, ctx);
+ throw new EvaluationException("Couldn't find operation '" + getName().getValue()
+ + getParamTypes(evaluatedParams, ctx) + "' for " + ctx.getType(targetObj).getName() + ".", this,
+ ctx);
return ctx.handleNullEvaluation(this);
}
@@ -187,18 +197,23 @@ public class OperationCall extends FeatureCall {
Extension f = null;
try {
f = ctx.getExtensionForTypes(getName().getValue(), paramTypes);
- } catch (final Exception e) {
- issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Error parsing extensions : " + e.getMessage(), this));
+ }
+ catch (final Exception e) {
+ issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Error parsing extensions : "
+ + e.getMessage(), this));
}
if (f != null)
return f.getReturnType(paramTypes, ctx, issues);
final Variable var = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE);
if (var != null) {
targetType = (Type) var.getValue();
- } else {
- issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, "Couldn't find extensions : " + toString(), this));
}
- } else {
+ else {
+ issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, "Couldn't find extensions : "
+ + toString(), this));
+ }
+ }
+ else {
targetType = getTarget().analyze(ctx, issues);
}
if (targetType == null)
@@ -235,43 +250,49 @@ public class OperationCall extends FeatureCall {
additionalMsg = " or type '" + innerType + "'";
}
- issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, "Couldn't find operation '" + getName().getValue()
- + getParamsString(paramTypes) + "' for type '" + targetType.getName() + "'" + additionalMsg, this));
+ issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, "Couldn't find operation '"
+ + getName().getValue() + getParamsString(paramTypes) + "' for type '" + targetType.getName() + "'"
+ + additionalMsg, this));
return null;
}
- private Type getExtensionsReturnType(final ExecutionContext ctx, final Set<AnalysationIssue> issues, final Type[] paramTypes,
- final Type targetType) {
+ private Type getExtensionsReturnType(final ExecutionContext ctx, final Set<AnalysationIssue> issues,
+ final Type[] paramTypes, final Type targetType) {
final Type[] pts = new Type[paramTypes.length + 1];
pts[0] = targetType;
System.arraycopy(paramTypes, 0, pts, 1, paramTypes.length);
Extension f = null;
try {
f = ctx.getExtensionForTypes(getName().getValue(), pts);
- } catch (final Exception e) {
- issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Error parsing extensions : " + e.getMessage(), this));
+ }
+ catch (final Exception e) {
+ issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Error parsing extensions : "
+ + e.getMessage(), this));
}
if (f != null) {
final Set<AnalysationIssue> temp = new HashSet<AnalysationIssue>();
final Type rt = f.getReturnType(pts, ctx, temp);
if (rt == null) {
- issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "couldn't resolve return type for extension " + f + "! Errors : "
- + temp.toString(), this));
+ issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR,
+ "couldn't resolve return type for extension " + f + "! Errors : " + temp.toString(), this));
}
return rt;
- } else if (getTarget() == null) { // try without implicite this
+ }
+ else if (getTarget() == null) { // try without implicite this
try {
f = ctx.getExtensionForTypes(getName().getValue(), paramTypes);
- } catch (final Exception e) {
- issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Error parsing extensions : " + e.getMessage(), this));
+ }
+ catch (final Exception e) {
+ issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Error parsing extensions : "
+ + e.getMessage(), this));
}
if (f != null) {
final Set<AnalysationIssue> temp = new HashSet<AnalysationIssue>();
final Type rt = f.getReturnType(pts, ctx, temp);
if (rt == null) {
- issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "couldn't resolve return type for extension " + f
- + "! Errors : " + temp.toString(), this));
+ issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR,
+ "couldn't resolve return type for extension " + f + "! Errors : " + temp.toString(), this));
}
return rt;
}
@@ -293,36 +314,43 @@ public class OperationCall extends FeatureCall {
@Override
protected String toStringInternal() {
- return (getTarget() != null ? getTarget().toStringInternal() + "." : "") + getName() + getParamsExpressionString(getParams());
+ return (getTarget() != null ? getTarget().toStringInternal() + "." : "") + getName()
+ + getParamsExpressionString(getParams());
}
@Override
- public String getNameString(ExecutionContext context) {
+ public String getNameString(final ExecutionContext context) {
final StringBuffer buff = new StringBuffer();
buff.append(getName().getValue());
buff.append("(");
if (params.length > 0)
- if (context != null)
+ if (context != null) {
buff.append(getParamTypesString(context));
- else
- // TODO: CK low: Get parameter types from OawModelManager for Breakpoints
+ }
+ else {
+ // TODO: CK low: Get parameter types from XtendXpandModelManager
+ // for Breakpoints
buff.append("..");
+ }
return buff.append(")").toString();
}
- private String getParamTypesString(ExecutionContext context) {
+ private String getParamTypesString(final ExecutionContext context) {
final ExecutionContext ctx = context.cloneWithoutMonitor();
final StringBuffer buff = new StringBuffer();
for (int i = 0; i < getParams().length; i++) {
- Type type = ctx.getType(params[i].evaluate(ctx));
- String name = type.getName();
- int pos = name.lastIndexOf("::");
- if (pos < 0)
+ final Type type = ctx.getType(params[i].evaluate(ctx));
+ final String name = type.getName();
+ final int pos = name.lastIndexOf("::");
+ if (pos < 0) {
buff.append(name);
- else
+ }
+ else {
buff.append(name.substring(pos + 2));
- if (i + 1 < params.length)
+ }
+ if (i + 1 < params.length) {
buff.append(",");
+ }
}
return buff.toString();
}
@@ -338,16 +366,17 @@ public class OperationCall extends FeatureCall {
return buff.append(")").toString();
}
- private Object evaluate(Extension ext, Object[] params, ExecutionContext ctx) {
+ private Object evaluate(final Extension ext, final Object[] params, final ExecutionContext ctx) {
ctx.preTask(this);
- Object result = ext.evaluate(params, ctx);
+ final Object result = ext.evaluate(params, ctx);
ctx.postTask(this);
return result;
}
- private Object evaluate(Operation op, Object targetObj, Object[] params, ExecutionContext ctx) {
+ private Object evaluate(final Operation op, final Object targetObj, final Object[] params,
+ final ExecutionContext ctx) {
ctx.preTask(this);
- Object result = op.evaluate(targetObj, params);
+ final Object result = op.evaluate(targetObj, params);
ctx.postTask(this);
return result;
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java
index 464d7e4..4b318f0 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java
@@ -35,7 +35,8 @@ public class SwitchExpression extends Expression {
private List<Case> cases = null;
- public SwitchExpression(final Expression switchExpr, final List<Case> cases, final Expression defaultExpr) {
+ public SwitchExpression(final Expression switchExpr,
+ final List<Case> cases, final Expression defaultExpr) {
this.switchExpr = switchExpr;
this.cases = cases;
this.defaultExpr = defaultExpr;
@@ -44,9 +45,8 @@ public class SwitchExpression extends Expression {
@Override
protected Object evaluateInternal(final ExecutionContext ctx) {
Object switchVal = Boolean.TRUE;
- if (switchExpr != null) {
+ if (switchExpr != null)
switchVal = switchExpr.evaluate(ctx);
- }
for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) {
final Case c = iter.next();
final Object caseCondVal = c.getCondition().evaluate(ctx);
@@ -64,12 +64,10 @@ public class SwitchExpression extends Expression {
return (Boolean) new ExpressionFacade(ctx).evaluate("swtch==cse", props);
}
- @Override
public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
Type condType = ctx.getBooleanType();
- if (switchExpr != null) {
+ if (switchExpr != null)
condType = switchExpr.analyze(ctx, issues);
- }
if (condType == null)
return null;
Type returnType = defaultExpr.analyze(ctx, issues);
@@ -89,8 +87,7 @@ public class SwitchExpression extends Expression {
if (!returnType.isAssignableFrom(caseThenType)) {
if (caseThenType.isAssignableFrom(returnType)) {
returnType = caseThenType;
- }
- else {
+ } else {
returnType = ctx.getObjectType();
}
}
@@ -113,6 +110,6 @@ public class SwitchExpression extends Expression {
@Override
protected String toStringInternal() {
- return "switch " + switchExpr.toStringInternal();
+ return "switch " + switchExpr.toStringInternal() ;
}
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java
index 50de562..50cb2b5 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java
@@ -99,8 +99,8 @@ public class ExpressionProposalComputer implements ProposalComputer {
private final static Map<String, String> blockTokens = new HashMap<String, String>();
static {
- blockTokens.put("(",")");
- blockTokens.put("{","}");
+ blockTokens.put("(", ")");
+ blockTokens.put("{", "}");
}
private static final Pattern QUALIFIED_NAME = Pattern.compile("\\W*(.*)(?:::\\w*)$");
@@ -179,7 +179,7 @@ public class ExpressionProposalComputer implements ProposalComputer {
if (m.matches()) {
String typeName = m.group(1);
implicitVariableType = ctx.getTypeForName(typeName);
- if (implicitVariableType!=null) {
+ if (implicitVariableType != null) {
for (StaticProperty p : implicitVariableType.getAllStaticProperties()) {
if (p.getName().startsWith(prefix)) {
proposals.add(factory.createStaticPropertyProposal(p, prefix, false));
@@ -506,7 +506,7 @@ public class ExpressionProposalComputer implements ProposalComputer {
private final static boolean isOpposite(final CommonToken left, final CommonToken right) {
final String temp = blockTokens.get(left.getText());
- if (temp==null)
+ if (temp == null)
return false;
return temp != null && right.getText().equals(temp);
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java
index b095e54..c802850 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java
@@ -24,13 +24,9 @@ public interface ProposalFactory {
/**
* Creates an proposal for a static property
- *
- * @param p
- * The property for which a proposal should be created
- * @param prefix
- * Current evaluation text prefix
- * @param onCollection
- * <code>true</code>: Proposal is computed on a collection
+ * @param p The property for which a proposal should be created
+ * @param prefix Current evaluation text prefix
+ * @param onCollection <code>true</code>: Proposal is computed on a collection
* @return A proposal for the content assist
*/
public Object createStaticPropertyProposal(StaticProperty p, String prefix, boolean onCollection);
@@ -65,4 +61,5 @@ public interface ProposalFactory {
public boolean isDuplicate(Set<String> nameCache, Object proposal);
public void addToCache(Set<String> nameCache, Object proposal);
+
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java
index fd8aa5a..758631c 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java
@@ -86,6 +86,7 @@ public class ProposalFactoryDefaultImpl implements ProposalFactory {
if (nameCache == null || proposal == null)
throw new IllegalArgumentException();
+
ProposalImpl p = castToProposal(proposal);
if (p != null) {
if (nameCache.contains(p.getDisplayString()))
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java
index b8e953d..5af8344 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java
@@ -21,29 +21,33 @@ import org.eclipse.xtend.expression.ExecutionContext;
*/
public abstract class BaseSpecialTreatment {
- public boolean shallNotSuspend(Object element, int flag, ExecutionContext context) {
+ public boolean shallNotSuspend(final Object element, final int flag, final ExecutionContext context) {
return false;
}
- public void adaptSyntaxElement(SyntaxElement to, Object element) {
+ public void adaptSyntaxElement(final SyntaxElement to, final Object element) {
// empty implementation
}
/**
- * add syntax element specific content to the element name that will be shown in Launch view
- * @param se the syntax element
- * @param context the execution context
+ * add syntax element specific content to the element name that will be
+ * shown in Launch view
+ *
+ * @param se
+ * the syntax element
+ * @param context
+ * the execution context
* @return the special text to add to the name
*/
- public String adaptElementName(ISyntaxElement se, ExecutionContext context){
+ public String adaptElementName(final ISyntaxElement se, final ExecutionContext context) {
return "";
}
- public ISyntaxElement getSpecialEndSyntaxElement(ISyntaxElement se){
+ public ISyntaxElement getSpecialEndSyntaxElement(final ISyntaxElement se) {
return null;
}
- public int getElementNameLength(ISyntaxElement se) {
+ public int getElementNameLength(final ISyntaxElement se) {
return -1;
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java
index 4c9d746..f678d4a 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java
@@ -39,7 +39,7 @@ import org.eclipse.xtend.typesystem.Property;
import org.eclipse.xtend.typesystem.Type;
/**
- * The IElementAdapter implementation for expressions.
+ * The ElementAdapter implementation for expressions.
*
* @author Bernd Kolb
* @author Clemens Kadura (zAJKa)
@@ -67,7 +67,7 @@ public class ExpressionElementAdapter implements ElementAdapter {
return context;
}
- public void setContext(Object context) {
+ public void setContext(final Object context) {
this.context = (ExecutionContext) context;
}
@@ -77,85 +77,85 @@ public class ExpressionElementAdapter implements ElementAdapter {
// -------------------------------------------------------------------------
- public boolean canHandle(Object element) {
+ public boolean canHandle(final Object element) {
if (element instanceof Expression)
return true;
if (element instanceof SyntaxElement) {
- SyntaxElement se = (SyntaxElement) element;
+ final SyntaxElement se = (SyntaxElement) element;
return se.resource.endsWith(".ext");
}
return false;
}
- public boolean shallHandle(Object element) {
+ public boolean shallHandle(final Object element) {
return element instanceof OperationCall && ((OperationCall) element).getName().getValue().length() > 2;
}
- public boolean shallSuspend(Object element, int flag) {
+ public boolean shallSuspend(final Object element, final int flag) {
boolean result = true;
- for (BaseSpecialTreatment special : specials) {
- result &= !(special.shallNotSuspend(element, flag, context));
+ for (final BaseSpecialTreatment special : specials) {
+ result &= !special.shallNotSuspend(element, flag, context);
}
return result;
}
- public SyntaxElement createElementTO(Object element) {
- SyntaxElement to = pres.getStartPresentation((ISyntaxElement) element, context);
- for (BaseSpecialTreatment special : specials) {
+ public SyntaxElement createElement(final Object element) {
+ final SyntaxElement to = pres.getStartPresentation((ISyntaxElement) element, context);
+ for (final BaseSpecialTreatment special : specials) {
special.adaptSyntaxElement(to, element);
}
return to;
}
- public boolean isSurroundingElement(Object element) {
+ public boolean isSurroundingElement(final Object element) {
return false;
}
- public SyntaxElement createEndElementTO(Object element) {
+ public SyntaxElement createEndElementTO(final Object element) {
// TODO: CK: low: decide where end location is available and set it here
return pres.getEndPresentation((org.eclipse.internal.xtend.expression.ast.SyntaxElement) element, context);
}
- public String getVariableDetailRep(Object element) {
+ public String getVariableDetailRep(final Object element) {
return pres.getStringRep(element);
}
- public String getVariableSimpleRep(Object element) {
+ public String getVariableSimpleRep(final Object element) {
return pres.getVariableSimpleRep(element, context);
}
- public boolean checkVariableHasMembers(Object element) {
+ public boolean checkVariableHasMembers(final Object element) {
if (element instanceof Collection)
return !((Collection<?>) element).isEmpty();
if (element instanceof Type) {
- Type t = (Type) element;
+ final Type t = (Type) element;
return t.getAllProperties().size() > 0;
}
return context.getType(element).getAllProperties().size() > 0;
}
- public List<NameValuePair> getVariables(Object element) {
+ public List<NameValuePair> getVariables(final Object element) {
if (element instanceof ChainExpression || element instanceof Literal)
return Collections.EMPTY_LIST;
if (element instanceof OperationCall) {
- ArrayList<NameValuePair> result = getAllVisibleVariables();
+ final ArrayList<NameValuePair> result = getAllVisibleVariables();
- Map<String, Variable> visibleVariables = context.getVisibleVariables();
+ final Map<String, Variable> visibleVariables = context.getVisibleVariables();
- Expression[] params = ((OperationCall) element).getParams();
- for (Expression expression : params) {
+ final Expression[] params = ((OperationCall) element).getParams();
+ for (final Expression expression : params) {
if (expression instanceof FeatureCall && !(expression instanceof OperationCall)) {
- FeatureCall fc = (FeatureCall) expression;
+ final FeatureCall fc = (FeatureCall) expression;
if (!visibleVariables.containsKey(fc.toString())) {
result.addAll(evaluateFeatureCall(fc));
}
}
}
- Expression target = ((OperationCall) element).getTarget();
+ final Expression target = ((OperationCall) element).getTarget();
if (target instanceof FeatureCall && !(target instanceof OperationCall)) {
if (!visibleVariables.containsKey(target.toString())) {
- FeatureCall fc = (FeatureCall) target;
+ final FeatureCall fc = (FeatureCall) target;
result.addAll(evaluateFeatureCall(fc));
}
@@ -166,25 +166,25 @@ public class ExpressionElementAdapter implements ElementAdapter {
if (element instanceof FeatureCall)
return evaluateFeatureCall((FeatureCall) element);
if (element instanceof Collection) {
- List<NameValuePair> result = new ArrayList<NameValuePair>();
- Collection col = (Collection) element;
+ final List<NameValuePair> result = new ArrayList<NameValuePair>();
+ final Collection col = (Collection) element;
int i = 0;
- for (Object object : col) {
+ for (final Object object : col) {
result.add(new NameValuePair("[" + i + "]", object));
i++;
}
return result;
}
- Type type = context.getType(element);
+ final Type type = context.getType(element);
return getAllPropertiesFor(type, element);
}
- public Object findElement(SyntaxElement se, Object actual, int flag) {
+ public Object findElement(final SyntaxElement se, final Object actual, final int flag) {
if (actual == null)
return null;
if (actual instanceof OperationCall) {
- OperationCall op = (OperationCall) actual;
- int start = pres.getStart(op);
+ final OperationCall op = (OperationCall) actual;
+ final int start = pres.getStart(op);
if (se.resource.endsWith(pres.getStringRep(op.getFileName())) && se.start == start)
return actual;
}
@@ -194,26 +194,26 @@ public class ExpressionElementAdapter implements ElementAdapter {
// -------------------------------------------------------------------------
protected ArrayList<NameValuePair> getAllVisibleVariables() {
- ArrayList<NameValuePair> result = new ArrayList<NameValuePair>();
- Map<String, Variable> visibleVariables = context.getVisibleVariables();
+ final ArrayList<NameValuePair> result = new ArrayList<NameValuePair>();
+ final Map<String, Variable> visibleVariables = context.getVisibleVariables();
- for (Entry<String, Variable> nameValuePair : visibleVariables.entrySet()) {
+ for (final Entry<String, Variable> nameValuePair : visibleVariables.entrySet()) {
result.add(new NameValuePair(nameValuePair.getKey(), nameValuePair.getValue().getValue()));
}
return result;
}
- private List<NameValuePair> evaluateFeatureCall(FeatureCall fc) {
+ private List<NameValuePair> evaluateFeatureCall(final FeatureCall fc) {
return getEvalResultProperties(fc.toString(), fc.evaluate(context.cloneWithoutMonitor()));
}
- private List<NameValuePair> getEvalResultProperties(String prefix, Object evaluate) {
- ArrayList<NameValuePair> result = new ArrayList<NameValuePair>();
+ private List<NameValuePair> getEvalResultProperties(final String prefix, final Object evaluate) {
+ final ArrayList<NameValuePair> result = new ArrayList<NameValuePair>();
if (evaluate instanceof Collection) {
result.add(new NameValuePair(prefix, evaluate));
return result;
}
- Type type = context.getType(evaluate);
+ final Type type = context.getType(evaluate);
return getAllPropertiesFor(type, evaluate);
}
@@ -223,17 +223,17 @@ public class ExpressionElementAdapter implements ElementAdapter {
// method here (as in Java)
// Is this a bug or intended that way in AbstractTypeImpl? (TODO: ask Sven
// or Arno)
- private List<NameValuePair> getAllPropertiesFor(Type type, Object element) {
- ArrayList<NameValuePair> result = new ArrayList<NameValuePair>();
+ private List<NameValuePair> getAllPropertiesFor(final Type type, final Object element) {
+ final ArrayList<NameValuePair> result = new ArrayList<NameValuePair>();
- for (Property p : getAllProperties(type)) {
- String name = p.getName();
+ for (final Property p : getAllProperties(type)) {
+ final String name = p.getName();
if (!(name.equals("wait") || name.startsWith("notify"))) {
Object value = null;
try {
value = p.get(element);
}
- catch (Exception e) {
+ catch (final Exception e) {
value = "Error: " + e.getMessage();
}
if (value != null) {
@@ -249,34 +249,34 @@ public class ExpressionElementAdapter implements ElementAdapter {
private final Map<Type, Map<String, Callable>> typeCache = new HashMap<Type, Map<String, Callable>>();
- private Set<? extends Property> getAllProperties(Type type) {
+ private Set<? extends Property> getAllProperties(final Type type) {
return PolymorphicResolver.select(getAllFeatures(type), Property.class);
}
- public final Set<Callable> getAllFeatures(Type type) {
+ public final Set<Callable> getAllFeatures(final Type type) {
Map<String, Callable> allFeatures;
if (typeCache.containsKey(type)) {
allFeatures = typeCache.get(type);
}
else {
allFeatures = new HashMap<String, Callable>();
- Callable[] contribs = ((AbstractTypeImpl) type).getContributedFeatures();
+ final Callable[] contribs = ((AbstractTypeImpl) type).getContributedFeatures();
addIfNotExist(allFeatures, Arrays.asList(contribs));
- for (Type superType : type.getSuperTypes()) {
+ for (final Type superType : type.getSuperTypes()) {
if (superType != null) {
addIfNotExist(allFeatures, getAllFeatures(superType));
}
}
typeCache.put(type, allFeatures);
}
- Set<Callable> result = new HashSet<Callable>();
+ final Set<Callable> result = new HashSet<Callable>();
result.addAll(allFeatures.values());
return result;
}
- private void addIfNotExist(Map<String, Callable> all, Collection<Callable> more) {
- for (Callable one : more) {
- String name = one.getName();
+ private void addIfNotExist(final Map<String, Callable> all, final Collection<Callable> more) {
+ for (final Callable one : more) {
+ final String name = one.getName();
if (!all.containsKey(name)) {
all.put(name, one);
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java
index 00b3fa5..3ad2082 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java
@@ -20,7 +20,8 @@ import org.eclipse.xtend.expression.ExpressionFacade;
import org.eclipse.xtend.expression.Variable;
/**
- * This class is responsible for all presentation topics for expressions in the debugger views.
+ * This class is responsible for all presentation topics for expressions in the
+ * debugger views.
*
* @author Clemens Kadura (zAJKa)
*/
@@ -30,14 +31,14 @@ public class ExpressionModelPresentation {
// -------------------------------------------------------------------------
- public ExpressionModelPresentation(Set<BaseSpecialTreatment> specials) {
+ public ExpressionModelPresentation(final Set<BaseSpecialTreatment> specials) {
this.specials = specials;
}
// -------------------------------------------------------------------------
- public SyntaxElement getStartPresentation(ISyntaxElement se, ExecutionContext context) {
- SyntaxElement to = new SyntaxElement();
+ public SyntaxElement getStartPresentation(final ISyntaxElement se, final ExecutionContext context) {
+ final SyntaxElement to = new SyntaxElement();
to.containerName = getContainerName(se);
to.elementName = se.getNameString(context);
@@ -48,50 +49,51 @@ public class ExpressionModelPresentation {
return to;
}
- public SyntaxElement getEndPresentation(ISyntaxElement se, ExecutionContext context) {
+ public SyntaxElement getEndPresentation(final ISyntaxElement se, final ExecutionContext context) {
return getStartPresentation(se, context);
}
- public String getVariableSimpleRep(Object element, ExecutionContext context) {
+ public String getVariableSimpleRep(final Object element, final ExecutionContext context) {
if (element == null)
return "null";
if (element instanceof String)
return (String) element;
- return (String) new ExpressionFacade(context.cloneWithVariable(new Variable("this", element))).evaluate("metaType.name");
+ return (String) new ExpressionFacade(context.cloneWithVariable(new Variable("this", element)))
+ .evaluate("metaType.name");
}
// -------------------------------------------------------------------------
- public int getStart(ISyntaxElement se) {
+ public int getStart(final ISyntaxElement se) {
if (se instanceof FeatureCall)
return ((FeatureCall) se).getName().getStart();
return se.getStart();
}
- public int getStartingEndPosition(ISyntaxElement se) {
+ public int getStartingEndPosition(final ISyntaxElement se) {
return se.getEnd();
}
// -------------------------------------------------------------------------
- protected String getContainerName(ISyntaxElement se) {
+ protected String getContainerName(final ISyntaxElement se) {
return getTemplateName(se);
}
- protected String getTemplateName(ISyntaxElement se) {
- String fileName = se.getFileName();
+ protected String getTemplateName(final ISyntaxElement se) {
+ final String fileName = se.getFileName();
if (fileName == null)
return "";
return fileName.substring(fileName.lastIndexOf('/') + 1, fileName.length() - 4);
}
- protected String getResource(ISyntaxElement se) {
+ protected String getResource(final ISyntaxElement se) {
if (se.getFileName() == null)
return "";
return se.getFileName();
}
- public String getStringRep(Object element) {
+ public String getStringRep(final Object element) {
if (element == null)
return "null";
return element.toString();
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java
index 6ffddb3..37685f4 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java
@@ -32,6 +32,10 @@ import org.eclipse.xtend.typesystem.Type;
* @author Sven Efftinge (http://www.efftinge.de)
* @author Arno Haase
*/
+/**
+ * @author Patrick Schoenbach - Initial API and implementation
+ * @version $Revision: 1.6 $
+ */
public final class BuiltinMetaModel implements MetaModel {
public static final String OBJECT = "Object";
@@ -298,15 +302,15 @@ public final class BuiltinMetaModel implements MetaModel {
private final Cache<Object, Type> typeCache = new Cache<Object, Type>() {
@Override
- protected Type createNew(Object obj) {
+ protected Type createNew(final Object obj) {
if (obj == null)
return getVoidType();
if (obj instanceof Set)
- return getSetType(getObjectType());
+ return getSetType(null);
if (obj instanceof List)
- return getListType(getObjectType());
+ return getListType(null);
if (obj instanceof Collection)
- return getCollectionType(getObjectType());
+ return getCollectionType(null);
// datatypes
if (stringType.isInstance(obj))
return stringType;
@@ -391,5 +395,4 @@ public final class BuiltinMetaModel implements MetaModel {
// TODO: provide real implementation
return new HashSet<String>();
}
-
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java
index 878e661..78f5c8d 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java
@@ -76,7 +76,7 @@ public class CollectionTypeImpl extends BuiltinBaseType implements Parameterized
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null) {
+ if (target==null) {
LOG.warn("toList called with Null argument. Will return an empty list.");
return new ArrayList<Object>(0);
}
@@ -101,7 +101,7 @@ public class CollectionTypeImpl extends BuiltinBaseType implements Parameterized
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null) {
+ if (target==null) {
LOG.warn("toSet called with Null argument. Will return an empty set.");
return new ArrayList<Object>(0);
}
@@ -157,7 +157,7 @@ public class CollectionTypeImpl extends BuiltinBaseType implements Parameterized
}
public Object get(final Object target) {
- if (target == null) {
+ if (target==null) {
LOG.warn("isEmpty called with Null argument. Will return true.");
return Boolean.TRUE;
}
@@ -259,11 +259,10 @@ public class CollectionTypeImpl extends BuiltinBaseType implements Parameterized
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
final Set r = new HashSet((Collection) target);
- if (params != null && params[0] != null) {
+ if (params!=null && params[0]!=null) {
r.addAll((Collection) params[0]);
- }
- else {
- LOG.warn("Invoking union() with Null as argument. Will return the source collection.");
+ } else {
+ LOG.warn ("Invoking union() with Null as argument. Will return the source collection.");
}
return r;
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java
index 538b590..2e2d8f5 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java
@@ -34,12 +34,12 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
}
public boolean isInstance(final Object o) {
- return o instanceof BigInteger || o instanceof Integer || o instanceof Byte || o instanceof Long
+ return o instanceof Integer || o instanceof BigInteger || o instanceof Byte || o instanceof Long
|| o instanceof Short;
}
public Object newInstance() {
- return new BigInteger("-1");
+ return new Long(-1);
}
@Override
@@ -50,7 +50,7 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
public Object evaluateInternal(final Object target, final Object[] params) {
if (params[0] == null)
return null;
- return toInt(target).add(toInt(params[0]));
+ return new Long(((Number) target).longValue() + ((Number) params[0]).longValue());
}
},
new OperationImpl(this, "-", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
@@ -58,13 +58,13 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
public Object evaluateInternal(final Object target, final Object[] params) {
if (params[0] == null)
return null;
- return toInt(target).subtract(toInt(params[0]));
+ return new Long(((Number) target).longValue() - ((Number) params[0]).longValue());
}
},
new OperationImpl(this, "-", IntegerTypeImpl.this, new Type[] {}) {
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
- return toInt(target).negate();
+ return new Long(((Number) target).longValue() * -1l);
}
},
new OperationImpl(this, "*", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
@@ -73,7 +73,7 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
if (params[0] == null)
return null;
- return toInt(target).multiply(toInt(params[0]));
+ return new Long(((Number) target).longValue() * ((Number) params[0]).longValue());
}
},
new OperationImpl(this, "/", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
@@ -82,38 +82,48 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
if (params[0] == null)
return null;
- return toInt(target).divide(toInt(params[0]));
+ return new Long(((Number) target).longValue() / ((Number) params[0]).longValue());
}
},
- new OperationImpl(this, "==", getTypeSystem().getBooleanType(), new Type[] { IntegerTypeImpl.this }) {
+ new OperationImpl(this, "==", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
if (target == null)
return new Boolean(target == params[0]);
+
try {
- return toInt(target).equals(toInt(params[0]));
+ return toLong(target).equals(toLong(params[0]));
}
catch (Exception exc) {
+ if (target instanceof Number && params[0] instanceof Number)
+ return ((Number) target).doubleValue() == ((Number) params[0]).doubleValue();
+
return false;
}
}
},
- new OperationImpl(this, "!=", getTypeSystem().getBooleanType(), new Type[] { IntegerTypeImpl.this }) {
+ new OperationImpl(this, "!=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
if (target == null)
return params[0] != null;
try {
- return ! toInt(target).equals(toInt(params[0]));
+ return ! toLong(target).equals(toLong(params[0]));
}
catch (Exception exc) {
+ if (target instanceof Number && params[0] instanceof Number)
+ return ((Number) target).doubleValue() != ((Number) params[0]).doubleValue();
+
return true;
}
}
},
- new OperationImpl(this, ">", getTypeSystem().getBooleanType(), new Type[] { IntegerTypeImpl.this }) {
+ new OperationImpl(this, ">", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
if (target == null)
@@ -122,14 +132,15 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
return Boolean.FALSE;
try {
- return toInt(target).compareTo(toInt(params[0])) > 0;
+ return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) > 0;
}
catch (Exception exc) {
- return Boolean.FALSE;
+ return ((Number) target).doubleValue() > ((Number) params[0]).doubleValue();
}
}
},
- new OperationImpl(this, ">=", getTypeSystem().getBooleanType(), new Type[] { IntegerTypeImpl.this }) {
+ new OperationImpl(this, ">=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
if (target == null)
@@ -138,14 +149,15 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
return Boolean.FALSE;
try {
- return toInt(target).compareTo(toInt(params[0])) >= 0;
+ return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) >= 0;
}
catch (Exception exc) {
- return Boolean.FALSE;
+ return ((Number) target).doubleValue() >= ((Number) params[0]).doubleValue();
}
}
},
- new OperationImpl(this, "<", getTypeSystem().getBooleanType(), new Type[] { IntegerTypeImpl.this }) {
+ new OperationImpl(this, "<", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
if (target == null)
@@ -154,14 +166,15 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
return Boolean.FALSE;
try {
- return toInt(target).compareTo(toInt(params[0])) < 0;
+ return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) < 0;
}
catch (Exception exc) {
- return Boolean.FALSE;
+ return ((Number) target).doubleValue() < ((Number) params[0]).doubleValue();
}
}
},
- new OperationImpl(this, "<=", getTypeSystem().getBooleanType(), new Type[] { IntegerTypeImpl.this }) {
+ new OperationImpl(this, "<=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
if (target == null)
@@ -170,30 +183,30 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
return Boolean.FALSE;
try {
- return toInt(target).compareTo(toInt(params[0])) <= 0;
+ return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) <= 0;
}
catch (Exception exc) {
- return Boolean.FALSE;
+ return ((Number) target).doubleValue() <= ((Number) params[0]).doubleValue();
}
}
}, new OperationImpl(this, "upTo", getTypeSystem().getListType(this), new Type[] { this }) {
@Override
public String getDocumentation() {
- return "returns a List of Integers starting with the value of the target expression, up to "
+ return "returns a List of Integers starting with the value of the target expression, up to"
+ "the value of the specified Integer, incremented by one.<br/>"
+ "e.g. '1.upTo(5)' evaluates to {1,2,3,4,5}";
}
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
- final List<BigInteger> result = new ArrayList<BigInteger>();
- BigInteger l1 = toInt(target);
- final BigInteger l2 = toInt(params[0]);
+ final List<Long> result = new ArrayList<Long>();
+ long l1 = toLong(target).longValue();
+ final long l2 = toLong(params[0]).longValue();
- while (l1.compareTo(l2) <= 0) {
- result.add(l1);
- l1 = l1.add(BigInteger.ONE);
+ while (l1 <= l2) {
+ result.add(new Long(l1));
+ l1++;
}
return result;
}
@@ -201,21 +214,21 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
@Override
public String getDocumentation() {
- return "returns a List of Integers starting with the value of the target expression, up to "
+ return "returns a List of Integers starting with the value of the target expression, up to"
+ "the value of the first paramter, incremented by the second parameter.<br/>"
+ "e.g. '1.upTo(10, 2)' evaluates to {1,3,5,7,9}";
}
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
- final List<BigInteger> result = new ArrayList<BigInteger>();
- BigInteger l1 = toInt(target);
- final BigInteger l2 = toInt(params[0]);
- final BigInteger l3 = toInt(params[1]);
+ final List<Long> result = new ArrayList<Long>();
+ long l1 = toLong(target).longValue();
+ final long l2 = toLong(params[0]).longValue();
+ final long l3 = toLong(params[1]).longValue();
- while (l1.compareTo(l2) <= 0) {
- result.add(l1);
- l1 = l1.add(l3);
+ while (l1 <= l2) {
+ result.add(new Long(l1));
+ l1 = l1 + l3;
}
return result;
}
@@ -227,39 +240,36 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
return Collections.singleton(getTypeSystem().getRealType());
}
- protected BigInteger toInt(final Object o) {
- if(o == null)
+ Long toLong(final Object o) {
+ if (o == null)
return null;
- if (o instanceof BigInteger)
- return (BigInteger) o;
-
if (o instanceof Integer)
- return BigInteger.valueOf(((Integer)o).longValue());
+ return new Long(((Integer) o).longValue());
+ else if (o instanceof BigInteger)
+ return new Long(((BigInteger) o).longValue());
else if (o instanceof Byte)
- return BigInteger.valueOf(((Byte)o).longValue());
+ return new Long(((Byte) o).longValue());
else if (o instanceof Long)
- return BigInteger.valueOf((Long)o);
+ return (Long) o;
else if (o instanceof Short)
- return BigInteger.valueOf(((Short) o).longValue());
-
+ return new Long(((Short) o).longValue());
throw new IllegalArgumentException(o.getClass().getName() + " not supported");
}
@Override
public Object convert(final Object src, final Class<?> targetType) {
- final BigInteger value = toInt(src);
-
- if (targetType.isAssignableFrom(BigInteger.class))
- return value;
- else if (targetType.isAssignableFrom(Long.class) || targetType.isAssignableFrom(Long.TYPE))
- return value.longValue();
- else if (targetType.isAssignableFrom(Integer.class) || targetType.isAssignableFrom(Integer.TYPE))
- return value.intValue();
+ final Long l = toLong(src);
+ if (targetType.isAssignableFrom(Integer.class) || targetType.isAssignableFrom(Integer.TYPE))
+ return new Integer(l.intValue());
+ else if (targetType.isAssignableFrom(BigInteger.class))
+ return BigInteger.valueOf(l.longValue());
else if (targetType.isAssignableFrom(Byte.class) || targetType.isAssignableFrom(Byte.TYPE))
- return value.byteValue();
+ return new Byte(l.byteValue());
+ else if (targetType.isAssignableFrom(Long.class) || targetType.isAssignableFrom(Long.TYPE))
+ return src;
else if (targetType.isAssignableFrom(Short.class) || targetType.isAssignableFrom(Short.TYPE))
- return value.shortValue();
+ return new Short(l.shortValue());
return super.convert(src, targetType);
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java
index 2f500be..9c339d5 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java
@@ -142,6 +142,7 @@ public class ObjectTypeImpl extends BuiltinBaseType implements Type {
return new Object();
}
+ @SuppressWarnings("unchecked")
@Override
public Set<Type> getSuperTypes() {
return Collections.EMPTY_SET;
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java
index b363bdc..1f6e9f0 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java
@@ -123,7 +123,7 @@ public class StringTypeImpl extends BuiltinBaseType implements Type {
@Override
public String getDocumentation() {
- return "Returns a new string that is a substring of this string.";
+ return "Tests if this string ends with the specified prefix.";
}
@Override
@@ -292,7 +292,7 @@ public class StringTypeImpl extends BuiltinBaseType implements Type {
@Override
public Object evaluateInternal(final Object target, final Object[] params) {
try {
- return new BigInteger((String) target);
+ return Integer.valueOf((String) target);
} catch (NumberFormatException nfe) {
log.error("'asInteger' on '"+target+"' returned null!");
return null;
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java
index 895b565..0d935d3 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java
@@ -63,8 +63,8 @@ public class JavaMetaModel implements MetaModel, TypeFinder {
private final Cache<Class<?>, Type> cache = new Cache<Class<? extends Object>, Type>() {
@Override
- protected Type createNew(Class<?> clazz) {
- JavaTypeImpl impl = new JavaTypeImpl(JavaMetaModel.this, clazz, getName(clazz), _strategy);
+ protected Type createNew(final Class<?> clazz) {
+ final JavaTypeImpl impl = new JavaTypeImpl(JavaMetaModel.this, clazz, getName(clazz), _strategy);
if (List.class.isAssignableFrom(clazz))
return typeSystem.getListType(typeSystem.getObjectType());
else if (Set.class.isAssignableFrom(clazz))
@@ -83,14 +83,14 @@ public class JavaMetaModel implements MetaModel, TypeFinder {
private final Cache<String, Class<?>> classCache = new Cache<String, Class<? extends Object>>() {
@Override
- protected Class<?> createNew(String typeName) {
+ protected Class<?> createNew(final String typeName) {
// try to load the requested class by its name
final String classname = typeName.replaceAll(SyntaxConstants.NS_DELIM, ".");
try {
- Class<?> loadedClass = ResourceLoaderFactory.createResourceLoader().loadClass(classname);
+ final Class<?> loadedClass = ResourceLoaderFactory.createResourceLoader().loadClass(classname);
return loadedClass == null ? NOCLASS : loadedClass;
}
- catch (Exception e1) {
+ catch (final Exception e1) {
// FIXME: This catch block should really be removed - the
// built-in ResosurceLoader implementation
// never throws an exception, and contributed implementations
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java
index f3d525e..64a31c4 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java
@@ -75,9 +75,6 @@ public class JavaBeansStrategy implements JavaTypeStrategy {
final PropertyDescriptor pd = pdArr[i];
final Method m = pd.getReadMethod() != null ? pd.getReadMethod() : pd.getWriteMethod();
if (m != null && clazz.equals(m.getDeclaringClass())) {
- // remember the getter method for this property; we do not need
- // to add this feature as an operation, too.
- String propName = pd.getName();
if (pd.getReadMethod() != null) {
usedMethods.add(pd.getReadMethod());
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java
index da2ce9b..828f156 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java
@@ -62,7 +62,7 @@ public class ProfileCollector {
*/
public void finish () {
if (_out != null) {
- _out.println ("</m2t-profile>");
+ _out.println ("</oaw-profile>");
_out.flush();
_out = null;
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java
index 92ff0d2..1da7721 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java
@@ -35,6 +35,8 @@ abstract class CharsetRecog_sbcs extends CharsetRecognizer {
static class NGramParser
{
+ @SuppressWarnings("unused")
+ private static final int N_GRAM_SIZE = 3;
private static final int N_GRAM_MASK = 0xFFFFFF;
private int byteIndex = 0;
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java
index 49a88fa..e9be794 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java
@@ -21,19 +21,15 @@ import org.eclipse.xtend.XtendComponent;
public class XtendAdvice extends AbstractWorkflowAdvice {
- private List<String> extensionAdvices = new ArrayList<String>();
+ private final List<String> extensionAdvices = new ArrayList<String>();
- public void addExtensionAdvices(String extensionAdvices) {
- this.extensionAdvices.add( extensionAdvices );
- }
-
- public void addExtensionAdvice(String extensionAdvices) {
- this.extensionAdvices.add( extensionAdvices );
+ public void addExtensionAdvice(final String extensionAdvice) {
+ this.extensionAdvices.add(extensionAdvice);
}
@Override
public void weave(WorkflowComponent c, Issues issues) {
- if ( !(c instanceof XtendComponent) ) {
+ if (!(c instanceof XtendComponent)) {
issues.addError(this, "advice target is not an XtendComponent.");
} else {
XtendComponent xc = (XtendComponent)c;
@@ -42,11 +38,13 @@ public class XtendAdvice extends AbstractWorkflowAdvice {
}
}
}
-
+
+ /**
+ * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage()
+ */
@Override
public String getLogMessage() {
- return "extensionAdvices: "+buildList( extensionAdvices );
+ return "extensionAdvices: " + buildList(extensionAdvices);
}
-
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java
index 4403a85..92e2eb1 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java
@@ -41,8 +41,8 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
private boolean isPrivate = false;
- public AbstractExtension( final Identifier name,
- final Identifier returnType, final List<DeclaredParameter> formalParameters, final boolean cached, final boolean isPrivate) {
+ public AbstractExtension(final Identifier name, final Identifier returnType,
+ final List<DeclaredParameter> formalParameters, final boolean cached, final boolean isPrivate) {
this.name = name;
this.formalParameters = formalParameters;
this.returnType = returnType;
@@ -50,15 +50,19 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
this.isPrivate = isPrivate;
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#getFormalParameters()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#getFormalParameters()
*/
public List<DeclaredParameter> getFormalParameters() {
return formalParameters;
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#getName()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#getName()
*/
public String getName() {
return name.getValue();
@@ -68,8 +72,12 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
return name;
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#getReturnType(org.eclipse.internal.xtend.type.Type[], org.eclipse.internal.xtend.expression.ExecutionContext, java.util.Set)
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.xtend.ast.Extension#getReturnType(org.
+ * openarchitectureware.type.Type[],
+ * org.eclipse.expression.ExecutionContext, java.util.Set)
*/
public final Type getReturnType(final Type[] parameters, ExecutionContext ctx, final Set<AnalysationIssue> issues) {
ctx = ctx.cloneWithResource(getExtensionFile());
@@ -78,10 +86,18 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
protected abstract Type internalGetReturnType(Type[] parameters, ExecutionContext ctx, Set<AnalysationIssue> issues);
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#analyze(org.eclipse.internal.xtend.expression.ExecutionContext, java.util.Set)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.xtend.ast.Extension#analyze(org.eclipse
+ * .expression.ExecutionContext, java.util.Set)
*/
public final void analyze(ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ try {
+ if (ctx.getCallback() != null) {
+ ctx.getCallback().pre(this, ctx);
+ }
final List<DeclaredParameter> params = getFormalParameters();
final Set<String> usedNames = new HashSet<String>();
for (final Iterator<DeclaredParameter> iter = params.iterator(); iter.hasNext();) {
@@ -106,19 +122,36 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
}
try {
analyzeInternal(ctx, issues);
- } catch (RuntimeException ex) {
+ }
+ catch (RuntimeException ex) {
ctx.handleRuntimeException(ex, this, null);
}
}
+ finally {
+ if (ctx.getCallback() != null) {
+ ctx.getCallback().post(null);
+ }
+ }
+ }
- protected abstract void analyzeInternal(ExecutionContext ctx, Set<AnalysationIssue> issues);
+ protected void analyzeInternal(ExecutionContext ctx, Set<AnalysationIssue> issues) {
+ checkForAmbiguousDefinitions(ctx, issues);
+ }
private final Map<List<Object>, Object> cache = new HashMap<List<Object>, Object>();
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#evaluate(java.lang.Object[], org.eclipse.internal.xtend.expression.ExecutionContext)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.xtend.ast.Extension#evaluate(java.lang.Object[],
+ * org.eclipse.expression.ExecutionContext)
*/
public Object evaluate(final Object[] parameters, ExecutionContext ctx) {
try {
+ if (ctx.getCallback() != null) {
+ ctx.getCallback().pre(this, ctx);
+ }
if (cached) {
final List<Object> l = Arrays.asList(parameters);
if (cache.containsKey(l))
@@ -132,9 +165,15 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
cache.put(Arrays.asList(parameters), result);
}
return result;
- } catch (RuntimeException ex) {
+ }
+ catch (RuntimeException ex) {
ctx.handleRuntimeException(ex, this, null);
}
+ finally {
+ if (ctx.getCallback() != null) {
+ ctx.getCallback().post(null);
+ }
+ }
return null;
}
@@ -142,8 +181,10 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
file = f;
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#getExtensionFile()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#getExtensionFile()
*/
public ExtensionFile getExtensionFile() {
return file;
@@ -151,8 +192,10 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
protected abstract Object evaluateInternal(Object[] parameters, ExecutionContext ctx);
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#getParameterNames()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#getParameterNames()
*/
public List<String> getParameterNames() {
final List<String> names = new ArrayList<String>();
@@ -162,8 +205,12 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
return names;
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#init(org.eclipse.internal.xtend.expression.ExecutionContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.xtend.ast.Extension#init(org.eclipse
+ * .expression.ExecutionContext)
*/
public void init(final ExecutionContext ctx) {
if (parameterTypes == null) {
@@ -177,15 +224,18 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
+ "'. Did you forget to configure the corresponding metamodel?", this, ctx);
parameterTypes.add(t);
}
- } catch (final RuntimeException e) {
+ }
+ catch (final RuntimeException e) {
parameterTypes = null;
throw e;
}
}
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#getReturnType()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#getReturnType()
*/
public Type getReturnType() {
throw new UnsupportedOperationException();
@@ -195,15 +245,20 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
protected Identifier returnType;
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#getParameterTypes()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#getParameterTypes()
*/
public List<Type> getParameterTypes() {
return parameterTypes;
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#getReturnTypeIdentifier()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.xtend.ast.Extension#getReturnTypeIdentifier()
*/
public Identifier getReturnTypeIdentifier() {
return returnType;
@@ -211,13 +266,16 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
private String _stringRepresentation = null;
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#toString()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#toString()
*/
@Override
public String toString() {
if (_stringRepresentation == null) {
- _stringRepresentation = (returnType != null ? returnType.getValue() + " " : "") + getName() + "(" + paramsToString() + ")";
+ _stringRepresentation = (returnType != null ? returnType.getValue() + " " : "") + getName() + "("
+ + paramsToString() + ")";
}
return _stringRepresentation;
@@ -225,12 +283,15 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
private String _outlineRepresentation = null;
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#toOutlineString()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#toOutlineString()
*/
public String toOutlineString() {
if (_outlineRepresentation == null) {
- _outlineRepresentation = getName() + "(" + paramsToOutlineString() + ")" + (returnType != null ? ": "+returnType.getValue() : "") ;
+ _outlineRepresentation = getName() + "(" + paramsToOutlineString() + ")"
+ + (returnType != null ? ": " + returnType.getValue() : "");
}
return _outlineRepresentation;
}
@@ -251,7 +312,7 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
final StringBuffer buff = new StringBuffer();
for (final Iterator<DeclaredParameter> iter = getFormalParameters().iterator(); iter.hasNext();) {
final DeclaredParameter element = iter.next();
- buff.append(element.getName());
+ buff.append(element.getType());
if (iter.hasNext()) {
buff.append(", ");
}
@@ -259,22 +320,26 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
return buff.toString();
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#isPrivate()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#isPrivate()
*/
public boolean isPrivate() {
return isPrivate;
}
- /* (non-Javadoc)
- * @see org.eclipse.internal.xtend.xtend.ast.Extension#isCached()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xtend.ast.Extension#isCached()
*/
- public boolean isCached () {
+ public boolean isCached() {
return cached;
}
public String getQualifiedName() {
- return getExtensionFile().getFullyQualifiedName()+"::"+getName();
+ return getExtensionFile().getFullyQualifiedName() + "::" + getName();
}
@Override
@@ -298,16 +363,31 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi
if (getName() == null) {
if (other.getName() != null)
return false;
- } else if (!getName().equals(other.getName()))
+ }
+ else if (!getName().equals(other.getName()))
return false;
if (parameterTypes == null) {
if (other.parameterTypes != null)
return false;
- } else if (!parameterTypes.equals(other.parameterTypes))
+ }
+ else if (!parameterTypes.equals(other.parameterTypes))
return false;
return true;
}
-
+ protected void checkForAmbiguousDefinitions(final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ String name = getName();
+ for (Extension ext : ctx.getAllExtensions()) {
+ String otherName = ext.getName();
+ if (name.equals(otherName) && (!getFileName().equals(ext.getFileName()) || getLine() != ext.getLine())) {
+ if (getParameterTypes().equals(ext.getParameterTypes())) {
+ issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Ambiguous definition: "
+ + toOutlineString(), this, true));
+ issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Ambiguous definition: "
+ + ext.toOutlineString(), (AbstractExtension) ext, true));
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java
index 6fa9137..534fd8d 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java
@@ -52,29 +52,20 @@ public class Check extends SyntaxElement {
}
public final void analyze(ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ try {
+ if (ctx.getCallback() != null)
+ ctx.getCallback().pre(this,ctx);
final Type toCheck = ctx.getTypeForName(type.getValue());
if (toCheck == null) {
- issues
- .add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Type not found: " + type.getValue(),
- this));
- return;
- }
- if (feature != null) {
- Property property = toCheck.getProperty(feature.getValue());
- if (property == null) {
- issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, "Couldn't find property '"
- + feature.getValue() + "' for type '" + type.getValue() + "'", this));
+ issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Type not found: " + type.getValue(), this));
return;
}
- }
-
ctx = ctx.cloneWithVariable(new Variable(ExecutionContext.IMPLICIT_VARIABLE, toCheck));
if (guard != null) {
Type guardType = null;
try {
guardType = guard.analyze(ctx, issues);
- }
- catch (RuntimeException ex) {
+ } catch (RuntimeException ex) {
ctx.handleRuntimeException(ex, this, null);
}
if (guardType == null)
@@ -88,8 +79,7 @@ public class Check extends SyntaxElement {
Type constraintType = null;
try {
constraintType = constraint.analyze(ctx, issues);
- }
- catch (RuntimeException ex) {
+ } catch (RuntimeException ex) {
ctx.handleRuntimeException(ex, this, null);
}
if (constraintType == null)
@@ -101,10 +91,13 @@ public class Check extends SyntaxElement {
try {
msg.analyze(ctx, issues);
- }
- catch (RuntimeException ex) {
+ } catch (RuntimeException ex) {
ctx.handleRuntimeException(ex, this, null);
}
+ } finally {
+ if (ctx.getCallback() != null)
+ ctx.getCallback().post(null);
+ }
}
/**
@@ -120,13 +113,16 @@ public class Check extends SyntaxElement {
* <code>true</code>: If this check is not evaluated for any
* elements an warning will be added to <tt>issues</tt>
*/
- public void validate(ExecutionContext ctx, final Collection<?> colToCheck, final Issues issues,
- boolean warnIfNothingChecked) {
+ public void validate(ExecutionContext ctx, final Collection<?> colToCheck, final Issues issues, boolean warnIfNothingChecked) {
+ try {
+ if (ctx.getCallback() != null)
+ ctx.getCallback().pre(this, ctx);
// get the type for which the check should be evaluated
final Type typeToCheck = ctx.getTypeForName(type.getValue());
// The type is unknown => exit with exception
if (typeToCheck == null)
throw new EvaluationException("Type not found : " + type.getValue(), this, ctx);
+
// will be set to true when check is evaluated for any object
boolean someObjectFound = false;
for (final Iterator<?> iter = colToCheck.iterator(); iter.hasNext();) {
@@ -137,48 +133,47 @@ public class Check extends SyntaxElement {
try {
// create a new execution context for evaluation
ctx = ctx.cloneWithVariable(new Variable(ExecutionContext.IMPLICIT_VARIABLE, o));
- // check the guard condition; do not evaluate if guard is
+ // check the guard condition; do not evaluate if guard
+ // is
// evaluated to false
if (process(ctx)) {
- final Object result = constraint.evaluate(ctx);
+ Object result = null;
+ try {
+ result = constraint.evaluate(ctx);
+ } catch (RuntimeException e) {
+ final String msg = e.getMessage();
+ issues.addError(msg, e);
+ }
// check result must be of Boolean type
if (result != null && !(result instanceof Boolean))
- throw new EvaluationException("Boolean expected! ( was " + result.getClass().getName()
- + ")", this, ctx);
+ throw new EvaluationException("Boolean expected! ( was " + result.getClass().getName() + ")",
+ this, ctx);
// add issue if result of the check is false
final Boolean r = (Boolean) result;
if (Boolean.FALSE.equals(r)) {
// get the error message
- final Object msgResult = msg.evaluate(ctx);
+ Object msgResult = null;
+ try {
+ msgResult = msg.evaluate(ctx);
+ } catch (RuntimeException e) {
+ final String msg = e.getMessage();
+ issues.addError(msg, e);
+ }
+
String stringResult = "Message evaluation returned null";
if (msgResult != null) {
stringResult = msgResult.toString();
}
- // Involved property e.g. test::Bean#property
- String propertyName = null;
- if (feature != null) {
- String featureValue = feature.getValue();
- Property property = typeToCheck.getProperty(featureValue);
- if (property == null) {
- throw new EvaluationException("Property " + featureValue + " for Type "
- + typeToCheck + " not found!", this, ctx);
- }
- else {
- propertyName = property.getName();
- }
- }
if (errorSeverity) {
- issues.addError(null, stringResult, o, propertyName, null, Collections.emptyList());
- }
- else {
- issues.addWarning(null, stringResult, o, propertyName, null, Collections.emptyList());
+ issues.addError(stringResult, o);
+ } else {
+ issues.addWarning(stringResult, o);
}
}
}
- }
- catch (final NullPointerException npe) {
+ } catch (final NullPointerException npe) {
final Object msgResult = msg.evaluate(ctx);
String stringResult = "Message evaluation returned null";
if (msgResult != null) {
@@ -186,16 +181,19 @@ public class Check extends SyntaxElement {
}
if (errorSeverity) {
issues.addError(stringResult + " (NPE in constraint evaluation)", o);
- }
- else {
+ } else {
issues.addWarning(stringResult + " (NPE in constraint evaluation)", o);
}
}
}
}
if (warnIfNothingChecked && (!someObjectFound)) {
- issues.addWarning("The constraint did not match any model elements. Context: " + type.toString()
- + ", message: " + msg);
+ issues.addWarning("The constraint did not match any model elements. Context: " + type.toString() + ", message: "
+ + msg);
+ }
+ } finally {
+ if (ctx.getCallback() != null)
+ ctx.getCallback().post(null);
}
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java
index f17cbd1..70dbf10 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java
@@ -27,73 +27,74 @@ import org.eclipse.xtend.typesystem.Type;
public class CreateExtensionStatement extends AbstractExtension {
- private Expression expression;
+ private final Expression expression;
- private String returnVarName;
+ private final String returnVarName;
- public CreateExtensionStatement(final Identifier name,
- final Identifier returnType, final Identifier rtName, final List<DeclaredParameter> params, final Expression expr,
- final boolean isPrivate) {
- super(name, returnType, params, true, isPrivate);
- expression = expr;
- returnVarName = rtName!=null ? rtName.getValue() : "this";
- }
+ public CreateExtensionStatement(final Identifier name, final Identifier returnType, final Identifier rtName,
+ final List<DeclaredParameter> params, final Expression expr, final boolean isPrivate) {
+ super(name, returnType, params, true, isPrivate);
+ expression = expr;
+ returnVarName = rtName != null ? rtName.getValue() : "this";
+ }
+
+ public String getReturnVarName() {
+ return returnVarName;
+ }
public Expression getExpression() {
return expression;
}
- @Override
- protected Type internalGetReturnType(final Type[] parameters, final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
- return ctx.getTypeForName(getReturnTypeIdentifier().getValue());
- }
+ @Override
+ protected Type internalGetReturnType(final Type[] parameters, final ExecutionContext ctx,
+ final Set<AnalysationIssue> issues) {
+ return ctx.getTypeForName(getReturnTypeIdentifier().getValue());
+ }
- @Override
- public void analyzeInternal(ExecutionContext ctx, final Set<AnalysationIssue> issues) {
- final Type t = ctx.getTypeForName(returnType.getValue());
- if (t == null) {
- issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Couldn't resolve type " + returnType
- + "!", returnType));
- return;
- }
- if (t.isAbstract())
- issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Cannot create instance of " + returnType
- + " because it is declared abstract!", returnType));
- ctx = ctx.cloneWithVariable(new Variable(returnVarName, t));
- expression.analyze(ctx, issues);
- }
+ @Override
+ public void analyzeInternal(ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ final Type t = ctx.getTypeForName(returnType.getValue());
+ if (t == null) {
+ issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Couldn't resolve type " + returnType
+ + "!", returnType));
+ return;
+ }
+ if (t.isAbstract()) {
+ issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Cannot create instance of "
+ + returnType + " because it is declared abstract!", returnType));
+ }
+ ctx = ctx.cloneWithVariable(new Variable(returnVarName, t));
+ expression.analyze(ctx, issues);
+ }
- private final Map<List<Object>, Object> cache = new HashMap<List<Object>, Object>();
+ private final Map<List<Object>, Object> cache = new HashMap<List<Object>, Object>();
- @Override
- public Object evaluate(final Object[] parameters, ExecutionContext ctx) {
- final List<Object> l = Arrays.asList(parameters);
- if (cache.containsKey(l))
- return cache.get(l);
- ctx = ctx.cloneWithResource(getExtensionFile());
- final Type t = ctx.getTypeForName(returnType.getValue());
- if (t == null)
- throw new EvaluationException("Couldn't resolve type " + returnType, returnType, ctx);
- if (t.isAbstract())
- throw new EvaluationException("Cannot create instance of abstract class " + returnType, returnType, ctx);
- final Object inst = t.newInstance();
- cache.put(l, inst);
- ctx = ctx.cloneWithVariable(new Variable(returnVarName, inst));
- for (int i = 0; i < parameters.length; i++) {
- final Object object = parameters[i];
- ctx = ctx.cloneWithVariable(new Variable(getParameterNames().get(i), object));
- }
- expression.evaluate(ctx);
- return inst;
- }
+ @Override
+ public Object evaluate(final Object[] parameters, ExecutionContext ctx) {
+ final List<Object> l = Arrays.asList(parameters);
+ if (cache.containsKey(l))
+ return cache.get(l);
+ ctx = ctx.cloneWithResource(getExtensionFile());
+ final Type t = ctx.getTypeForName(returnType.getValue());
+ if (t == null)
+ throw new EvaluationException("Couldn't resolve type " + returnType, returnType, ctx);
+ if (t.isAbstract())
+ throw new EvaluationException("Cannot create instance of abstract class " + returnType, returnType, ctx);
+ final Object inst = t.newInstance();
+ cache.put(l, inst);
+ ctx = ctx.cloneWithVariable(new Variable(returnVarName, inst));
+ for (int i = 0; i < parameters.length; i++) {
+ final Object object = parameters[i];
+ ctx = ctx.cloneWithVariable(new Variable(getParameterNames().get(i), object));
+ }
+ expression.evaluate(ctx);
+ return inst;
+ }
- @Override
- protected Object evaluateInternal(final Object[] parameters, final ExecutionContext ctx) {
- throw new UnsupportedOperationException();
- }
-
- public String getReturnVarName() {
- return returnVarName;
- }
+ @Override
+ protected Object evaluateInternal(final Object[] parameters, final ExecutionContext ctx) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java
index 080c297..e41dcf4 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java
@@ -26,12 +26,10 @@ import org.eclipse.xtend.typesystem.Type;
public class ExpressionExtensionStatement extends AbstractExtension {
- private Expression expression;
+ private final Expression expression;
- public ExpressionExtensionStatement(final Identifier name,
- final Identifier returnType,
- final List<DeclaredParameter> formalParameters,
- final Expression expression, final boolean cached,
+ public ExpressionExtensionStatement(final Identifier name, final Identifier returnType,
+ final List<DeclaredParameter> formalParameters, final Expression expression, final boolean cached,
final boolean isPrivate) {
super(name, returnType, formalParameters, cached, isPrivate);
this.expression = expression;
@@ -44,13 +42,11 @@ public class ExpressionExtensionStatement extends AbstractExtension {
private final Stack<List<Type>> analyzations = new Stack<List<Type>>();
@Override
- public Object evaluateInternal(final Object[] parameters,
- final ExecutionContext ctx) {
+ public Object evaluateInternal(final Object[] parameters, final ExecutionContext ctx) {
return evaluateInternal2(parameters, ctx);
}
- protected Object evaluateInternal2(final Object[] parameters,
- ExecutionContext ctx) {
+ protected Object evaluateInternal2(final Object[] parameters, ExecutionContext ctx) {
ctx = ctx.cloneWithoutVariables();
ctx = ctx.cloneWithResource(file);
final List<String> paramNames = getParameterNames();
@@ -62,43 +58,40 @@ public class ExpressionExtensionStatement extends AbstractExtension {
}
@Override
- public void analyzeInternal(final ExecutionContext ctx,
- final Set<AnalysationIssue> issues) {
- if (expression != null)
+ public void analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ if (expression != null) {
expression.analyze(ctx, issues);
+ }
}
@Override
- protected Type internalGetReturnType(final Type[] parameters,
- final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ protected Type internalGetReturnType(final Type[] parameters, final ExecutionContext ctx,
+ final Set<AnalysationIssue> issues) {
if (getReturnTypeIdentifier() != null)
return ctx.getTypeForName(getReturnTypeIdentifier().getValue());
- if (parameters == null
- || parameters.length != getParameterNames().size())
+ if (parameters == null || parameters.length != getParameterNames().size())
return null;
final List<Type> params = Arrays.asList(parameters);
if (!analyzations.contains(params)) {
analyzations.push(params);
try {
return analyzeInternal(parameters, ctx, issues);
- } finally {
+ }
+ finally {
analyzations.pop();
}
- } else {
+ }
+ else {
if (returnType == null) {
- issues
- .add(new AnalysationIssue(
- AnalysationIssue.INTERNAL_ERROR,
- "Recursive extensions need to have a return type specified!",
- this));
+ issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR,
+ "Recursive extensions need to have a return type specified!", this));
return null;
}
return ctx.getTypeForName(returnType.getValue());
}
}
- protected Type analyzeInternal(final Type[] parameters,
- ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ protected Type analyzeInternal(final Type[] parameters, ExecutionContext ctx, final Set<AnalysationIssue> issues) {
ctx = ctx.cloneWithoutVariables();
ctx = ctx.cloneWithResource(file);
final List<String> paramNames = getParameterNames();
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java
index 30dc5d8..0770e5a 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java
@@ -40,9 +40,9 @@ public class JavaExtensionStatement extends AbstractExtension {
protected List<Identifier> javaParamTypes;
- public JavaExtensionStatement(final Identifier name,
- final List<DeclaredParameter> formalParameters, final Identifier returnType, final Identifier javaType,
- final Identifier javaMethod, final List<Identifier> javaParamTypes, final boolean cached, final boolean isPrivate) {
+ public JavaExtensionStatement(final Identifier name, final List<DeclaredParameter> formalParameters,
+ final Identifier returnType, final Identifier javaType, final Identifier javaMethod,
+ final List<Identifier> javaParamTypes, final boolean cached, final boolean isPrivate) {
super(name, returnType, formalParameters, cached, isPrivate);
this.javaType = javaType;
this.javaMethod = javaMethod;
@@ -53,7 +53,7 @@ public class JavaExtensionStatement extends AbstractExtension {
return javaType;
}
- public String getJavaMethodName () {
+ public String getJavaMethodName() {
return javaMethod.getValue();
}
@@ -70,20 +70,13 @@ public class JavaExtensionStatement extends AbstractExtension {
}
throw new EvaluationException(javaMethodToString() + " not found, problems were: \n" + b, this, ctx);
}
- convertTypesToMethodSignature(ctx, method, parameters);
return method.invoke(null, parameters);
- } catch (final InvocationTargetException ite) {
- throw new RuntimeException(ite.getCause());
- } catch (final Exception e) {
- throw new EvaluationException(e, this, ctx);
}
+ catch (final InvocationTargetException ite) {
+ throw new RuntimeException(ite.getCause());
}
-
- private void convertTypesToMethodSignature(ExecutionContext ctx, Method method, Object[] parameters) {
- Class<?>[] paramTypes = method.getParameterTypes();
- for(int i = 0; i < parameters.length; i++) {
- Object param = parameters[i];
- parameters[i] = ctx.getType(param).convert(param, paramTypes[i]);
+ catch (final Exception e) {
+ throw new EvaluationException(e, this, ctx);
}
}
@@ -99,12 +92,14 @@ public class JavaExtensionStatement extends AbstractExtension {
return javaType + "." + javaMethod + "(" + buff + ")";
}
+ @SuppressWarnings("unchecked")
public Method getJavaMethod(final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
try {
Class clazz = null;
clazz = ResourceLoaderFactory.createResourceLoader().loadClass(javaType.getValue());
if (clazz == null) {
- issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Couldn't find Java type "+javaType.getValue(), javaType));
+ issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Couldn't find Java type "
+ + javaType.getValue(), javaType));
return null;
}
final Class[] paramTypes = new Class[javaParamTypes.size()];
@@ -113,20 +108,24 @@ public class JavaExtensionStatement extends AbstractExtension {
paramTypes[i] = ResourceLoaderFactory.createResourceLoader().loadClass(javaParamType.getValue());
if (paramTypes[i] == null) {
- issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, javaParamType.getValue(), javaParamType));
+ issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, javaParamType.getValue(),
+ javaParamType));
return null;
}
}
final Method m = clazz.getMethod(javaMethod.getValue(), paramTypes);
if (!Modifier.isStatic(m.getModifiers())) {
- issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, javaMethod.getValue() + " must be static!", javaMethod));
+ issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, javaMethod.getValue()
+ + " must be static!", javaMethod));
}
if (!Modifier.isPublic(m.getModifiers())) {
- issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, javaMethod.getValue() + " must be public!", javaMethod));
+ issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, javaMethod.getValue()
+ + " must be public!", javaMethod));
}
return m;
- } catch (final NoSuchMethodException e) {
+ }
+ catch (final NoSuchMethodException e) {
issues.add(new AnalysationIssue(AnalysationIssue.FEATURE_NOT_FOUND, javaMethod.getValue(), javaMethod));
}
return null;
@@ -134,18 +133,23 @@ public class JavaExtensionStatement extends AbstractExtension {
@Override
public void analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ super.analyzeInternal(ctx, issues);
if (returnType == null) {
- issues.add(new AnalysationIssue(AnalysationIssue.SYNTAX_ERROR, "A return type must be specified for java extensions!", this));
+ issues.add(new AnalysationIssue(AnalysationIssue.SYNTAX_ERROR,
+ "A return type must be specified for java extensions!", this));
}
getJavaMethod(ctx, issues);
}
@Override
- protected Type internalGetReturnType(final Type[] parameters, final ExecutionContext ctx, final Set<AnalysationIssue> issues) {
+ protected Type internalGetReturnType(final Type[] parameters, final ExecutionContext ctx,
+ final Set<AnalysationIssue> issues) {
if (returnType == null) {
- issues.add(new AnalysationIssue(AnalysationIssue.SYNTAX_ERROR, "A return type must be specified for java extensions!", this));
+ issues.add(new AnalysationIssue(AnalysationIssue.SYNTAX_ERROR,
+ "A return type must be specified for java extensions!", this));
return null;
- } else
+ }
+ else
return ctx.getTypeForName(returnType.getValue());
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java
index e235e4f..046846d 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java
@@ -12,4 +12,4 @@ package org.eclipse.internal.xtend.xtend.parser;
public interface ErrorHandler {
public void handleError(XtendError e);
-}
+}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java
index 7249e59..02a4f2f 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java
@@ -38,45 +38,46 @@ public class ExtensionFactory extends ExpressionFactory {
public ExtensionFile createExtensionFile(final List<ImportStatement> nsimports,
final List<ImportStatement> extimports, final List<Extension> extensions, final List<Around> arounds,
- List<Check> checks) {
+ final List<Check> checks) {
return (ExtensionFile) handle(new ExtensionFile(nonNull(nsimports), nonNull(extimports), nonNull(extensions),
nonNull(arounds), nonNull(checks)));
}
public ImportStatement createNsImport(final Identifier t) {
- return (ImportStatement) handle(new ImportStatement(t, false));
+ return handle(new ImportStatement(t, false));
}
public ImportStatement createExtensionFileImport(final Identifier t, final Identifier exported) {
- return (ImportStatement) handle(new ImportStatement(t, exported != null));
+ return handle(new ImportStatement(t, exported != null));
}
public JavaExtensionStatement createJavaExtension(final Identifier name, final Identifier type,
final List<DeclaredParameter> params, final Identifier typeName, final Identifier methodName,
final List<Identifier> javaParamTypes, final Identifier cached, final Identifier priv) {
- return (JavaExtensionStatement) handle(new JavaExtensionStatement(name, nonNull(params), type, typeName,
- methodName, nonNull(javaParamTypes), cached != null, priv != null));
+ return handle(new JavaExtensionStatement(name, nonNull(params), type, typeName, methodName,
+ nonNull(javaParamTypes), cached != null, priv != null));
}
public ExpressionExtensionStatement createExpressionExtension(final Identifier name, final Identifier returnType,
final List<DeclaredParameter> params, final Expression expr, final Identifier cached, final Identifier priv) {
- return (ExpressionExtensionStatement) handle(new ExpressionExtensionStatement(name, returnType,
- nonNull(params), expr, cached != null, priv != null));
+ return handle(new ExpressionExtensionStatement(name, returnType, nonNull(params), expr, cached != null,
+ priv != null));
}
public Extension createCreateExtension(final Identifier create, final Identifier returnType, final Identifier rtn,
final Identifier name, final List<DeclaredParameter> params, final Expression expr, final Identifier priv) {
- return (CreateExtensionStatement) handle(new CreateExtensionStatement(name, returnType, rtn != null ? rtn
- : null, nonNull(params), expr, priv != null));
+ return handle(new CreateExtensionStatement(name, returnType, rtn != null ? rtn : null, nonNull(params), expr,
+ priv != null));
}
- public Around createAround(Identifier pointcut, List<DeclaredParameter> p, boolean wildparams, Expression expr) {
- return (Around) handle(new Around(pointcut, nonNull(p), wildparams, expr));
+ public Around createAround(final Identifier pointcut, final List<DeclaredParameter> p, final boolean wildparams,
+ final Expression expr) {
+ return handle(new Around(pointcut, nonNull(p), wildparams, expr));
}
- public Check createCheck(Identifier t, Identifier f, Expression guard, boolean errorSev, Expression msg,
- Expression expr) {
- return (Check) handle(new Check(t, f, guard, errorSev, msg, expr));
+ public Check createCheck(final Identifier t, final Identifier f, final Expression guard, final boolean errorSev,
+ final Expression msg, final Expression expr) {
+ return handle(new Check(t, f, guard, errorSev, msg, expr));
}
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java
index e970850..41abfd4 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java
@@ -10,34 +10,36 @@
*******************************************************************************/
package org.eclipse.internal.xtend.xtend.parser;
-
public class SyntaxError implements XtendError {
- private int start,end, line;
- private String message;
-
-
- public SyntaxError(int start, int end, int line, String message) {
+ private final int start, end, line;
+ private final String message;
+
+ public SyntaxError(final int start, final int end, final int line, final String message) {
super();
this.start = start;
this.end = end;
this.line = line;
this.message = message;
}
+
public int getEnd() {
return end;
}
+
public int getLine() {
return line;
}
+
public String getMessage() {
return message;
}
+
public int getStart() {
return start;
}
-
+
@Override
public String toString() {
- return getMessage()+" on line "+line;
+ return getMessage() + " on line " + line;
}
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java
index afdd406..dd2fe80 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java
@@ -57,6 +57,7 @@ public class AdviceContextType extends AbstractTypeImpl {
},
new OperationImpl(AdviceContextType.this,"proceed",getTypeSystem().getObjectType(),getTypeSystem().getListType(getTypeSystem().getObjectType())) {
+ @SuppressWarnings("unchecked")
@Override
protected Object evaluateInternal(Object target, Object[] params) {
return ((AdviceContext)target).proceed(((List<Object>)params[0]).toArray());
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java
index ea21a82..407378b 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java
@@ -29,14 +29,25 @@ public class XtendMetaModel implements MetaModel {
types.put(t.getName(), t);
}
+ /**
+ * @see org.eclipse.type.MetaModel#getKnownTypes()
+ */
public Set<? extends Type> getKnownTypes() {
return new HashSet<Type>(types.values());
}
+ /**
+ * Returns the name of the metamodel.
+ *
+ * @return name of metamodel
+ */
public String getName() {
return "xtend";
}
+ /**
+ * @see org.eclipse.type.MetaModel#getType(java.lang.Object)
+ */
public Type getType(Object obj) {
Type bestMatch = null;
for (Type aType : getKnownTypes()) {
@@ -49,22 +60,33 @@ public class XtendMetaModel implements MetaModel {
return bestMatch;
}
+ /**
+ * @see org.eclipse.type.MetaModel#getTypeForName(java.lang.String)
+ */
public Type getTypeForName(String typeName) {
return types.get(typeName);
}
private TypeSystem ts = null;
+ /**
+ * @see org.eclipse.type.MetaModel#getTypeSystem()
+ */
public TypeSystem getTypeSystem() {
return ts;
}
+ /**
+ * @see org.eclipse.type.MetaModel#setTypeSystem(org.eclipse.expression.TypeSystem)
+ */
public void setTypeSystem(TypeSystem typeSystem) {
ts = typeSystem;
}
+ /**
+ * @see org.eclipse.type.MetaModel#getNamespaces()
+ */
public Set<String> getNamespaces() {
return new HashSet<String>();
}
-
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java
index c08e0b0..8be3acf 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java
@@ -45,11 +45,9 @@ public class XtendComponent extends AbstractExpressionsUsingWorkflowComponent {
private String invokeExpression;
private String expression = null;
-
private String collectProfileSummary = null;
private String verboseProfileFilename = null;
-
private String outputSlot = WorkflowContext.DEFAULT_SLOT;
/**
@@ -58,7 +56,6 @@ public class XtendComponent extends AbstractExpressionsUsingWorkflowComponent {
* @param extensionAdvice
* the advice
*/
- @Override
public void addExtensionAdvice(final String extensionAdvice) {
if (!extensionAdvices.contains(extensionAdvice)) {
extensionAdvices.add(extensionAdvice);
@@ -66,7 +63,7 @@ public class XtendComponent extends AbstractExpressionsUsingWorkflowComponent {
}
/**
- * @see org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent#checkConfigurationInternal(org.eclipse.emf.mwe.core.issues.Issues)
+ * @see org.eclipse.expression.AbstractExpressionsUsingWorkflowComponent#checkConfigurationInternal(org.eclipse.workflow.issues.Issues)
*/
@Override
public void checkConfigurationInternal(final Issues issues) {
@@ -109,7 +106,7 @@ public class XtendComponent extends AbstractExpressionsUsingWorkflowComponent {
}
/**
- * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage()
+ * @see org.eclipse.workflow.lib.AbstractWorkflowComponent#getLogMessage()
*/
@Override
public String getLogMessage() {
@@ -117,9 +114,9 @@ public class XtendComponent extends AbstractExpressionsUsingWorkflowComponent {
}
/**
- * @see org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent#invokeInternal2(org.eclipse.emf.mwe.core.WorkflowContext,
- * org.eclipse.emf.mwe.core.monitor.ProgressMonitor,
- * org.eclipse.emf.mwe.core.issues.Issues)
+ * @see org.eclipse.expression.AbstractExpressionsUsingWorkflowComponent#invokeInternal2(org.eclipse.workflow.WorkflowContext,
+ * org.eclipse.workflow.monitor.ProgressMonitor,
+ * org.eclipse.workflow.issues.Issues)
*/
@Override
public void invokeInternal2(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) {
@@ -253,7 +250,6 @@ public class XtendComponent extends AbstractExpressionsUsingWorkflowComponent {
verboseProfileFilename = fileName;
}
- @Override
public String getComponentName() {
return COMPONENT_NAME;
}
@@ -263,5 +259,4 @@ public class XtendComponent extends AbstractExpressionsUsingWorkflowComponent {
extensionFile.replace("::", "/") + ".ext");
return in;
}
-
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java
index 3d36a8d..5e659fa 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java
@@ -84,26 +84,6 @@ public class XtendFacade {
return extension.evaluate(params, ctx);
}
- public Object call(final String ext, List<?> params) {
- Object[] paramsArray = new Object[params.size()];
- paramsArray = params.toArray(paramsArray);
- final Extension extension = ctx.getExtension(ext, paramsArray);
- if (extension == null)
- throw new IllegalArgumentException("Couldn't find extension " + ext);
- return extension.evaluate(paramsArray, ctx);
- }
-
- public boolean hasExtension(final String ext, Object[] paramsArray) {
- final Extension extension = ctx.getExtension(ext, paramsArray);
- return extension != null;
- }
-
- public boolean hasExtension(final String ext, List<?> params) {
- Object[] paramsArray = new Object[params.size()];
- paramsArray = params.toArray(paramsArray);
- return hasExtension(ext, paramsArray);
- }
-
public Type analyze(final String string, Object[] objects, final Set<AnalysationIssue> issues) {
if (objects == null) {
objects = new Object[0];
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java
index 132a613..c2ed7e1 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java
@@ -98,7 +98,7 @@ public class CheckComponent extends AbstractExpressionsUsingWorkflowComponent {
}
/**
- * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage()
+ * @see org.eclipse.workflow.lib.AbstractWorkflowComponent#getLogMessage()
*/
@Override
public String getLogMessage() {
@@ -117,9 +117,8 @@ public class CheckComponent extends AbstractExpressionsUsingWorkflowComponent {
}
/**
- * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName()
+ * @see org.eclipse.workflow.WorkflowComponent#getComponentName()
*/
- @Override
public String getComponentName() {
return COMPONENT_NAME;
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowAdvice.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowAdvice.java
index 7ef29d4..2420174 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowAdvice.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowAdvice.java
@@ -52,8 +52,8 @@ public abstract class AbstractExpressionsUsingWorkflowAdvice extends AbstractWor
}
/**
- * @see org.eclipse.emf.mwe.core.ao.AbstractWorkflowAdvice#weave(org.eclipse.emf.mwe.core.WorkflowComponent,
- * org.eclipse.emf.mwe.core.issues.Issues)
+ * @see org.eclipse.workflow.ao.AbstractWorkflowAdvice#weave(org.eclipse.workflow.WorkflowComponent,
+ * org.eclipse.workflow.issues.Issues)
*/
@Override
public void weave(WorkflowComponent c, Issues issues) {
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java
index 2bedafa..269775a 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java
@@ -32,7 +32,7 @@ public abstract class AbstractExpressionsUsingWorkflowComponent extends Abstract
protected final List<MetaModel> metaModels = new ArrayList<MetaModel>();
- protected final List<GlobalVarDef> globalVarDefs = new ArrayList<GlobalVarDef>();
+ private List<GlobalVarDef> globalVarDefs = new ArrayList<GlobalVarDef>();
protected final List<String> _advice = new ArrayList<String>();
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java
index 5b7b6b1..3cd475a 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java
@@ -19,6 +19,23 @@ import org.eclipse.internal.xtend.expression.ast.SyntaxElement;
*/
public class AnalysationIssue {
+ private enum AnalysationIssueSeverity {
+ WARNING, ERROR
+ };
+
+ public final static class AnalysationIssueType {
+ String name;
+
+ public AnalysationIssueType(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+
public final static AnalysationIssueType INCOMPATIBLE_TYPES = new AnalysationIssueType("Incompatible types");
public final static AnalysationIssueType UNNECESSARY_CAST = new AnalysationIssueType("Unnecessary cast");
@@ -29,35 +46,40 @@ public class AnalysationIssue {
public static final AnalysationIssueType INTERNAL_ERROR = new AnalysationIssueType("Internal error");
- public static final AnalysationIssueType JAVA_TYPE_NOT_FOUND = new AnalysationIssueType("Java AnalysationIssueType not found");
+ public static final AnalysationIssueType JAVA_TYPE_NOT_FOUND = new AnalysationIssueType(
+ "Java AnalysationIssueType not found");
public static final AnalysationIssueType SYNTAX_ERROR = new AnalysationIssueType("Syntax error");
public static final AnalysationIssueType RESOURCE_NOT_FOUND = new AnalysationIssueType("Resource not found");
- public final static class AnalysationIssueType {
- String name;
+ private final AnalysationIssueType analysationIssueType;
- public AnalysationIssueType(final String name) {
- this.name = name;
- }
+ private final String message;
- @Override
- public String toString() {
- return name;
- }
- }
+ private final SyntaxElement element;
- private AnalysationIssueType analysationIssueType;
+ private final AnalysationIssueSeverity severity;
- private String message;
+ public AnalysationIssue(final AnalysationIssueType analysationIssueType, final String message,
+ final SyntaxElement element) {
+ this(analysationIssueType, message, element, false);
+ }
- private SyntaxElement element;
+ public AnalysationIssue(final AnalysationIssueType analysationIssueType, final String message,
+ final SyntaxElement element, boolean warning) {
+ if (analysationIssueType == null || message == null || message.length() == 0 || element == null)
+ throw new IllegalArgumentException();
- public AnalysationIssue(final AnalysationIssueType analysationIssueType, final String message, final SyntaxElement element) {
this.analysationIssueType = analysationIssueType;
this.message = message;
this.element = element;
+ if (warning) {
+ severity = AnalysationIssueSeverity.WARNING;
+ }
+ else {
+ severity = AnalysationIssueSeverity.ERROR;
+ }
}
public SyntaxElement getElement() {
@@ -72,6 +94,14 @@ public class AnalysationIssue {
return analysationIssueType;
}
+ public boolean isError() {
+ return severity == AnalysationIssueSeverity.ERROR;
+ }
+
+ public boolean isWarning() {
+ return severity == AnalysationIssueSeverity.WARNING;
+ }
+
@Override
public String toString() {
return "[" + analysationIssueType.name + "] - " + message + " : " + element;
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Callback.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Callback.java
index 578e6ea..c882e63 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Callback.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Callback.java
@@ -24,12 +24,8 @@ public interface Callback {
* @param ctx
*/
void pre(SyntaxElement ele, ExecutionContext ctx);
-
/**
- * @param expressionResult
- * the result of the evaluation (an instance of {@link Type} in
- * analyzation phase) if syntax element was an instance of
- * {@link Expression}
+ * @param expressionResult the result of the evaluation (an instance of {@link Type} in analyzation phase) if syntax element was an instance of {@link Expression}
*/
void post(Object expressionResult);
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java
index 0c0431d..c352960 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java
@@ -32,7 +32,7 @@ public class ExpressionFacade {
return execContext;
}
- public ExpressionFacade (final ExecutionContext execCtx) {
+ public ExpressionFacade(final ExecutionContext execCtx) {
execContext = execCtx;
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java
index bfa3ab1..d6d9c01 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java
@@ -20,6 +20,4 @@ public interface Resource {
public String[] getImportedExtensions();
-
-
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java
index 1624694..4253537 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java
@@ -18,7 +18,7 @@ import org.eclipse.internal.xtend.expression.parser.SyntaxConstants;
/**
* Utility class for retrieving information from various type name presentations
- * used within oAW's type system.
+ * used within Xtend's type system.
* <p>
* The following type formats can occur:
* <ul>
@@ -32,7 +32,7 @@ import org.eclipse.internal.xtend.expression.parser.SyntaxConstants;
* <li> <code>entities::Account</code>
* <li> <code>List[entities::Account]</code>
* </ul>
- * <p> '<code>&lt;typename&gt;</code>' is the fully qualified name
+ * <p>'<code>&lt;typename&gt;</code>' is the fully qualified name
* <code>namespace1::namespace2::name</code>
*
* @author Sven Efftinge (http://www.efftinge.de) - Initial implementation
@@ -45,9 +45,9 @@ public class TypeNameUtil {
/**
* This pattern is used to find the type name within possible query strings
*/
- final static Pattern TYPE_PATTERN =
- Pattern.compile("\\A(?:(\\w+)\\[)?(?:(\\w+)!)?("+QUALIFIEDNAME_STRING+")(?:\\])?\\z");
- final static Pattern GENERICLIST_PATTERN = Pattern.compile("\\A\\[L("+QUALIFIEDNAME_STRING+");");
+ final static Pattern TYPE_PATTERN = Pattern.compile("\\A(?:(\\w+)\\[)?(?:(\\w+)!)?(" + QUALIFIEDNAME_STRING
+ + ")(?:\\])?\\z");
+ final static Pattern GENERICLIST_PATTERN = Pattern.compile("\\A\\[L(" + QUALIFIEDNAME_STRING + ");");
/**
* Retrieves the collection type.
@@ -62,7 +62,7 @@ public class TypeNameUtil {
if (group == null) {
if (GENERICLIST_PATTERN.matcher(name).matches()) {
group = "List";
- }
+ }
}
return group;
}
@@ -86,11 +86,10 @@ public class TypeNameUtil {
}
private static String getGroup(final String input, final Pattern pattern, final int group) {
- final Matcher m = pattern.matcher(input);
-
- if (m.matches() && m.groupCount() >= group) {
+ final Matcher m = pattern.matcher(input);
+
+ if (m.matches() && m.groupCount() >= group)
return m.group(group);
- }
return null;
}
@@ -99,7 +98,8 @@ public class TypeNameUtil {
*
* @param class1
* A class instance for which the name should be retrieved
- * @return oAW's classname representation (<code>package1::package2::TheClassname</code>)
+ * @return Xtend's classname representation (
+ * <code>package1::package2::TheClassname</code>)
*/
public static String getName(final Class<?> class1) {
return class1.getName().replaceAll("\\.", SyntaxConstants.NS_DELIM);
@@ -110,17 +110,14 @@ public class TypeNameUtil {
*
* @param fqn
* Qualified type name
- * @return
- *
- * <pre>
+ * @return <pre>
* ns1::ns2::name -&gt; ns1::ns2
* name -&gt; &lt;null&gt;
* </pre>
*/
public static String withoutLastSegment(final String fqn) {
- if (fqn.lastIndexOf(SyntaxConstants.NS_DELIM) == -1) {
+ if (fqn.lastIndexOf(SyntaxConstants.NS_DELIM) == -1)
return null;
- }
return fqn.substring(0, fqn.lastIndexOf(SyntaxConstants.NS_DELIM));
}
@@ -130,17 +127,14 @@ public class TypeNameUtil {
*
* @param fqn
* Qualified type name
- * @return
- *
- * <pre>
+ * @return <pre>
* ns1::ns2::name -&gt; name
* name -&gt; name
* </pre>
*/
public static String getLastSegment(final String fqn) {
- if (fqn.lastIndexOf(SyntaxConstants.NS_DELIM) == -1) {
+ if (fqn.lastIndexOf(SyntaxConstants.NS_DELIM) == -1)
return fqn;
- }
return fqn.substring(fqn.lastIndexOf(SyntaxConstants.NS_DELIM) + SyntaxConstants.NS_DELIM.length());
}
@@ -149,9 +143,7 @@ public class TypeNameUtil {
*
* @param fqn
* Qualified type string
- * @return
- *
- * <pre>
+ * @return <pre>
* ns1::ns2::type -&gt; type
* List[type] -&gt; List[type]
* List[Metamodel!ns1::type] -&gt; List[Metamodel!type]
@@ -171,27 +163,29 @@ public class TypeNameUtil {
return sb.toString();
}
- public static Object getPackage(String insertString) {
+ public static Object getPackage(final String insertString) {
if (insertString == null || insertString.trim().length() == 0)
return null;
- int index = insertString.indexOf(SyntaxConstants.NS_DELIM);
- if (index != -1) {
+ final int index = insertString.indexOf(SyntaxConstants.NS_DELIM);
+ if (index != -1)
return insertString.substring(0, index);
- }
return null;
}
-
+
/**
- * Converts a Java qualified name (dot seperated) to oAW qualified name ('::' seperated)
- * @param javaTypeName A java qualifier
- * @return All dots are replaced by '::'. Returns <code>null</code> if <tt>javaTypeName</tt> is null.
+ * Converts a Java qualified name (dot seperated) to Xtend qualified name
+ * ('::' seperated)
+ *
+ * @param javaTypeName
+ * A java qualifier
+ * @return All dots are replaced by '::'. Returns <code>null</code> if
+ * <tt>javaTypeName</tt> is null.
* @since 4.3.1
*/
- public static String convertJavaTypeName (String javaTypeName) {
- if (javaTypeName == null) {
+ public static String convertJavaTypeName(final String javaTypeName) {
+ if (javaTypeName == null)
return null;
- } else {
+ else
return javaTypeName.replaceAll("\\.", SyntaxConstants.NS_DELIM);
- }
}
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java
index f366eeb..6e25399 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java
@@ -144,7 +144,6 @@ public class TypeSystemImpl implements TypeSystem {
}
}
}
-
return bestMatch;
}
@@ -168,9 +167,12 @@ public class TypeSystemImpl implements TypeSystem {
t = (ParameterizedType) builtin.getTypeForName(collectionTypeName);
if (t == null) {
return null;
- }
+ }
}
Type r = null;
+ // FIXME This loop can potentially return wrong results depending on the
+ // installed metamodels and the order of these models in the
+ // list "metamodels".
for (int i = 0; i < metaModels.size() && r == null; i++) {
final MetaModel curMeta = metaModels.get(i);
r = curMeta.getTypeForName(typeName);
@@ -181,7 +183,7 @@ public class TypeSystemImpl implements TypeSystem {
return r;
} else {
return t.cloneWithInnerType(r);
- }
+ }
}
public Type getFeatureType() {
@@ -264,7 +266,7 @@ public class TypeSystemImpl implements TypeSystem {
colType = (ParameterizedType) builtin.getTypeForName(colTypeName);
if (colType == null) {
return new Type[0];
- }
+ }
}
for (int i = 0; i < metaModels.size(); i++) {
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java
index 27a43e3..a694ce7 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java
@@ -173,7 +173,6 @@ public abstract class AbstractTypeImpl implements Type {
public Object convert(final Object src, final Class<?> targetType) {
if (src == null)
return null;
-
if (targetType.isInstance(src))
return src;
else
diff --git a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/TestEnvironment.java b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/TestEnvironment.java
index b6a2455..8f4667b 100644
--- a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/TestEnvironment.java
+++ b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/TestEnvironment.java
@@ -60,1080 +60,1137 @@ import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
import org.eclipse.xtend.shared.ui.Activator;
import org.eclipse.xtend.shared.ui.core.IModelMarker;
-
public class TestEnvironment {
- private boolean fIsOpen = false;
-
- private boolean fWasBuilt = false;
-
- private IWorkspace fWorkspace = null;
-
- private Hashtable fProjects = null;
-
- private void addBuilderSpecs(final String projectName) {
- try {
- final IProject project = getProject(projectName);
- final IProjectDescription description = project.getDescription();
- description.setNatureIds(new String[] { JavaCore.NATURE_ID, Activator.getNatureId() });
-
- project.setDescription(description, null);
- } catch (final CoreException e) {
- handleCoreException(e);
- }
- }
-
- /**
- * Adds a binary class with the given contents to the given package in the
- * workspace. The package is created if necessary. If a class with the same
- * name already exists, it is replaced. A workspace must be open, and the
- * given class name must not end with ".class". Returns the path of the
- * added class.
- */
- public IPath addBinaryClass(final IPath packagePath, final String className, final byte[] contents) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IPath classPath = packagePath.append(className + ".class"); //$NON-NLS-1$
- createFile(classPath, contents);
- return classPath;
- }
-
- /**
- * Adds a binary class with the given contents to the given package in the
- * workspace. The package is created if necessary. If a class with the same
- * name already exists, it is replaced. A workspace must be open, and the
- * given class name must not end with ".class". Returns the path of the
- * added class.
- */
- public IPath addBinaryClass(final IPath packageFragmentRootPath, final String packageName, final String className,
- final byte[] contents) {
- /* make sure the package exists */
- if (packageName != null && packageName.length() > 0) {
- final IPath packagePath = addPackage(packageFragmentRootPath, packageName);
-
- return addBinaryClass(packagePath, className, contents);
- }
- return addBinaryClass(packageFragmentRootPath, className, contents);
-
- }
-
- /**
- * Adds a class with the given contents to the given package in the
- * workspace. The package is created if necessary. If a class with the same
- * name already exists, it is replaced. A workspace must be open, and the
- * given class name must not end with ".java". Returns the path of the added
- * class.
- */
- public IPath addClass(final IPath packagePath, final String className, final String contents) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IPath classPath = packagePath.append(className + ".java"); //$NON-NLS-1$
- createFile(classPath, contents.getBytes());
- return classPath;
- }
-
- /**
- * Adds a class with the given contents to the given package in the
- * workspace. The package is created if necessary. If a class with the same
- * name already exists, it is replaced. A workspace must be open, and the
- * given class name must not end with ".java". Returns the path of the added
- * class.
- */
- public IPath addClass(final IPath packageFragmentRootPath, final String packageName, final String className,
- final String contents) {
- /* make sure the package exists */
- if (packageName != null && packageName.length() > 0) {
- final IPath packagePath = addPackage(packageFragmentRootPath, packageName);
-
- return addClass(packagePath, className, contents);
- }
- return addClass(packageFragmentRootPath, className, contents);
- }
-
- /**
- * Adds a package to the given package fragment root in the workspace. The
- * package fragment root is created if necessary. If a package with the same
- * name already exists, it is not replaced. A workspace must be open.
- * Returns the path of the added package.
- */
- public IPath addPackage(final IPath packageFragmentRootPath, final String packageName) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IPath path = packageFragmentRootPath.append(packageName.replace('.', IPath.SEPARATOR));
- createFolder(path);
- return path;
- }
-
- public IPath addPackageFragmentRoot(final IPath projectPath, final String sourceFolderName)
- throws JavaModelException {
- return addPackageFragmentRoot(projectPath, sourceFolderName, null, null);
- }
-
- /**
- * Adds a package fragment root to the workspace. If a package fragment root
- * with the same name already exists, it is not replaced. A workspace must
- * be open. Returns the path of the added package fragment root.
- */
- public IPath addPackageFragmentRoot(final IPath projectPath, final String sourceFolderName,
- final IPath[] exclusionPatterns, final String specificOutputLocation) throws JavaModelException {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IPath path = getPackageFragmentRootPath(projectPath, sourceFolderName);
- createFolder(path);
- IPath outputPath = null;
- if (specificOutputLocation != null) {
- outputPath = getPackageFragmentRootPath(projectPath, specificOutputLocation);
- createFolder(outputPath);
- }
- final IClasspathEntry entry = JavaCore.newSourceEntry(path, exclusionPatterns == null ? new Path[0]
- : exclusionPatterns, outputPath);
- addEntry(projectPath, entry);
- return path;
- }
-
- public IPath addProject(final String projectName) throws JavaModelException {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IProject project = createProject(projectName);
-
- return project.getFullPath();
- }
-
- public void addRequiredProject(final IPath projectPath, final IPath requiredProjectPath) throws JavaModelException {
- addRequiredProject(projectPath, requiredProjectPath, new IPath[] {}/*
- * include
- * all
- */,
- new IPath[] {}/* exclude none */, false);
- }
-
- /**
- * Adds a project to the classpath of a project.
- */
- @SuppressWarnings("restriction")
+ private boolean fIsOpen = false;
+
+ private boolean fWasBuilt = false;
+
+ private IWorkspace fWorkspace = null;
+
+ private Hashtable fProjects = null;
+
+ private void addBuilderSpecs(final String projectName) {
+ try {
+ final IProject project = getProject(projectName);
+ final IProjectDescription description = project.getDescription();
+ description.setNatureIds(new String[] { JavaCore.NATURE_ID, Activator.getNatureId() });
+
+ project.setDescription(description, null);
+ }
+ catch (final CoreException e) {
+ handleCoreException(e);
+ }
+ }
+
+ /**
+ * Adds a binary class with the given contents to the given package in the
+ * workspace. The package is created if necessary. If a class with the same
+ * name already exists, it is replaced. A workspace must be open, and the
+ * given class name must not end with ".class". Returns the path of the
+ * added class.
+ */
+ public IPath addBinaryClass(final IPath packagePath, final String className, final byte[] contents) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IPath classPath = packagePath.append(className + ".class"); //$NON-NLS-1$
+ createFile(classPath, contents);
+ return classPath;
+ }
+
+ /**
+ * Adds a binary class with the given contents to the given package in the
+ * workspace. The package is created if necessary. If a class with the same
+ * name already exists, it is replaced. A workspace must be open, and the
+ * given class name must not end with ".class". Returns the path of the
+ * added class.
+ */
+ public IPath addBinaryClass(final IPath packageFragmentRootPath, final String packageName, final String className,
+ final byte[] contents) {
+ /* make sure the package exists */
+ if (packageName != null && packageName.length() > 0) {
+ final IPath packagePath = addPackage(packageFragmentRootPath, packageName);
+
+ return addBinaryClass(packagePath, className, contents);
+ }
+ return addBinaryClass(packageFragmentRootPath, className, contents);
+
+ }
+
+ /**
+ * Adds a class with the given contents to the given package in the
+ * workspace. The package is created if necessary. If a class with the same
+ * name already exists, it is replaced. A workspace must be open, and the
+ * given class name must not end with ".java". Returns the path of the added
+ * class.
+ */
+ public IPath addClass(final IPath packagePath, final String className, final String contents) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IPath classPath = packagePath.append(className + ".java"); //$NON-NLS-1$
+ createFile(classPath, contents.getBytes());
+ return classPath;
+ }
+
+ /**
+ * Adds a class with the given contents to the given package in the
+ * workspace. The package is created if necessary. If a class with the same
+ * name already exists, it is replaced. A workspace must be open, and the
+ * given class name must not end with ".java". Returns the path of the added
+ * class.
+ */
+ public IPath addClass(final IPath packageFragmentRootPath, final String packageName, final String className,
+ final String contents) {
+ /* make sure the package exists */
+ if (packageName != null && packageName.length() > 0) {
+ final IPath packagePath = addPackage(packageFragmentRootPath, packageName);
+
+ return addClass(packagePath, className, contents);
+ }
+ return addClass(packageFragmentRootPath, className, contents);
+ }
+
+ /**
+ * Adds a package to the given package fragment root in the workspace. The
+ * package fragment root is created if necessary. If a package with the same
+ * name already exists, it is not replaced. A workspace must be open.
+ * Returns the path of the added package.
+ */
+ public IPath addPackage(final IPath packageFragmentRootPath, final String packageName) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IPath path = packageFragmentRootPath.append(packageName.replace('.', IPath.SEPARATOR));
+ createFolder(path);
+ return path;
+ }
+
+ public IPath addPackageFragmentRoot(final IPath projectPath, final String sourceFolderName)
+ throws JavaModelException {
+ return addPackageFragmentRoot(projectPath, sourceFolderName, null, null);
+ }
+
+ /**
+ * Adds a package fragment root to the workspace. If a package fragment root
+ * with the same name already exists, it is not replaced. A workspace must
+ * be open. Returns the path of the added package fragment root.
+ */
+ public IPath addPackageFragmentRoot(final IPath projectPath, final String sourceFolderName,
+ final IPath[] exclusionPatterns, final String specificOutputLocation) throws JavaModelException {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IPath path = getPackageFragmentRootPath(projectPath, sourceFolderName);
+ createFolder(path);
+ IPath outputPath = null;
+ if (specificOutputLocation != null) {
+ outputPath = getPackageFragmentRootPath(projectPath, specificOutputLocation);
+ createFolder(outputPath);
+ }
+ final IClasspathEntry entry = JavaCore.newSourceEntry(path, exclusionPatterns == null ? new Path[0]
+ : exclusionPatterns, outputPath);
+ addEntry(projectPath, entry);
+ return path;
+ }
+
+ public IPath addProject(final String projectName) throws JavaModelException {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IProject project = createProject(projectName);
+
+ return project.getFullPath();
+ }
+
+ public void addRequiredProject(final IPath projectPath, final IPath requiredProjectPath) throws JavaModelException {
+ addRequiredProject(projectPath, requiredProjectPath, new IPath[] {}/*
+ * include
+ * all
+ */, new IPath[] {}/*
+ * exclude
+ * none
+ */, false);
+ }
+
+ /**
+ * Adds a project to the classpath of a project.
+ */
+ @SuppressWarnings("restriction")
public void addRequiredProject(final IPath projectPath, final IPath requiredProjectPath,
- final IPath[] accessibleFiles, final IPath[] nonAccessibleFiles, final boolean isExported)
- throws JavaModelException {
- checkAssertion("required project must not be in project", !projectPath.isPrefixOf(requiredProjectPath)); //$NON-NLS-1$
- final IAccessRule[] accessRules = ClasspathEntry.getAccessRules(accessibleFiles, nonAccessibleFiles);
- addEntry(projectPath, JavaCore.newProjectEntry(requiredProjectPath, accessRules, true,
- new IClasspathAttribute[0], isExported));
- }
-
- public void addExternalJars(final IPath projectPath, final String[] jars) throws JavaModelException {
- addExternalJars(projectPath, jars, false);
- }
-
- public void addExternalJar(final IPath projectPath, final String jar) throws JavaModelException {
- addExternalJar(projectPath, jar, false);
- }
-
- /**
- * Add the given folder to the list of source folders in the given Java Projekt
- * @param projectPath Project to modify
- * @param folder Folder to add
- */
- public IClasspathEntry addFolderToSourceFolders(final IPath projectPath, final IPath folder) {
- IClasspathEntry newSourceEntry = null;
- try {
- newSourceEntry = JavaCore.newSourceEntry(folder);
- addEntry(projectPath, newSourceEntry);
- } catch (final JavaModelException e) {
- e.printStackTrace();
- checkAssertion("JavaModelException", false); //$NON-NLS-1$
- }
- return newSourceEntry;
- }
-
- /**
- * Adds an external jar to the classpath of a project.
- */
- public void addExternalJars(final IPath projectPath, final String[] jars, final boolean isExported)
- throws JavaModelException {
- for (int i = 0, max = jars.length; i < max; i++) {
- final String jar = jars[i];
- checkAssertion("file name must end with .zip or .jar", jar.endsWith(".zip") || jar.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addEntry(projectPath, JavaCore.newLibraryEntry(new Path(jar), null, null, isExported));
- }
- }
-
- /**
- * Adds an external jar to the classpath of a project.
- */
- public void addExternalJar(final IPath projectPath, final String jar, final boolean isExported)
- throws JavaModelException {
- checkAssertion("file name must end with .zip or .jar", jar.endsWith(".zip") || jar.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addEntry(projectPath, JavaCore.newLibraryEntry(new Path(jar), null, null, isExported));
- }
-
- private void addEntry(final IPath projectPath, final IClasspathEntry entryPath) throws JavaModelException {
- final IClasspathEntry[] classpath = getClasspath(projectPath);
- final IClasspathEntry[] newClaspath = new IClasspathEntry[classpath.length + 1];
- System.arraycopy(classpath, 0, newClaspath, 0, classpath.length);
- newClaspath[classpath.length] = entryPath;
- setClasspath(projectPath, newClaspath);
- }
-
- /**
- * Returns the class path.
- */
+ final IPath[] accessibleFiles, final IPath[] nonAccessibleFiles, final boolean isExported)
+ throws JavaModelException {
+ checkAssertion("required project must not be in project", !projectPath.isPrefixOf(requiredProjectPath)); //$NON-NLS-1$
+ final IAccessRule[] accessRules = ClasspathEntry.getAccessRules(accessibleFiles, nonAccessibleFiles);
+ addEntry(projectPath, JavaCore.newProjectEntry(requiredProjectPath, accessRules, true,
+ new IClasspathAttribute[0], isExported));
+ }
+
+ public void addExternalJars(final IPath projectPath, final String[] jars) throws JavaModelException {
+ addExternalJars(projectPath, jars, false);
+ }
+
+ public void addExternalJar(final IPath projectPath, final String jar) throws JavaModelException {
+ addExternalJar(projectPath, jar, false);
+ }
+
+ /**
+ * Add the given folder to the list of source folders in the given Java
+ * Projekt
+ *
+ * @param projectPath
+ * Project to modify
+ * @param folder
+ * Folder to add
+ */
+ public IClasspathEntry addFolderToSourceFolders(final IPath projectPath, final IPath folder) {
+ IClasspathEntry newSourceEntry = null;
+ try {
+ newSourceEntry = JavaCore.newSourceEntry(folder);
+ addEntry(projectPath, newSourceEntry);
+ }
+ catch (final JavaModelException e) {
+ e.printStackTrace();
+ checkAssertion("JavaModelException", false); //$NON-NLS-1$
+ }
+ return newSourceEntry;
+ }
+
+ /**
+ * Adds an external jar to the classpath of a project.
+ */
+ public void addExternalJars(final IPath projectPath, final String[] jars, final boolean isExported)
+ throws JavaModelException {
+ for (final String jar : jars) {
+ checkAssertion("file name must end with .zip or .jar", jar.endsWith(".zip") || jar.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addEntry(projectPath, JavaCore.newLibraryEntry(new Path(jar), null, null, isExported));
+ }
+ }
+
+ /**
+ * Adds an external jar to the classpath of a project.
+ */
+ public void addExternalJar(final IPath projectPath, final String jar, final boolean isExported)
+ throws JavaModelException {
+ checkAssertion("file name must end with .zip or .jar", jar.endsWith(".zip") || jar.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addEntry(projectPath, JavaCore.newLibraryEntry(new Path(jar), null, null, isExported));
+ }
+
+ private void addEntry(final IPath projectPath, final IClasspathEntry entryPath) throws JavaModelException {
+ final IClasspathEntry[] classpath = getClasspath(projectPath);
+ final IClasspathEntry[] newClaspath = new IClasspathEntry[classpath.length + 1];
+ System.arraycopy(classpath, 0, newClaspath, 0, classpath.length);
+ newClaspath[classpath.length] = entryPath;
+ setClasspath(projectPath, newClaspath);
+ }
+
+ /**
+ * Returns the class path.
+ */
@SuppressWarnings("restriction")
public IClasspathEntry[] getClasspath(final IPath projectPath) {
- try {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final JavaProject javaProject = (JavaProject) JavaCore.create(getProject(projectPath));
- return javaProject.getExpandedClasspath();
- } catch (final JavaModelException e) {
- e.printStackTrace();
- checkAssertion("JavaModelException", false); //$NON-NLS-1$
- return null; // not reachable
- }
- }
-
- /**
- * Adds a file.
- */
- public IPath addFile(final IPath root, final String fileName, final String contents) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IPath filePath = root.append(fileName);
- createFile(filePath, contents.getBytes());
- return filePath;
- }
-
- /**
- * Adds a folder.
- */
- public IPath addFolder(final IPath root, final String folderName) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IPath folderPath = root.append(folderName);
- createFolder(folderPath);
- return folderPath;
- }
-
- public IPath addInternalJar(final IPath projectPath, final String zipName, final byte[] contents)
- throws JavaModelException {
- return addInternalJar(projectPath, zipName, contents, false);
- }
-
- /**
- * Adds a jar with the given contents to the the workspace. If a jar with
- * the same name already exists, it is replaced. A workspace must be open,
- * and the given zip name must end with ".zip" or ".jar". Returns the path
- * of the added jar.
- */
- public IPath addInternalJar(final IPath projectPath, final String zipName, final byte[] contents,
- final boolean isExported) throws JavaModelException {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- checkAssertion("zipName must end with .zip or .jar", zipName.endsWith(".zip") || zipName.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- final IPath path = projectPath.append(zipName);
-
- /* remove any existing zip from the java model */
- removeInternalJar(projectPath, zipName);
-
- createFile(path, contents);
- addEntry(projectPath, JavaCore.newLibraryEntry(path, null, null, isExported));
- return path;
- }
-
- private void checkAssertion(final String message, boolean b) {
- if (!b)
- throw new RuntimeException(message);
- }
-
- /**
- * Closes the testing environment and frees up any resources. Once the
- * testing environment is closed, it shouldn't be used any more.
- */
- public void close() {
- try {
- if (fProjects != null) {
- final Enumeration projectNames = fProjects.keys();
- while (projectNames.hasMoreElements()) {
- final String projectName = (String) projectNames.nextElement();
- getJavaProject(projectName).getJavaModel().close();
- }
- }
- closeWorkspace();
- } catch (final JavaModelException e) {
- e.printStackTrace();
- } catch (final RuntimeException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Close a project from the workspace.
- */
- public void closeProject(final IPath projectPath) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- try {
- getJavaProject(projectPath).getProject().close(null);
- } catch (final CoreException e) {
- e.printStackTrace();
- }
- }
-
- private void closeWorkspace() {
- fIsOpen = false;
- fWasBuilt = false;
- }
-
- private IFile createFile(final IPath path, final byte[] contents) {
- try {
- final IFile file = fWorkspace.getRoot().getFile(path);
-
- final ByteArrayInputStream is = new ByteArrayInputStream(contents);
- if (file.exists()) {
- file.setContents(is, true, false, null);
- } else {
- file.create(is, true, null);
- }
- return file;
- } catch (final CoreException e) {
- handle(e);
- }
- return null;
- }
-
- private IFolder createFolder(final IPath path) {
- checkAssertion("root", !path.isRoot()); //$NON-NLS-1$
-
- /* don't create folders for projects */
- if (path.segmentCount() <= 1)
- return null;
-
- final IFolder folder = fWorkspace.getRoot().getFolder(path);
- if (!folder.exists()) {
- /* create the parent folder if necessary */
- createFolder(path.removeLastSegments(1));
-
- try {
- folder.create(true, true, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
- return folder;
- }
-
- public IProject createProject(final String projectName) {
- IProject project = null;
- try {
- project = fWorkspace.getRoot().getProject(projectName);
- project.create(null, null);
- project.open(null);
- fProjects.put(projectName, project);
- addBuilderSpecs(projectName);
- } catch (final CoreException e) {
- handle(e);
- }
-
- return project;
- }
-
- /**
- * Batch builds the workspace. A workspace must be open.
- */
- public void fullBuild() {
- waitForAutoBuild();
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- try {
- getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
- } catch (final CoreException e) {
- handle(e);
- }
- fWasBuilt = true;
- }
-
- /**
- * Batch builds a project. A workspace must be open.
- */
- public void fullBuild(final IPath projectPath) {
- waitForAutoBuild();
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- try {
- getProject(projectPath).build(IncrementalProjectBuilder.FULL_BUILD, null);
- } catch (final CoreException e) {
- handle(e);
- }
- fWasBuilt = true;
- }
-
- /**
- * Returns the Java Model element for the project.
- */
- public IJavaProject getJavaProject(final IPath projectPath) {
- final IJavaProject javaProject = JavaCore.create(getProject(projectPath));
- if (javaProject == null)
- throw new NullPointerException("No javaProject for path : " + projectPath.toPortableString());
- return javaProject;
- }
-
- /**
- * Returns the Java Model element for the project.
- */
- public IJavaProject getJavaProject(final String projectName) {
- final IJavaProject javaProject = JavaCore.create(getProject(projectName));
- if (javaProject == null)
- throw new NullPointerException("No javaProject for name : " + projectName);
- return javaProject;
- }
-
- /**
- * Return output location for a project.
- */
- public IPath getOutputLocation(final IPath projectPath) {
- try {
- final IJavaProject javaProject = JavaCore.create(getProject(projectPath));
- return javaProject.getOutputLocation();
- } catch (final CoreException e) {
- // ignore
- }
- return null;
- }
-
- /**
- * Return all problems with workspace.
- */
- public IMarker[] getMarkers() {
- return getMarkersFor(getWorkspaceRootPath());
- }
-
- /**
- * Return all problems with the specified element.
- */
- public IMarker[] getMarkersFor(final IPath path) {
- return getMarkersFor(path, false);
- }
-
- /**
- * Return all problems with the specified element.
- */
+ try {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final JavaProject javaProject = (JavaProject) JavaCore.create(getProject(projectPath));
+ return javaProject.getExpandedClasspath();
+ }
+ catch (final JavaModelException e) {
+ e.printStackTrace();
+ checkAssertion("JavaModelException", false); //$NON-NLS-1$
+ return null; // not reachable
+ }
+ }
+
+ /**
+ * Adds a file.
+ */
+ public IPath addFile(final IPath root, final String fileName, final String contents) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IPath filePath = root.append(fileName);
+ createFile(filePath, contents.getBytes());
+ return filePath;
+ }
+
+ /**
+ * Adds a folder.
+ */
+ public IPath addFolder(final IPath root, final String folderName) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IPath folderPath = root.append(folderName);
+ createFolder(folderPath);
+ return folderPath;
+ }
+
+ public IPath addInternalJar(final IPath projectPath, final String zipName, final byte[] contents)
+ throws JavaModelException {
+ return addInternalJar(projectPath, zipName, contents, false);
+ }
+
+ /**
+ * Adds a jar with the given contents to the the workspace. If a jar with
+ * the same name already exists, it is replaced. A workspace must be open,
+ * and the given zip name must end with ".zip" or ".jar". Returns the path
+ * of the added jar.
+ */
+ public IPath addInternalJar(final IPath projectPath, final String zipName, final byte[] contents,
+ final boolean isExported) throws JavaModelException {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ checkAssertion("zipName must end with .zip or .jar", zipName.endsWith(".zip") || zipName.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ final IPath path = projectPath.append(zipName);
+
+ /* remove any existing zip from the java model */
+ removeInternalJar(projectPath, zipName);
+
+ createFile(path, contents);
+ addEntry(projectPath, JavaCore.newLibraryEntry(path, null, null, isExported));
+ return path;
+ }
+
+ private void checkAssertion(final String message, final boolean b) {
+ if (!b)
+ throw new RuntimeException(message);
+ }
+
+ /**
+ * Closes the testing environment and frees up any resources. Once the
+ * testing environment is closed, it shouldn't be used any more.
+ */
+ public void close() {
+ try {
+ if (fProjects != null) {
+ final Enumeration projectNames = fProjects.keys();
+ while (projectNames.hasMoreElements()) {
+ final String projectName = (String) projectNames.nextElement();
+ getJavaProject(projectName).getJavaModel().close();
+ }
+ }
+ closeWorkspace();
+ }
+ catch (final JavaModelException e) {
+ e.printStackTrace();
+ }
+ catch (final RuntimeException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Close a project from the workspace.
+ */
+ public void closeProject(final IPath projectPath) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ try {
+ getJavaProject(projectPath).getProject().close(null);
+ }
+ catch (final CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void closeWorkspace() {
+ fIsOpen = false;
+ fWasBuilt = false;
+ }
+
+ private IFile createFile(final IPath path, final byte[] contents) {
+ try {
+ final IFile file = fWorkspace.getRoot().getFile(path);
+
+ final ByteArrayInputStream is = new ByteArrayInputStream(contents);
+ if (file.exists()) {
+ file.setContents(is, true, false, null);
+ }
+ else {
+ file.create(is, true, null);
+ }
+ return file;
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ return null;
+ }
+
+ private IFolder createFolder(final IPath path) {
+ checkAssertion("root", !path.isRoot()); //$NON-NLS-1$
+
+ /* don't create folders for projects */
+ if (path.segmentCount() <= 1)
+ return null;
+
+ final IFolder folder = fWorkspace.getRoot().getFolder(path);
+ if (!folder.exists()) {
+ /* create the parent folder if necessary */
+ createFolder(path.removeLastSegments(1));
+
+ try {
+ folder.create(true, true, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+ return folder;
+ }
+
+ public IProject createProject(final String projectName) {
+ IProject project = null;
+ try {
+ project = fWorkspace.getRoot().getProject(projectName);
+ project.create(null, null);
+ project.open(null);
+ fProjects.put(projectName, project);
+ addBuilderSpecs(projectName);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+
+ return project;
+ }
+
+ /**
+ * Batch builds the workspace. A workspace must be open.
+ */
+ public void fullBuild() {
+ waitForAutoBuild();
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ try {
+ getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ fWasBuilt = true;
+ }
+
+ /**
+ * Batch builds a project. A workspace must be open.
+ */
+ public void fullBuild(final IPath projectPath) {
+ waitForAutoBuild();
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ try {
+ getProject(projectPath).build(IncrementalProjectBuilder.FULL_BUILD, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ fWasBuilt = true;
+ }
+
+ /**
+ * Returns the Java Model element for the project.
+ */
+ public IJavaProject getJavaProject(final IPath projectPath) {
+ final IJavaProject javaProject = JavaCore.create(getProject(projectPath));
+ if (javaProject == null)
+ throw new NullPointerException("No javaProject for path : " + projectPath.toPortableString());
+ return javaProject;
+ }
+
+ /**
+ * Returns the Java Model element for the project.
+ */
+ public IJavaProject getJavaProject(final String projectName) {
+ final IJavaProject javaProject = JavaCore.create(getProject(projectName));
+ if (javaProject == null)
+ throw new NullPointerException("No javaProject for name : " + projectName);
+ return javaProject;
+ }
+
+ /**
+ * Return output location for a project.
+ */
+ public IPath getOutputLocation(final IPath projectPath) {
+ try {
+ final IJavaProject javaProject = JavaCore.create(getProject(projectPath));
+ return javaProject.getOutputLocation();
+ }
+ catch (final CoreException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ /**
+ * Return all problems with workspace.
+ */
+ public IMarker[] getMarkers() {
+ return getMarkersFor(getWorkspaceRootPath());
+ }
+
+ /**
+ * Return all problems with the specified element.
+ */
+ public IMarker[] getMarkersFor(final IPath path) {
+ return getMarkersFor(path, false);
+ }
+
+ /**
+ * Return all problems with the specified element.
+ */
public IMarker[] getMarkersFor(final IPath path, final boolean storeRange) {
- IResource resource;
- if (path.equals(getWorkspaceRootPath())) {
- resource = getWorkspace().getRoot();
- } else {
- final IProject p = getProject(path);
- if (p != null && path.equals(p.getFullPath())) {
- resource = getProject(path.lastSegment());
- } else if (path.getFileExtension() == null) {
- resource = getWorkspace().getRoot().getFolder(path);
- } else {
- resource = getWorkspace().getRoot().getFile(path);
- }
- }
- try {
- final ArrayList problems = new ArrayList();
- IMarker[] markers = resource.findMarkers(IModelMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
- problems.addAll(Arrays.asList(markers));
- markers = resource.findMarkers(IModelMarker.WARNING, true, IResource.DEPTH_INFINITE);
- problems.addAll(Arrays.asList(markers));
-
- return (IMarker[]) problems.toArray(new IMarker[problems.size()]);
- } catch (final CoreException e) {
- // ignore
- }
- return new IMarker[0];
- }
-
- /**
- * Return all problems with the specified element.
- */
- public IMarker[] getTaskMarkersFor(final IPath path) {
- IResource resource = null;
- if (path.equals(getWorkspaceRootPath())) {
- resource = getWorkspace().getRoot();
- } else {
- final IProject p = getProject(path);
- if (p != null && path.equals(p.getFullPath())) {
- resource = getProject(path.lastSegment());
- } else if (path.getFileExtension() == null) {
- resource = getWorkspace().getRoot().getFolder(path);
- } else {
- resource = getWorkspace().getRoot().getFile(path);
- }
- }
- try {
- if (resource != null)
- return resource.findMarkers(IJavaModelMarker.TASK_MARKER, true, IResource.DEPTH_INFINITE);
- } catch (final CoreException e) {
- // ignore
- }
- return new IMarker[0];
- }
-
- /**
- * Return the path of the package with the given name. A workspace must be
- * open, and the package must exist.
- */
- public IPath getPackagePath(final IPath root, final String packageName) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- if (packageName.length() == 0)
- return root;
- return root.append(packageName.replace('.', IPath.SEPARATOR));
- }
-
- /**
- * Return the path of the package fragment root with the given name. A
- * workspace must be open, and the package fragment root must exist.
- */
- public IPath getPackageFragmentRootPath(final IPath projectPath, final String name) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- if (name.length() == 0)
- return projectPath;
- return projectPath.append(name);
- }
-
- /**
- * Returns the core project.
- */
- public IProject getProject(final String projectName) {
- return (IProject) fProjects.get(projectName);
- }
-
- /**
- * Returns the core project.
- */
- public IProject getProject(final IPath projectPath) {
- return (IProject) fProjects.get(projectPath.lastSegment());
- }
-
- /**
- * Returns the workspace.
- */
- public IWorkspace getWorkspace() {
- return fWorkspace;
- }
-
- /**
- * Returns the path of workspace root.
- */
- public IPath getWorkspaceRootPath() {
- return getWorkspace().getRoot().getLocation();
- }
-
- private IPath getJarRootPath(final IPath projectPath) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- return getProject(projectPath).getFullPath();
- }
-
- void handle(final Exception e) {
- if (e instanceof CoreException) {
- handleCoreException((CoreException) e);
- } else
- throw new RuntimeException(e);
- }
-
- /**
- * Handles a core exception thrown during a testing environment operation
- */
- private void handleCoreException(final CoreException e) {
- e.printStackTrace();
- final IStatus status = e.getStatus();
- String message = e.getMessage();
- if (status.isMultiStatus()) {
- final MultiStatus multiStatus = (MultiStatus) status;
- final IStatus[] children = multiStatus.getChildren();
- final StringBuffer buffer = new StringBuffer();
- for (int i = 0, max = children.length; i < max; i++) {
- final IStatus child = children[i];
- if (child != null) {
- buffer.append(child.getMessage());
- buffer.append(System.getProperty("line.separator"));//$NON-NLS-1$
- }
- }
- message = String.valueOf(buffer);
- }
- throw new RuntimeException("Core exception in testing environment: " + message, e); //$NON-NLS-1$
- }
-
- /**
- * Incrementally builds the workspace. A workspace must be open.
- */
- public void incrementalBuild() {
- waitForAutoBuild();
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- checkAssertion("the workspace must have been built", fWasBuilt); //$NON-NLS-1$
- try {
- getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- /**
- * Incrementally builds a project. A workspace must be open.
- */
- public void incrementalBuild(final IPath projectPath) {
- waitForAutoBuild();
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- checkAssertion("the workspace must have been built", fWasBuilt); //$NON-NLS-1$
- try {
- getProject(projectPath).build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- public boolean isAutoBuilding() {
- final IWorkspace w = getWorkspace();
- final IWorkspaceDescription d = w.getDescription();
- return d.isAutoBuilding();
- }
-
- /**
- * Open an empty workspace.
- */
- public void openEmptyWorkspace() {
- close();
- openWorkspace();
- fProjects = new Hashtable(10);
- setup();
- }
-
- /**
- * Close a project from the workspace.
- */
- public void openProject(final IPath projectPath) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- try {
- getJavaProject(projectPath).getProject().open(null);
- } catch (final CoreException e) {
- e.printStackTrace();
- }
- }
-
- private void openWorkspace() {
- try {
- closeWorkspace();
-
- fWorkspace = ResourcesPlugin.getWorkspace();
-
- // turn off auto-build -- the tests determine when builds occur
- final IWorkspaceDescription description = fWorkspace.getDescription();
- description.setAutoBuilding(false);
- fWorkspace.setDescription(description);
- } catch (final Exception e) {
- handle(e);
- }
- }
-
- /**
- * Renames a compilation unit int the given package in the workspace. A
- * workspace must be open.
- */
- public void renameCU(final IPath packagePath, final String cuName, final String newName) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IFolder packageFolder = fWorkspace.getRoot().getFolder(packagePath);
- try {
- packageFolder.getFile(cuName).move(packageFolder.getFile(newName).getFullPath(), true, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- /**
- * Removes a binary class from the given package in the workspace. A
- * workspace must be open, and the given class name must not end with
- * ".class".
- */
- public void removeBinaryClass(final IPath packagePath, String className) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- className += ".class"; //$NON-NLS-1$
- final IFolder packageFolder = fWorkspace.getRoot().getFolder(packagePath);
- try {
- packageFolder.getFile(className).delete(true, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- /**
- * Removes a class from the given package in the workspace. A workspace must
- * be open, and the given class name must not end with ".java".
- */
- public void removeClass(final IPath packagePath, String className) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- className += ".java"; //$NON-NLS-1$
- final IFolder packageFolder = fWorkspace.getRoot().getFolder(packagePath);
- try {
- packageFolder.getFile(className).delete(true, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- /**
- * Removes a package from the given package fragment root in the workspace.
- * A workspace must be open.
- */
- public void removePackage(final IPath packageFragmentRootPath, final String packageName) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IPath path = packageFragmentRootPath.append(packageName.replace('.', IPath.SEPARATOR));
- final IFolder folder = fWorkspace.getRoot().getFolder(path);
- try {
- folder.delete(false, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- /**
- * Removes the given package fragment root from the the workspace. A
- * workspace must be open.
- */
- public void removePackageFragmentRoot(final IPath projectPath, final String packageFragmentRootName)
- throws JavaModelException {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- if (packageFragmentRootName.length() > 0) {
- final IFolder folder = getProject(projectPath).getFolder(packageFragmentRootName);
- if (folder.exists()) {
- try {
- folder.delete(false, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
- }
- final IPath rootPath = getPackageFragmentRootPath(projectPath, packageFragmentRootName);
- removeEntry(projectPath, rootPath);
- }
-
- /**
- * Remove a project from the workspace.
- */
- public void removeProject(final IPath projectPath) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- try {
- getJavaProject(projectPath).close();
- } catch (final JavaModelException e) {
- e.printStackTrace();
- }
- final IProject project = getProject(projectPath);
- try {
- project.refreshLocal(IProject.DEPTH_INFINITE, new NullProgressMonitor());
- project.delete(true, true, null);
- } catch (final CoreException ignore) {
-// handle(e);
- }
-
- }
-
- /**
- * Search the user hard-drive for a Java class library. Returns null if none
- * could be found.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()]
- */
- public String[] getJavaClassLibs() {
- final String jreDir = getJREDirectory();
- if (jreDir == null)
- return new String[] {};
- final String vmName = System.getProperty("java.vm.name");
- if ("J9".equals(vmName)) {
- return new String[] { toNativePath(jreDir + "/lib/jclMax/classes.zip") };
- } else if ("Mac OS X".equals(System.getProperty("os.name"))) {
- return new String[] { toNativePath(jreDir + "/../Classes/classes.jar") };
- } else {
- final File file = new File(jreDir + "/lib/rt.jar");
- if (file.exists())
- return new String[] { toNativePath(jreDir + "/lib/rt.jar") };
- return new String[] { toNativePath(jreDir + "/lib/core.jar"), toNativePath(jreDir + "/lib/security.jar"),
- toNativePath(jreDir + "/lib/graphics.jar") };
- }
- }
-
- /**
- * Returns the JRE directory this tests are running on. Returns null if none
- * could be found.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJREDirectory()]
- */
- public String getJREDirectory() {
- return System.getProperty("java.home");
- }
-
- /**
- * Makes the given path a path using native path separators as returned by
- * File.getPath() and trimming any extra slash.
- */
- public String toNativePath(final String path) {
- final String nativePath = path.replace('\\', File.separatorChar).replace('/', File.separatorChar);
- return nativePath.endsWith("/") || nativePath.endsWith("\\") ? nativePath.substring(0, nativePath.length() - 1)
- : nativePath;
- }
-
- /**
- * Remove a required project from the classpath
- */
- public void removeRequiredProject(final IPath projectPath, final IPath requiredProject) throws JavaModelException {
- removeEntry(projectPath, requiredProject);
- }
-
- /**
- * Remove all elements in the workspace.
- */
- public void resetWorkspace() {
- if (fProjects != null) {
- final Enumeration projectNames = fProjects.keys();
- while (projectNames.hasMoreElements()) {
- final String projectName = (String) projectNames.nextElement();
- removeProject(getProject(projectName).getFullPath());
- }
- }
- }
-
- /**
- * Remove a given classpath entry from the projects class path
- * @param projectPath The project to modify
- * @param entry The entry to remove
- * @throws JavaModelException
- */
- public void removeClasspathEntry(final IPath projectPath,
- final IClasspathEntry entry) throws JavaModelException {
+ IResource resource;
+ if (path.equals(getWorkspaceRootPath())) {
+ resource = getWorkspace().getRoot();
+ }
+ else {
+ final IProject p = getProject(path);
+ if (p != null && path.equals(p.getFullPath())) {
+ resource = getProject(path.lastSegment());
+ }
+ else if (path.getFileExtension() == null) {
+ resource = getWorkspace().getRoot().getFolder(path);
+ }
+ else {
+ resource = getWorkspace().getRoot().getFile(path);
+ }
+ }
+ try {
+ final ArrayList problems = new ArrayList();
+ IMarker[] markers = resource.findMarkers(IModelMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ problems.addAll(Arrays.asList(markers));
+ markers = resource.findMarkers(IModelMarker.WARNING, true, IResource.DEPTH_INFINITE);
+ problems.addAll(Arrays.asList(markers));
+
+ return (IMarker[]) problems.toArray(new IMarker[problems.size()]);
+ }
+ catch (final CoreException e) {
+ // ignore
+ }
+ return new IMarker[0];
+ }
+
+ /**
+ * Return all problems with the specified element.
+ */
+ public IMarker[] getTaskMarkersFor(final IPath path) {
+ IResource resource = null;
+ if (path.equals(getWorkspaceRootPath())) {
+ resource = getWorkspace().getRoot();
+ }
+ else {
+ final IProject p = getProject(path);
+ if (p != null && path.equals(p.getFullPath())) {
+ resource = getProject(path.lastSegment());
+ }
+ else if (path.getFileExtension() == null) {
+ resource = getWorkspace().getRoot().getFolder(path);
+ }
+ else {
+ resource = getWorkspace().getRoot().getFile(path);
+ }
+ }
+ try {
+ if (resource != null)
+ return resource.findMarkers(IJavaModelMarker.TASK_MARKER, true, IResource.DEPTH_INFINITE);
+ }
+ catch (final CoreException e) {
+ // ignore
+ }
+ return new IMarker[0];
+ }
+
+ /**
+ * Return the path of the package with the given name. A workspace must be
+ * open, and the package must exist.
+ */
+ public IPath getPackagePath(final IPath root, final String packageName) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ if (packageName.length() == 0)
+ return root;
+ return root.append(packageName.replace('.', IPath.SEPARATOR));
+ }
+
+ /**
+ * Return the path of the package fragment root with the given name. A
+ * workspace must be open, and the package fragment root must exist.
+ */
+ public IPath getPackageFragmentRootPath(final IPath projectPath, final String name) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ if (name.length() == 0)
+ return projectPath;
+ return projectPath.append(name);
+ }
+
+ /**
+ * Returns the core project.
+ */
+ public IProject getProject(final String projectName) {
+ return (IProject) fProjects.get(projectName);
+ }
+
+ /**
+ * Returns the core project.
+ */
+ public IProject getProject(final IPath projectPath) {
+ return (IProject) fProjects.get(projectPath.lastSegment());
+ }
+
+ /**
+ * Returns the workspace.
+ */
+ public IWorkspace getWorkspace() {
+ return fWorkspace;
+ }
+
+ /**
+ * Returns the path of workspace root.
+ */
+ public IPath getWorkspaceRootPath() {
+ return getWorkspace().getRoot().getLocation();
+ }
+
+ private IPath getJarRootPath(final IPath projectPath) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ return getProject(projectPath).getFullPath();
+ }
+
+ void handle(final Exception e) {
+ if (e instanceof CoreException) {
+ handleCoreException((CoreException) e);
+ }
+ else
+ throw new RuntimeException(e);
+ }
+
+ /**
+ * Handles a core exception thrown during a testing environment operation
+ */
+ private void handleCoreException(final CoreException e) {
+ e.printStackTrace();
+ final IStatus status = e.getStatus();
+ String message = e.getMessage();
+ if (status.isMultiStatus()) {
+ final MultiStatus multiStatus = (MultiStatus) status;
+ final IStatus[] children = multiStatus.getChildren();
+ final StringBuffer buffer = new StringBuffer();
+ for (final IStatus child : children) {
+ if (child != null) {
+ buffer.append(child.getMessage());
+ buffer.append(System.getProperty("line.separator"));//$NON-NLS-1$
+ }
+ }
+ message = String.valueOf(buffer);
+ }
+ throw new RuntimeException("Core exception in testing environment: " + message, e); //$NON-NLS-1$
+ }
+
+ /**
+ * Incrementally builds the workspace. A workspace must be open.
+ */
+ public void incrementalBuild() {
+ waitForAutoBuild();
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ checkAssertion("the workspace must have been built", fWasBuilt); //$NON-NLS-1$
+ try {
+ getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ /**
+ * Incrementally builds a project. A workspace must be open.
+ */
+ public void incrementalBuild(final IPath projectPath) {
+ waitForAutoBuild();
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ checkAssertion("the workspace must have been built", fWasBuilt); //$NON-NLS-1$
+ try {
+ getProject(projectPath).build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ public boolean isAutoBuilding() {
+ final IWorkspace w = getWorkspace();
+ final IWorkspaceDescription d = w.getDescription();
+ return d.isAutoBuilding();
+ }
+
+ /**
+ * Open an empty workspace.
+ */
+ public void openEmptyWorkspace() {
+ close();
+ openWorkspace();
+ fProjects = new Hashtable(10);
+ setup();
+ }
+
+ /**
+ * Close a project from the workspace.
+ */
+ public void openProject(final IPath projectPath) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ try {
+ getJavaProject(projectPath).getProject().open(null);
+ }
+ catch (final CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void openWorkspace() {
+ try {
+ closeWorkspace();
+
+ fWorkspace = ResourcesPlugin.getWorkspace();
+
+ // turn off auto-build -- the tests determine when builds occur
+ final IWorkspaceDescription description = fWorkspace.getDescription();
+ description.setAutoBuilding(false);
+ fWorkspace.setDescription(description);
+ }
+ catch (final Exception e) {
+ handle(e);
+ }
+ }
+
+ /**
+ * Renames a compilation unit int the given package in the workspace. A
+ * workspace must be open.
+ */
+ public void renameCU(final IPath packagePath, final String cuName, final String newName) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IFolder packageFolder = fWorkspace.getRoot().getFolder(packagePath);
+ try {
+ packageFolder.getFile(cuName).move(packageFolder.getFile(newName).getFullPath(), true, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ /**
+ * Removes a binary class from the given package in the workspace. A
+ * workspace must be open, and the given class name must not end with
+ * ".class".
+ */
+ public void removeBinaryClass(final IPath packagePath, String className) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ className += ".class"; //$NON-NLS-1$
+ final IFolder packageFolder = fWorkspace.getRoot().getFolder(packagePath);
+ try {
+ packageFolder.getFile(className).delete(true, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ /**
+ * Removes a class from the given package in the workspace. A workspace must
+ * be open, and the given class name must not end with ".java".
+ */
+ public void removeClass(final IPath packagePath, String className) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ className += ".java"; //$NON-NLS-1$
+ final IFolder packageFolder = fWorkspace.getRoot().getFolder(packagePath);
+ try {
+ packageFolder.getFile(className).delete(true, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ /**
+ * Removes a package from the given package fragment root in the workspace.
+ * A workspace must be open.
+ */
+ public void removePackage(final IPath packageFragmentRootPath, final String packageName) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IPath path = packageFragmentRootPath.append(packageName.replace('.', IPath.SEPARATOR));
+ final IFolder folder = fWorkspace.getRoot().getFolder(path);
+ try {
+ folder.delete(false, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ /**
+ * Removes the given package fragment root from the the workspace. A
+ * workspace must be open.
+ */
+ public void removePackageFragmentRoot(final IPath projectPath, final String packageFragmentRootName)
+ throws JavaModelException {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ if (packageFragmentRootName.length() > 0) {
+ final IFolder folder = getProject(projectPath).getFolder(packageFragmentRootName);
+ if (folder.exists()) {
+ try {
+ folder.delete(false, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+ }
+ final IPath rootPath = getPackageFragmentRootPath(projectPath, packageFragmentRootName);
+ removeEntry(projectPath, rootPath);
+ }
+
+ /**
+ * Remove a project from the workspace.
+ */
+ public void removeProject(final IPath projectPath) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ try {
+ getJavaProject(projectPath).close();
+ }
+ catch (final JavaModelException e) {
+ e.printStackTrace();
+ }
+ final IProject project = getProject(projectPath);
+ try {
+ project.refreshLocal(IProject.DEPTH_INFINITE, new NullProgressMonitor());
+ project.delete(true, true, null);
+ }
+ catch (final CoreException ignore) {
+ // handle(e);
+ }
+
+ }
+
+ /**
+ * Search the user hard-drive for a Java class library. Returns null if none
+ * could be found.
+ *
+ * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()]
+ */
+ public String[] getJavaClassLibs() {
+ final String jreDir = getJREDirectory();
+ if (jreDir == null)
+ return new String[] {};
+ final String vmName = System.getProperty("java.vm.name");
+ if ("J9".equals(vmName))
+ return new String[] { toNativePath(jreDir + "/lib/jclMax/classes.zip") };
+ else if ("Mac OS X".equals(System.getProperty("os.name")))
+ return new String[] { toNativePath(jreDir + "/../Classes/classes.jar") };
+ else {
+ final File file = new File(jreDir + "/lib/rt.jar");
+ if (file.exists())
+ return new String[] { toNativePath(jreDir + "/lib/rt.jar") };
+ return new String[] { toNativePath(jreDir + "/lib/core.jar"), toNativePath(jreDir + "/lib/security.jar"),
+ toNativePath(jreDir + "/lib/graphics.jar") };
+ }
+ }
+
+ /**
+ * Returns the JRE directory this tests are running on. Returns null if none
+ * could be found.
+ *
+ * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJREDirectory()]
+ */
+ public String getJREDirectory() {
+ return System.getProperty("java.home");
+ }
+
+ /**
+ * Makes the given path a path using native path separators as returned by
+ * File.getPath() and trimming any extra slash.
+ */
+ public String toNativePath(final String path) {
+ final String nativePath = path.replace('\\', File.separatorChar).replace('/', File.separatorChar);
+ return nativePath.endsWith("/") || nativePath.endsWith("\\") ? nativePath.substring(0, nativePath.length() - 1)
+ : nativePath;
+ }
+
+ /**
+ * Remove a required project from the classpath
+ */
+ public void removeRequiredProject(final IPath projectPath, final IPath requiredProject) throws JavaModelException {
+ removeEntry(projectPath, requiredProject);
+ }
+
+ /**
+ * Remove all elements in the workspace.
+ */
+ public void resetWorkspace() {
+ if (fProjects != null) {
+ final Enumeration projectNames = fProjects.keys();
+ while (projectNames.hasMoreElements()) {
+ final String projectName = (String) projectNames.nextElement();
+ removeProject(getProject(projectName).getFullPath());
+ }
+ }
+ }
+
+ /**
+ * Remove a given classpath entry from the projects class path
+ *
+ * @param projectPath
+ * The project to modify
+ * @param entry
+ * The entry to remove
+ * @throws JavaModelException
+ */
+ public void removeClasspathEntry(final IPath projectPath, final IClasspathEntry entry) throws JavaModelException {
checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
final IClasspathEntry[] oldEntries = getClasspath(projectPath);
for (int i = 0; i < oldEntries.length; ++i) {
if (entry.equals(oldEntries[i])) {
final IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length - 1];
System.arraycopy(oldEntries, 0, newEntries, 0, i);
- System.arraycopy(oldEntries, i + 1, newEntries, i,
- oldEntries.length - i - 1);
+ System.arraycopy(oldEntries, i + 1, newEntries, i, oldEntries.length - i - 1);
setClasspath(projectPath, newEntries);
break;
}
}
}
-
- /**
+ /**
* Removes the given internal jar from the workspace. A workspace must be
* open.
*/
- public void removeInternalJar(final IPath projectPath, final String zipName) throws JavaModelException {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- checkAssertion("zipName must end with .zip or .jar", zipName.endsWith(".zip") || zipName.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /* remove zip from the java model (it caches open zip files) */
- final IPath zipPath = getJarRootPath(projectPath).append(zipName);
- try {
- getJavaProject(projectPath).getPackageFragmentRoot(getWorkspace().getRoot().getFile(zipPath)).close();
- } catch (final JavaModelException e) {
- e.printStackTrace();
- }
- removePackageFragmentRoot(projectPath, zipName);
-
- final IFile file = getProject(projectPath).getFile(zipName);
- try {
- file.delete(false, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- /**
- * Remove an external jar from the classpath.
- */
- public void removeExternalJar(final IPath projectPath, final IPath jarPath) throws JavaModelException {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- removeEntry(projectPath, jarPath);
- }
-
- private void removeEntry(final IPath projectPath, final IPath entryPath) throws JavaModelException {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IClasspathEntry[] oldEntries = getClasspath(projectPath);
- for (int i = 0; i < oldEntries.length; ++i) {
- if (oldEntries[i].getPath().equals(entryPath)) {
- final IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length - 1];
- System.arraycopy(oldEntries, 0, newEntries, 0, i);
- System.arraycopy(oldEntries, i + 1, newEntries, i, oldEntries.length - i - 1);
- setClasspath(projectPath, newEntries);
- }
- }
- }
-
- /**
- * Remove a file
- */
- public void removeFile(final IPath filePath) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- try {
- fWorkspace.getRoot().getFile(filePath).delete(true, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- /**
- * Remove a folder
- */
- public void removeFolder(final IPath folderPath) {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IFolder folder = fWorkspace.getRoot().getFolder(folderPath);
- try {
- folder.delete(true, null);
- } catch (final CoreException e) {
- handle(e);
- }
- }
-
- public void setAutoBuilding(final boolean value) {
- try {
- final IWorkspace w = getWorkspace();
- final IWorkspaceDescription d = w.getDescription();
- d.setAutoBuilding(value);
- w.setDescription(d);
- } catch (final CoreException e) {
- e.printStackTrace();
- checkAssertion("CoreException", false); //$NON-NLS-1$
- }
- }
-
- public void setBuildOrder(final String[] projects) {
- try {
- final IWorkspace w = getWorkspace();
- final IWorkspaceDescription d = w.getDescription();
- d.setBuildOrder(projects);
- w.setDescription(d);
- } catch (final CoreException e) {
- e.printStackTrace();
- checkAssertion("CoreException", false); //$NON-NLS-1$
- }
- }
-
- public void setClasspath(final IPath projectPath, final IClasspathEntry[] entries) throws JavaModelException {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IJavaProject javaProject = JavaCore.create(getProject(projectPath));
- javaProject.setRawClasspath(entries, null);
- }
-
- public IPath setExternalOutputFolder(final IPath projectPath, final String name, final IPath externalOutputLocation) {
- IPath result = null;
- try {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IProject p = getProject(projectPath);
- final IFolder f = p.getFolder(name);
- f.createLink(externalOutputLocation, IResource.ALLOW_MISSING_LOCAL, null);
-
- result = f.getFullPath();
- final IJavaProject javaProject = JavaCore.create(p);
- javaProject.setOutputLocation(result, null);
- } catch (final CoreException e) {
- e.printStackTrace();
- checkAssertion("CoreException", false); //$NON-NLS-1$
- }
- return result;
- }
-
- public IPath setOutputFolder(final IPath projectPath, final String outputFolder) {
- IPath outputPath = null;
- try {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- final IJavaProject javaProject = JavaCore.create(getProject(projectPath));
- outputPath = projectPath.append(outputFolder);
- javaProject.setOutputLocation(outputPath, null);
- } catch (final JavaModelException e) {
- e.printStackTrace();
- checkAssertion("JavaModelException", false); //$NON-NLS-1$
- }
- return outputPath;
- }
-
- private void setup() {
- fIsOpen = true;
- }
-
- /**
- * Wait for autobuild notification to occur
- */
- public void waitForAutoBuild() {
- checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
- boolean wasInterrupted = false;
- do {
- try {
- Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
- wasInterrupted = false;
- } catch (final OperationCanceledException e) {
- handle(e);
- } catch (final InterruptedException e) {
- wasInterrupted = true;
- }
- } while (wasInterrupted);
- fWasBuilt = true;
- }
-
- public void moveFile(final IPath root, final IPath tpl) {
- try {
- fWorkspace.getRoot().getFile(tpl).move(root.append(tpl.lastSegment()), true, new NullProgressMonitor());
- } catch (final CoreException e) {
- throw new RuntimeException(e);
- }
-
- }
-
- public void changeFile(final IPath tpl, final InputStream contents) {
- try {
- fWorkspace.getRoot().getFile(tpl).setContents(contents, true, true, new NullProgressMonitor());
- } catch (final CoreException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Imports one or more zipped projects into the workspace. The workspace must be opened before
- * invoking this method. The Zip file is assumed to have the following structure:
-<pre>
-/ Zip Root
-/Proj1 Project#1 Root
- +-- res1 Resource in Project#1
- +-- res2 "
-/Proj2 Project#2 Root
-...
-</pre>
- * @param resourceStream Stream for reading the Zip File
- * @return The imported projects
- * @since 25.07.2007
- * @author Karsten Thoms
- */
- public List<IProject> importZippedProject (InputStream resourceStream) {
- List<IProject> result = new ArrayList<IProject>();
-
- try {
- IPath root = fWorkspace.getRoot().getFullPath();
- File tempFile = File.createTempFile("oawtest", "");
- tempFile.deleteOnExit();
- FSIO.writeSingleFile(new FileWriter(tempFile), new BufferedReader(new InputStreamReader(resourceStream)));
- ZipFile zipFile = new ZipFile(tempFile);
- ZipFileStructureProvider zipFileStructureProvider = new ZipFileStructureProvider(zipFile);
- ZipEntry zipRoot = zipFileStructureProvider.getRoot();
-
- // Assume that the root entry in the ZIP file is named "/"
- if ("/".equals(zipRoot.getName())) {
- // Iterate over the contained projects
- for (Iterator<?> itProject= zipFileStructureProvider.getChildren(zipRoot).iterator(); itProject.hasNext(); ) {
- ZipEntry projectEntry = (ZipEntry) itProject.next();
- // The project name has a trailing slash that we need to remove
- String projectName = projectEntry.getName().substring(0, projectEntry.getName().length()-1);
-
- // Create this project
- IProject proj = createProject(projectName);
- // Iterate over the project's children and import them recursively
- for (Iterator it2=zipFileStructureProvider.getChildren(projectEntry).iterator(); it2.hasNext(); ) {
- ZipEntry projectContent = (ZipEntry) it2.next();
- // We use the ImportOperation to facilitate project import
- ImportOperation op = new ImportOperation(
- root,
- projectContent,
- zipFileStructureProvider,
- new IOverwriteQuery() {
- public String queryOverwrite(String pathString) {
- return IOverwriteQuery.ALL;
- }});
- op.run(new NullProgressMonitor());
- }
- result.add(proj);
- }
- }
- } catch (final RuntimeException e) {
- throw e;
- } catch (final Exception e) {
- throw new RuntimeException(e);
- }
- return result;
- }
+ public void removeInternalJar(final IPath projectPath, final String zipName) throws JavaModelException {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ checkAssertion("zipName must end with .zip or .jar", zipName.endsWith(".zip") || zipName.endsWith(".jar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ /* remove zip from the java model (it caches open zip files) */
+ final IPath zipPath = getJarRootPath(projectPath).append(zipName);
+ try {
+ getJavaProject(projectPath).getPackageFragmentRoot(getWorkspace().getRoot().getFile(zipPath)).close();
+ }
+ catch (final JavaModelException e) {
+ e.printStackTrace();
+ }
+ removePackageFragmentRoot(projectPath, zipName);
+
+ final IFile file = getProject(projectPath).getFile(zipName);
+ try {
+ file.delete(false, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ /**
+ * Remove an external jar from the classpath.
+ */
+ public void removeExternalJar(final IPath projectPath, final IPath jarPath) throws JavaModelException {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ removeEntry(projectPath, jarPath);
+ }
+
+ private void removeEntry(final IPath projectPath, final IPath entryPath) throws JavaModelException {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IClasspathEntry[] oldEntries = getClasspath(projectPath);
+ for (int i = 0; i < oldEntries.length; ++i) {
+ if (oldEntries[i].getPath().equals(entryPath)) {
+ final IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length - 1];
+ System.arraycopy(oldEntries, 0, newEntries, 0, i);
+ System.arraycopy(oldEntries, i + 1, newEntries, i, oldEntries.length - i - 1);
+ setClasspath(projectPath, newEntries);
+ }
+ }
+ }
+
+ /**
+ * Remove a file
+ */
+ public void removeFile(final IPath filePath) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ try {
+ fWorkspace.getRoot().getFile(filePath).delete(true, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ /**
+ * Remove a folder
+ */
+ public void removeFolder(final IPath folderPath) {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IFolder folder = fWorkspace.getRoot().getFolder(folderPath);
+ try {
+ folder.delete(true, null);
+ }
+ catch (final CoreException e) {
+ handle(e);
+ }
+ }
+
+ public void setAutoBuilding(final boolean value) {
+ try {
+ final IWorkspace w = getWorkspace();
+ final IWorkspaceDescription d = w.getDescription();
+ d.setAutoBuilding(value);
+ w.setDescription(d);
+ }
+ catch (final CoreException e) {
+ e.printStackTrace();
+ checkAssertion("CoreException", false); //$NON-NLS-1$
+ }
+ }
+
+ public void setBuildOrder(final String[] projects) {
+ try {
+ final IWorkspace w = getWorkspace();
+ final IWorkspaceDescription d = w.getDescription();
+ d.setBuildOrder(projects);
+ w.setDescription(d);
+ }
+ catch (final CoreException e) {
+ e.printStackTrace();
+ checkAssertion("CoreException", false); //$NON-NLS-1$
+ }
+ }
+
+ public void setClasspath(final IPath projectPath, final IClasspathEntry[] entries) throws JavaModelException {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IJavaProject javaProject = JavaCore.create(getProject(projectPath));
+ javaProject.setRawClasspath(entries, null);
+ }
+
+ public IPath setExternalOutputFolder(final IPath projectPath, final String name, final IPath externalOutputLocation) {
+ IPath result = null;
+ try {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IProject p = getProject(projectPath);
+ final IFolder f = p.getFolder(name);
+ f.createLink(externalOutputLocation, IResource.ALLOW_MISSING_LOCAL, null);
+
+ result = f.getFullPath();
+ final IJavaProject javaProject = JavaCore.create(p);
+ javaProject.setOutputLocation(result, null);
+ }
+ catch (final CoreException e) {
+ e.printStackTrace();
+ checkAssertion("CoreException", false); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ public IPath setOutputFolder(final IPath projectPath, final String outputFolder) {
+ IPath outputPath = null;
+ try {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ final IJavaProject javaProject = JavaCore.create(getProject(projectPath));
+ outputPath = projectPath.append(outputFolder);
+ javaProject.setOutputLocation(outputPath, null);
+ }
+ catch (final JavaModelException e) {
+ e.printStackTrace();
+ checkAssertion("JavaModelException", false); //$NON-NLS-1$
+ }
+ return outputPath;
+ }
+
+ private void setup() {
+ fIsOpen = true;
+ }
+
+ /**
+ * Wait for autobuild notification to occur
+ */
+ public void waitForAutoBuild() {
+ checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
+ boolean wasInterrupted = false;
+ do {
+ try {
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ wasInterrupted = false;
+ }
+ catch (final OperationCanceledException e) {
+ handle(e);
+ }
+ catch (final InterruptedException e) {
+ wasInterrupted = true;
+ }
+ } while (wasInterrupted);
+ fWasBuilt = true;
+ }
+
+ public void moveFile(final IPath root, final IPath tpl) {
+ try {
+ fWorkspace.getRoot().getFile(tpl).move(root.append(tpl.lastSegment()), true, new NullProgressMonitor());
+ }
+ catch (final CoreException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ public void changeFile(final IPath tpl, final InputStream contents) {
+ try {
+ fWorkspace.getRoot().getFile(tpl).setContents(contents, true, true, new NullProgressMonitor());
+ }
+ catch (final CoreException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Imports one or more zipped projects into the workspace. The workspace
+ * must be opened before invoking this method. The Zip file is assumed to
+ * have the following structure:
+ *
+ * <pre>
+ * / Zip Root
+ * /Proj1 Project#1 Root
+ * +-- res1 Resource in Project#1
+ * +-- res2 &quot;
+ * /Proj2 Project#2 Root
+ * ...
+ * </pre>
+ *
+ * @param resourceStream
+ * Stream for reading the Zip File
+ * @return The imported projects
+ * @since 25.07.2007
+ * @author Karsten Thoms
+ */
+ public List<IProject> importZippedProject(final InputStream resourceStream) {
+ final List<IProject> result = new ArrayList<IProject>();
+
+ try {
+ final IPath root = fWorkspace.getRoot().getFullPath();
+ final File tempFile = File.createTempFile("extxpttest", "");
+ tempFile.deleteOnExit();
+ FSIO.writeSingleFile(new FileWriter(tempFile), new BufferedReader(new InputStreamReader(resourceStream)));
+ final ZipFile zipFile = new ZipFile(tempFile);
+ final ZipFileStructureProvider zipFileStructureProvider = new ZipFileStructureProvider(zipFile);
+ final ZipEntry zipRoot = zipFileStructureProvider.getRoot();
+
+ // Assume that the root entry in the ZIP file is named "/"
+ if ("/".equals(zipRoot.getName())) {
+ // Iterate over the contained projects
+ for (final Iterator<?> itProject = zipFileStructureProvider.getChildren(zipRoot).iterator(); itProject
+ .hasNext();) {
+ final ZipEntry projectEntry = (ZipEntry) itProject.next();
+ // The project name has a trailing slash that we need to
+ // remove
+ final String projectName = projectEntry.getName().substring(0, projectEntry.getName().length() - 1);
+
+ // Create this project
+ final IProject proj = createProject(projectName);
+ // Iterate over the project's children and import them
+ // recursively
+ for (final Iterator it2 = zipFileStructureProvider.getChildren(projectEntry).iterator(); it2
+ .hasNext();) {
+ final ZipEntry projectContent = (ZipEntry) it2.next();
+ // We use the ImportOperation to facilitate project
+ // import
+ final ImportOperation op = new ImportOperation(root, projectContent, zipFileStructureProvider,
+ new IOverwriteQuery() {
+ public String queryOverwrite(final String pathString) {
+ return IOverwriteQuery.ALL;
+ }
+ });
+ op.run(new NullProgressMonitor());
+ }
+ result.add(proj);
+ }
+ }
+ }
+ catch (final RuntimeException e) {
+ throw e;
+ }
+ catch (final Exception e) {
+ throw new RuntimeException(e);
+ }
+ return result;
+ }
}
diff --git a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/ASTTest.java b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/ASTTest.java
index 1a97e8f..4558c4e 100644
--- a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/ASTTest.java
+++ b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/ASTTest.java
@@ -35,10 +35,10 @@ public class ASTTest extends XpandCoreTestBase {
dumpMarkers(tpl);
dumpMarkers(tpl2);
final IXpandResource xptpl = (IXpandResource) Activator.getExtXptModelManager().findExtXptResource(storage(tpl));
- assertNotNull("OawModelManager could not find Xpand Resource '"+tpl+"' in the workspace", xptpl);
+ assertNotNull("XtendXpandModelManager could not find Xpand Resource '"+tpl+"' in the workspace", xptpl);
final IXpandResource xptpl2 = (IXpandResource) Activator.getExtXptModelManager().findExtXptResource(storage(tpl2));
- assertNotNull("OawModelManager could not find Xpand Resource '"+tpl2+"' in the workspace", xptpl2);
+ assertNotNull("XtendXpandModelManager could not find Xpand Resource '"+tpl2+"' in the workspace", xptpl2);
env.removeFile(tpl);
env.incrementalBuild();
diff --git a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/AllPackageTests.java b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/AllPackageTests.java
index cd28712..fb0c1cd 100644
--- a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/AllPackageTests.java
+++ b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/AllPackageTests.java
@@ -11,7 +11,7 @@ public class AllPackageTests {
//$JUnit-BEGIN$
suite.addTestSuite(Bug155018Test.class);
suite.addTestSuite(JdtJavaBeanTest.class);
- suite.addTestSuite(OawProjectTest.class);
+ suite.addTestSuite(XtendXpandProjectTest.class);
suite.addTestSuite(SimpleProjectTest.class);
suite.addTestSuite(ASTTest.class);
//$JUnit-END$
diff --git a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/Bug155018Test.java b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/Bug155018Test.java
index 59d52cd..6ad990b 100644
--- a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/Bug155018Test.java
+++ b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/Bug155018Test.java
@@ -29,7 +29,7 @@ public class Bug155018Test extends XpandCoreTestBase {
/**
* Test for Bug#155018: The bug concerns loading resources from Jar files.
*/
- public final void testFindOawResourceInJar() throws JavaModelException {
+ public final void testFindExtXptResourceInJar() throws JavaModelException {
env.openEmptyWorkspace();
// create a test project and add a Jar file to its classpath. The Jar 'ExtensionInJar.jar' contains the
// extension 'org::openarchitectureware::util::IO.ext'
diff --git a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/OawProjectTest.java b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/XtendXpandProjectTest.java
index fdbe809..036adc1 100644
--- a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/OawProjectTest.java
+++ b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/core/XtendXpandProjectTest.java
@@ -13,35 +13,39 @@ package org.eclipse.xtend.shared.ui.test.xpand2.core;
import org.eclipse.core.runtime.IPath;
@SuppressWarnings("unused")
-public class OawProjectTest extends XpandCoreTestBase {
-
+public class XtendXpandProjectTest extends XpandCoreTestBase {
+
@Override
public void setUp() throws Exception {
super.setUp();
}
- // An example meta model which we will extract in our project and use in our templates
+ // An example meta model which we will extract in our project and use in our
+ // templates
// It has one type "MetaType" with attribute "name:String"
private final String ECORE_MMODEL = "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ "<ecore:EPackage xmi:version=\"2.0\" "
+ "xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"mm\" "
- + "nsURI=\"http://www.openarchitectureware.org/mm/test/mm\" nsPrefix=\"mm\">"
+ + "nsURI=\"http://www.eclipse.org/mm/test/mm\" nsPrefix=\"mm\">"
+ "<eClassifiers xsi:type=\"ecore:EClass\" name=\"MetaType\">"
+ "<eStructuralFeatures xsi:type=\"ecore:EAttribute\" name=\"name\" eType=\"ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString\"/>"
+ "</eClassifiers>" + "</ecore:EPackage>";
/**
- * This test case checks if caches inside the OawPluginProject reflect the current file structure
- * correctly. This is done by removing a necessary file from the project to compile. If the project
- * still compiles after removing the file, there is most likely a cache inside the OawPlugin class
- * still holding the now removed resource
+ * This test case checks if caches inside the OawPluginProject reflect the
+ * current file structure correctly. This is done by removing a necessary
+ * file from the project to compile. If the project still compiles after
+ * removing the file, there is most likely a cache inside the OawPlugin
+ * class still holding the now removed resource
+ *
* @throws Exception
*/
public void testOawPluginResourceCache() throws Exception {
- // Create workspace, Template which uses mm.ecore and Template2 which uses Template
+ // Create workspace, Template which uses mm.ecore and Template2 which
+ // uses Template
env.openEmptyWorkspace();
- final IPath pPath = env.addProject("test-"+System.currentTimeMillis());
+ final IPath pPath = env.addProject("test-" + System.currentTimeMillis());
env.addExternalJars(pPath, env.getJavaClassLibs());
env.removePackageFragmentRoot(pPath, "");
final IPath root = env.addPackageFragmentRoot(pPath, "templates");
@@ -49,11 +53,10 @@ public class OawProjectTest extends XpandCoreTestBase {
env.addFile(pack, "mm.ecore", ECORE_MMODEL);
- IPath tpl = env.addFile(pack, "Template.xpt", tag("IMPORT mm") + "\n"
- + tag("DEFINE Root FOR MetaType") + "\n" + tag("ENDDEFINE"));
- IPath tpl2 = env.addFile(pack, "Template2.xpt", tag("IMPORT mm") + "\n"
- + tag("DEFINE Root FOR MetaType") + "\n"
- + tag("EXPAND Template::Root FOR this") + tag("ENDDEFINE"));
+ final IPath tpl = env.addFile(pack, "Template.xpt", tag("IMPORT mm") + "\n" + tag("DEFINE Root FOR MetaType")
+ + "\n" + tag("ENDDEFINE"));
+ final IPath tpl2 = env.addFile(pack, "Template2.xpt", tag("IMPORT mm") + "\n" + tag("DEFINE Root FOR MetaType")
+ + "\n" + tag("EXPAND Template::Root FOR this") + tag("ENDDEFINE"));
env.fullBuild();
assertNoErrorMarkers(tpl);
assertNoErrorMarkers(tpl2);
@@ -62,23 +65,26 @@ public class OawProjectTest extends XpandCoreTestBase {
// file. Expected result: Template2 has errors
env.removeFile(tpl);
env.fullBuild();
- assertTrue("There should be an error now, that template 1 is missing!",
- env.getMarkersFor(tpl2).length > 0);
+ assertTrue("There should be an error now, that template 1 is missing!", env.getMarkersFor(tpl2).length > 0);
}
/**
- * This test case tests the OawModelManager by creating a working plugin named test with template
- * and metamodel. The whole project is removed afterwards. Now, a project is created called test again.
- * oAW should notice this new "test" project as completly now project having nothing to do with the former
- * "test" project. We try to see if it works by accessing a file in a template in the new test which only
- * existed in the old test. However, the test and its current strategy only work if there is a state
- * in OawPlugin class like a cache holding old resources. However, if there was no state in OawPlugin
- * then it would be ok to resuse the same class again...
+ * This test case tests the OawModelManager by creating a working plugin
+ * named test with template and metamodel. The whole project is removed
+ * afterwards. Now, a project is created called test again. Xpand should
+ * notice this new "test" project as completly now project having nothing to
+ * do with the former "test" project. We try to see if it works by accessing
+ * a file in a template in the new test which only existed in the old test.
+ * However, the test and its current strategy only work if there is a state
+ * in OawPlugin class like a cache holding old resources. However, if there
+ * was no state in OawPlugin then it would be ok to resuse the same class
+ * again...
+ *
* @throws Exception
*/
public void testOawPluginCacheWithRecreatedProject() throws Exception {
env.openEmptyWorkspace();
- final IPath pPath = env.addProject("test-"+System.currentTimeMillis());
+ final IPath pPath = env.addProject("test-" + System.currentTimeMillis());
env.addExternalJars(pPath, env.getJavaClassLibs());
env.removePackageFragmentRoot(pPath, "");
final IPath root = env.addPackageFragmentRoot(pPath, "templates");
@@ -87,8 +93,8 @@ public class OawProjectTest extends XpandCoreTestBase {
final IPath mmFolder = env.addFolder(root, "models");
env.addFile(mmFolder, "mm.ecore", ECORE_MMODEL);
- IPath tpl = env.addFile(pack, "Template.xpt", tag("IMPORT mm") + "\n"
- + tag("DEFINE Root FOR MetaType") + "\n" + tag("ENDDEFINE"));
+ final IPath tpl = env.addFile(pack, "Template.xpt", tag("IMPORT mm") + "\n" + tag("DEFINE Root FOR MetaType")
+ + "\n" + tag("ENDDEFINE"));
env.fullBuild();
assertNoErrorMarkers(tpl);
env.removeProject(pPath);
@@ -103,12 +109,10 @@ public class OawProjectTest extends XpandCoreTestBase {
final IPath mmFolder2 = env.addFolder(pPath2, "models");
env.addFile(mmFolder2, "mm.ecore", ECORE_MMODEL);
- IPath tpl2 = env.addFile(pack2, "Template2.xpt", tag("IMPORT mm")
- + "\n" + tag("DEFINE Root FOR MetaType") + "\n"
- + tag("EXPAND Template::Root FOR this") + tag("ENDDEFINE"));
+ final IPath tpl2 = env.addFile(pack2, "Template2.xpt", tag("IMPORT mm") + "\n"
+ + tag("DEFINE Root FOR MetaType") + "\n" + tag("EXPAND Template::Root FOR this") + tag("ENDDEFINE"));
env.fullBuild();
- assertTrue(
- "There should be an error now, that template 1 is absolutely unknown!",
+ assertTrue("There should be an error now, that template 1 is absolutely unknown!",
env.getMarkersFor(tpl2).length > 0);
}
}
diff --git a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/emf/EmfXpandTest.java b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/emf/EmfXpandTest.java
index 1ab2139..171ab0c 100644
--- a/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/emf/EmfXpandTest.java
+++ b/tests/org.eclipse.xtend.shared.ui.test/src/org/eclipse/xtend/shared/ui/test/xpand2/emf/EmfXpandTest.java
@@ -27,7 +27,7 @@ public class EmfXpandTest extends XpandCoreTestBase {
" xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"mm\" "
+
- " nsURI=\"http://www.openarchitectureware.org/mm/test/mm\" nsPrefix=\"mm\">"
+ " nsURI=\"http://www.eclipse.org/mm/test/mm\" nsPrefix=\"mm\">"
+ "<eClassifiers xsi:type=\"ecore:EClass\" name=\"MetaType\">"
+ "<eStructuralFeatures xsi:type=\"ecore:EAttribute\" name=\"name\" eType=\"ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString\"/>"
+ "</eClassifiers>" + "</ecore:EPackage>";