Search in sources :

Example 1 with IErlMacroDef

use of org.erlide.engine.model.erlang.IErlMacroDef in project erlide_eclipse by erlang.

the class SearchPatternFactory method getSearchPatternFromErlElementAndLimitTo.

public ErlangSearchPattern getSearchPatternFromErlElementAndLimitTo(final IErlElement element, final LimitTo limitTo) {
    if (element instanceof IErlFunction) {
        final IErlFunction function = (IErlFunction) element;
        final String withoutExtension = SystemConfiguration.withoutExtension(function.getModuleName());
        return new FunctionPattern(withoutExtension, function.getFunctionName(), function.getArity(), limitTo, true, modelUtilService.getModule(function), !function.isExported());
    } else if (element instanceof IErlMacroDef) {
        final IErlMacroDef m = (IErlMacroDef) element;
        final String unquoted = StringUtils.unquote(m.getDefinedName());
        return new MacroPattern(unquoted, limitTo);
    } else if (element instanceof IErlRecordDef) {
        final IErlRecordDef r = (IErlRecordDef) element;
        final String unquoted = StringUtils.unquote(r.getDefinedName());
        return new RecordPattern(unquoted, limitTo);
    } else if (element instanceof IErlFunctionClause) {
        final IErlFunctionClause clause = (IErlFunctionClause) element;
        return getSearchPatternFromErlElementAndLimitTo((IErlElement) clause.getParent(), limitTo);
    } else if (element instanceof IErlAttribute) {
        final IErlAttribute a = (IErlAttribute) element;
        if (a.getName().startsWith("include")) {
            final String s = Util.stringValue(a.getValue());
            return new IncludePattern(s, limitTo);
        }
    }
    return null;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlRecordDef(org.erlide.engine.model.erlang.IErlRecordDef) IErlFunction(org.erlide.engine.model.erlang.IErlFunction) IErlAttribute(org.erlide.engine.model.erlang.IErlAttribute) IErlMacroDef(org.erlide.engine.model.erlang.IErlMacroDef) IErlFunctionClause(org.erlide.engine.model.erlang.IErlFunctionClause)

Aggregations

IErlElement (org.erlide.engine.model.IErlElement)1 IErlAttribute (org.erlide.engine.model.erlang.IErlAttribute)1 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)1 IErlFunctionClause (org.erlide.engine.model.erlang.IErlFunctionClause)1 IErlMacroDef (org.erlide.engine.model.erlang.IErlMacroDef)1 IErlRecordDef (org.erlide.engine.model.erlang.IErlRecordDef)1