Commit 3cf9df1b authored by Dominique Marcadet's avatar Dominique Marcadet

Merge branch '27-add-line-number-in-messages' into 'master'

Resolve "add line number in messages"

Closes #27

See merge request !26
parents 36edb76f 9bdc64eb
Pipeline #7740 passed with stages
in 29 seconds
......@@ -102,4 +102,10 @@ public interface NsdObject extends EObject {
* @generated
*/
boolean buildExplicitLinks( IRiseClipseConsole console, boolean forceUpdate );
/*
* @generated NOT
*/
void setFilename( String filename );
String getFilename();
} // NsdObject
......@@ -31,6 +31,7 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
/**
......@@ -279,5 +280,19 @@ public abstract class NsdObjectImpl extends MinimalEObjectImpl.Container impleme
if( rs instanceof NsdResourceSetImpl ) return ( NsdResourceSetImpl ) rs;
return null;
}
private String filename;
public void setFilename( String filename ) {
this.filename = filename;
}
public String getFilename() {
if( filename == null ) {
Resource r = eResource();
filename = ( r == null ) ? "" : r.getURI().lastSegment();
}
return filename;
}
} //NsdObjectImpl
......@@ -1872,6 +1872,9 @@ public class ServiceDataAttributeImpl extends DocumentedClassImpl implements Ser
dataAttribute.setTypeKind( getTypeKind() );
dataAttribute.setFc( getFc() );
dataAttribute.setName( getName() );
dataAttribute.setLineNumber( getLineNumber() );
dataAttribute.setFilename( getFilename() );
return dataAttribute;
}
......
/**
* Copyright (c) 2019 CentraleSupélec & EDF.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec
* EDF R&D
* Contacts:
* dominique.marcadet@centralesupelec.fr
* aurelie.dehouck-neveu@edf.fr
* Web site:
* http://wdi.supelec.fr/software/RiseClipse/
*/
package fr.centralesupelec.edf.riseclipse.iec61850.nsd.util;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class NsdLoadImpl extends XMLLoadImpl {
public NsdLoadImpl( XMLHelper helper ) {
super( helper );
}
public DefaultHandler makeDefaultHandler() {
return new NsdXmlHandler( resource, helper, options );
}
@Override
protected SAXParser makeParser() throws ParserConfigurationException, SAXException {
SAXParserFactory f = SAXParserFactory.newInstance();
f.setNamespaceAware( true );
return f.newSAXParser();
}
}
......@@ -20,6 +20,7 @@
package fr.centralesupelec.edf.riseclipse.iec61850.nsd.util;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.xmi.XMLLoad;
import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
......@@ -44,6 +45,11 @@ public class NsdResourceImpl extends XMLResourceImpl implements IRiseClipseResou
super( uri );
}
@Override
protected XMLLoad createXMLLoad() {
return new NsdLoadImpl( createXMLHelper() );
}
@Override
public void printStatistics( IRiseClipseConsole console ) {
// TODO !
......
/**
* Copyright (c) 2019 CentraleSupélec & EDF.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec
* EDF R&D
* Contacts:
* dominique.marcadet@centralesupelec.fr
* aurelie.dehouck-neveu@edf.fr
* Web site:
* http://wdi.supelec.fr/software/RiseClipse/
*/
package fr.centralesupelec.edf.riseclipse.iec61850.nsd.util;
import java.util.Map;
import java.util.Stack;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.NsdObject;
import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole;
public class NsdXmlHandler extends SAXXMLHandler {
private Stack< Integer > lineNumbers;
public NsdXmlHandler( XMLResource xmiResource, XMLHelper helper, Map< ?, ? > options ) {
super( xmiResource, helper, options );
lineNumbers = new Stack< Integer >();
}
@Override
public void startElement( String uri, String localName, String name ) {
lineNumbers.push( this.locator.getLineNumber() );
super.startElement( uri, localName, name );
}
@Override
protected void processObject( EObject object ) {
if( lineNumbers.empty() ) {
AbstractRiseClipseConsole.getConsole().warning( "NsdXmlHandler: linenumber stack empty !" );
}
else {
int lineNumber = lineNumbers.peek();
if( object instanceof NsdObject ) {
(( NsdObject ) object ).setLineNumber( lineNumber );
}
}
// TODO: error message
super.processObject( object );
}
@Override
public void endElement( String uri, String localName, String name ) {
if( lineNumbers.empty() ) {
AbstractRiseClipseConsole.getConsole().warning( "NsdXmlHandler: linenumber stack empty !" );
}
else {
lineNumbers.pop();
}
super.endElement( uri, localName, name );
}
@Override
public void endDocument() {
super.endDocument();
if( ! lineNumbers.empty() ) {
AbstractRiseClipseConsole.getConsole().warning( "NsdXmlHandler: linenumber stack not empty !" );
while( ! lineNumbers.empty() ) {
AbstractRiseClipseConsole.getConsole().warning( lineNumbers.pop() );
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment