blob: 2c5f2b39a1e582b29054f271275b211d116b4c04 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*******************************************************************************
* Copyright (c) 2009 Red Hat Inc. and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alexander Kurtakov - initial API and implementation
*******************************************************************************/
package org.eclipse.dltk.sh.internal.core.parser;
import org.eclipse.dltk.compiler.IElementRequestor.FieldInfo;
import org.eclipse.dltk.compiler.IElementRequestor.TypeInfo;
import org.eclipse.dltk.compiler.ISourceElementRequestor;
import org.eclipse.dltk.compiler.env.IModuleSource;
import org.eclipse.dltk.core.AbstractSourceElementParser;
import org.eclipse.dltk.sh.core.ShelledNature;
public class ShelledSourceElementParser extends AbstractSourceElementParser {
@Override
protected String getNatureId() {
return ShelledNature.SHELLED_NATURE;
}
@Override
public void parseSourceModule(IModuleSource module) {
final ShellModuleDeclaration moduleDeclaration = (ShellModuleDeclaration) parse(module);
ISourceElementRequestor requestor = getRequestor();
requestor.enterModule();
TypeInfo tInfo = new TypeInfo();
tInfo.name = module.getModelElement().getElementName();
requestor.enterType(tInfo);
for (FunctionInfo method : moduleDeclaration.getFunctionsInfo()) {
requestor.enterMethod(method);
requestor.exitMethod(method.declarationEnd);
}
for (FieldInfo variable : moduleDeclaration.getFieldsInfo()) {
requestor.enterField(variable);
requestor.exitMethod(variable.nameSourceEnd);
}
requestor.exitType(module.getSourceContents().length());
requestor.exitModule(module.getSourceContents().length());
}
}
|