Skip to content

Commit

Permalink
[eclipse-cbi#115] Fixed issue
Browse files Browse the repository at this point in the history
* extended grammar
* extended XCore model
* created some resolved* model files
* extended generator for the maven elements
* created formatter for new DSL elements incl. test
* extended test dependencies so tests are running again
* created new target for 4.26
* extended default tpd for m2e bundles for testing
* modified keyword proposals so keywords are proposed for the maven
elements
* created 2 new templates for the new location type

Signed-off-by: Hannes Niederhausen <[email protected]>
  • Loading branch information
hannesN committed Dec 21, 2022
1 parent 7ce43ab commit b4ffdc2
Show file tree
Hide file tree
Showing 19 changed files with 762 additions and 92 deletions.
36 changes: 0 additions & 36 deletions .launchers/Runtime Workspace.launch

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class TargetPlatform {
refers derived Location[] locations get {
new UnmodifiableEList(contents.filter(typeof(Location)).toList)
}
refers derived MavenLocation[] mavenLocations get {
new UnmodifiableEList(contents.filter(typeof(MavenLocation)).toList)
}
refers derived Environment environment get {
contents.filter(typeof(Environment)).head
}
Expand Down Expand Up @@ -137,6 +140,41 @@ class Location extends TargetContent {
contains IU[] ius opposite location
}

class MavenLocation extends TargetContent {
String label
MavenScope[] scopes
MavenDependencyDepth dependencyDepth
MavenMissingManifest missingManifest
boolean includeSources

contains GeneratedFeature generatedFeature
contains MavenDependency[] dependencies

contains MavenRepository[] repositories
}

class GeneratedFeature {
String ^id
String name
String vendor
String version
String instalLibrary
contains IU[] additionalBundles
}

class MavenRepository {
String ^id
String url
}

class MavenDependency {
String groupId
String artifactId
String version
String classifier
String ^type = "jar"
}

class IncludeDeclaration extends TargetContent {
String importURI
}
Expand All @@ -147,6 +185,28 @@ class IU {
container Location location opposite ius
}


enum MavenScope {
COMPILE as 'compile' = 0
PROVIDED as 'provided' = 1
RUNTIME as 'runtime' = 2
TEST as 'test' = 3
SYSTEM as 'system' = 4
IMPORT as 'import' = 5
}

enum MavenMissingManifest {
GENERATE as 'generate' = 0,
ERROR as 'error' = 1,
IGNORE as 'ignore' = 2
}

enum MavenDependencyDepth {
NONE as 'none' = 0,
DIRECT as 'direct' = 1,
INFINITE as 'infinite' = 2
}

enum Option {
INCLUDE_REQUIRED as 'requirements' = 0
INCLUDE_ALL_ENVIRONMENTS as 'allEnvironments' = 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.cbi.targetplatform.tests"/>
</listAttribute>
Expand All @@ -15,8 +16,12 @@
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.cbi.targetplatform.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>
</launchConfiguration>
4 changes: 3 additions & 1 deletion org.eclipse.cbi.targetplatform.tests/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ source.. = src/main/java,\
bin.includes = META-INF/,\
.,\
plugin.properties
additional.bundles = org.eclipse.jdt.core
additional.bundles = org.eclipse.jdt.core,\
org.eclipse.debug.core

Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,62 @@ class FormatterTest {
}
''')
}

@Test def testMavenDependencies() {
'''
target "Test" maven Test scope =compile , test ,runtime
dependencyDepth = none missingManifest = generate includeSources{
feature {
id="my.feature.com" name="My little feature"
version="1.0.0.qualifier" additionalBundles { org.eclipse.rcp }
}
dependency { groupId="org.jetbrains.kotlin" artifactId="kotlin-runtime"
version="1.2.71"
type="jar" }
dependency { groupId="org.jetbrains.kotlin" artifactId="kotlin-runtime"
version="1.2.71"
classifier="jdk8" type="jar" }
repository id = "localRepo"
url = "http://my.local.artifactory.de"
}'''.isFormattedTo('''
target "Test"
maven Test scope=compile,test,runtime dependencyDepth=none missingManifest=generate includeSources {
feature {
id="my.feature.com"
name="My little feature"
version="1.0.0.qualifier"
additionalBundles {
org.eclipse.rcp
}
}
dependency {
groupId="org.jetbrains.kotlin"
artifactId="kotlin-runtime"
version="1.2.71"
type="jar"
}
dependency {
groupId="org.jetbrains.kotlin"
artifactId="kotlin-runtime"
version="1.2.71"
classifier="jdk8"
type="jar"
}
repository id="localRepo" url="http://my.local.artifactory.de"
}
''')
}

private def isFormattedTo(CharSequence actual, CharSequence expected) {
assertFormatted[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import com.google.inject.Inject
import java.net.URI
import java.util.Locale
import org.eclipse.cbi.targetplatform.model.Environment
import org.eclipse.cbi.targetplatform.model.GeneratedFeature
import org.eclipse.cbi.targetplatform.model.IU
import org.eclipse.cbi.targetplatform.model.Location
import org.eclipse.cbi.targetplatform.model.MavenDependency
import org.eclipse.cbi.targetplatform.model.MavenLocation
import org.eclipse.cbi.targetplatform.model.Option
import org.eclipse.cbi.targetplatform.model.Options
import org.eclipse.cbi.targetplatform.model.TargetPlatform
Expand Down Expand Up @@ -154,6 +157,8 @@ class TargetPlatformProposalProvider extends AbstractTargetPlatformProposalProvi
}

templateLocation(context, acceptor)
templateMavenLocation(context, acceptor)
templateMavenLocationWithFeature(context, acceptor)
templateIncludeDeclaration(context, acceptor)
}
}
Expand All @@ -179,6 +184,64 @@ class TargetPlatformProposalProvider extends AbstractTargetPlatformProposalProvi
acceptor.accept(p);
}

private def templateMavenLocationWithFeature(ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
val proposalText = '''
maven MavenDependencies scope=compile,test dependencyDepth=infinite missingManifest=generate includeSources {
feature {
id="my.feature.com"
name="My little feature"
version="1.0.0.qualifier"
}
dependency {
groupId=""
artifactId=""
version=""
}
}
'''
val p = createCompletionProposal(
proposalText,
new StyledString("Maven Location with Feature - add a new maven location with feature to this target platform", StyledString.QUALIFIER_STYLER),
getImage(LOCATION),
context
)

if (p instanceof ConfigurableCompletionProposal) {
p.priority = priorityHelper.defaultPriority + 540
p.cursorPosition = 6
p.setSelectionStart(p.getReplacementOffset()+6);
p.setSelectionLength("MavenDependencies".length);
p.setSimpleLinkedMode(context.getViewer(), '\t');
}
acceptor.accept(p);
}
private def templateMavenLocation(ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
val proposalText = '''
maven MavenDependencies scope=compile,test dependencyDepth=infinite missingManifest=generate includeSources {
dependency {
groupId=""
artifactId=""
version=""
}
}
'''
val p = createCompletionProposal(
proposalText,
new StyledString("Maven location - add a new maven location to this target platform", StyledString.QUALIFIER_STYLER),
getImage(LOCATION),
context
)

if (p instanceof ConfigurableCompletionProposal) {
p.priority = priorityHelper.defaultPriority + 540
p.cursorPosition = 6
p.setSelectionStart(p.getReplacementOffset()+6);
p.setSelectionLength("MavenDependencies".length);
p.setSimpleLinkedMode(context.getViewer(), '\t');
}
acceptor.accept(p);
}

private def templateIncludeDeclaration(ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
val proposalPrefix = grammarAccess.includeDeclarationAccess.includeKeyword_0.value + ' "'
val proposalText = proposalPrefix +TargetPlatformProposalProvider.INCLUDE_DECLARATION__URI_PLACEHOLDER+ '"'
Expand Down Expand Up @@ -286,7 +349,8 @@ class TargetPlatformProposalProvider extends AbstractTargetPlatformProposalProvi
context.currentNode.text.substring(0, currentNodeSizeToCursor)
else
''
if (text.contains("\n") || context.currentNode.text.length < currentNodeSizeToCursor) {
// need to check, the model could be a GeneratedFeature, which for now is not supported
if (model instanceof Location && text.contains("\n") || context.currentNode.text.length < currentNodeSizeToCursor) {
val location = model as Location
val uri = location.uri
val window = PlatformUI.getWorkbench().activeWorkbenchWindow
Expand Down Expand Up @@ -439,6 +503,10 @@ class TargetPlatformProposalProvider extends AbstractTargetPlatformProposalProvi
}

override completeKeyword(Keyword keyword, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// reactivating the keyword completion for the maven classes
switch(context.currentModel) {
MavenLocation, MavenDependency, GeneratedFeature: super.completeKeyword(keyword, context, acceptor)
}
}

override complete_STRING(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ protected String calculateId(String tokenName, int tokenType) {
return TargetPlatformHighlightingConfiguration.OPTION_ID;
}

if ("'version'".equals(tokenName) ||
"'='".equals(tokenName) ||
if ("'='".equals(tokenName) ||
"';'".equals(tokenName)) {
return DefaultHighlightingConfiguration.DEFAULT_ID;
}
Expand Down
Loading

0 comments on commit b4ffdc2

Please sign in to comment.