blob: 7ea3cf69b65e72c40708bbdf0bd050745d6867ad [file] [log] [blame]
/**
* Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.xtext.oxtype.validation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.common.types.JvmParameterizedTypeReference;
import org.eclipse.xtext.common.types.JvmType;
import org.eclipse.xtext.xbase.validation.JvmTypeReferencesValidator;
@SuppressWarnings("restriction")
public class WarningAwareJvmTypeReferencesValidator extends
JvmTypeReferencesValidator {
@Override
protected void warnRawType(JvmType type,
JvmParameterizedTypeReference typeRef) {
if (!isSuppressed(SuppressWarningAdapter.RAW_TYPE, typeRef)) {
super.warnRawType(type, typeRef);
}
}
protected boolean isSuppressed(String warning, EObject eObject) {
SuppressWarningAdapter adapter = (SuppressWarningAdapter) EcoreUtil
.getAdapter(eObject.eAdapters(), SuppressWarningAdapter.class);
if (adapter != null) {
return adapter.isSuppressed(warning);
} else {
return false;
}
}
}