-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix metacompiler when installed together with KLighD. Previously the metacompiler would fail to compile some melk files due to the name already being defined. This modifies the validator to explicitly only check in paths containing "src". * add missing newline
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...elk.core.meta/src/org/eclipse/elk/core/meta/validation/MelkUniqueClassNameValidator.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 mka and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.elk.core.meta.validation | ||
|
||
import com.google.inject.Inject | ||
import org.eclipse.xtext.common.types.JvmDeclaredType | ||
import org.eclipse.xtext.common.types.TypesPackage | ||
import org.eclipse.xtext.naming.QualifiedName | ||
import org.eclipse.xtext.xbase.validation.UniqueClassNameValidator | ||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider | ||
|
||
/** | ||
* Overwrites the UniqueClassNameValidator to only check for melk files in src folders. This probably | ||
* prevents some special use cases where ELK is used as a library and a new melk file is created. | ||
* | ||
*/ | ||
class MelkUniqueClassNameValidator extends UniqueClassNameValidator { | ||
|
||
@Inject | ||
var ResourceDescriptionsProvider resourceDescriptionsProvider; | ||
|
||
override doCheckUniqueName(QualifiedName name, JvmDeclaredType type) { | ||
val index = resourceDescriptionsProvider.getResourceDescriptions(type.eResource()) | ||
val others = index.getExportedObjects(TypesPackage.Literals.JVM_DECLARED_TYPE, name, false) | ||
return checkUniqueInIndex(type, others.filter[it.EObjectURI.segments.exists[it.contains("src")]]) | ||
} | ||
} |