Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 36b19fef9e7515abd28e2f40b6210ed72d8fb9e8 (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
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (c) 2013 QNX Software Systems and others.
 * 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
 */
package org.eclipse.cdt.qt.internal.core.pdom;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.qt.core.index.IQProperty;
import org.eclipse.core.runtime.CoreException;

@SuppressWarnings("restriction")
public class QtPropertyName extends AbstractQObjectMemberName implements IQtASTName {

	private String type;
	// TODO The PDOM attrs should only be created in #createPDOMBinding
	private List<QtPDOMProperty.Attribute> attributes = new ArrayList<QtPDOMProperty.Attribute>();

	public QtPropertyName(QObjectName qobjName, IASTName ast, String name, QtASTImageLocation location) {
		super(qobjName, ast, name, location);
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	/**
	 * This permits storage of duplicate attributes, a Codan checker should flag this as an error, but
	 * while the invalid code exists, the references should continue to be properly resolved.
	 */
	public void addAttribute(IQProperty.Attribute attr, String value) {
		attributes.add(new QtPDOMProperty.Attribute(attr, value));
	}

	/**
	 * This permits storage of duplicate attributes, a Codan checker should flag this as an error, but
	 * while the invalid code exists, the references should continue to be properly resolved.
	 */
	public void addAttribute(IQProperty.Attribute attr, String value, IBinding cppBinding) {
		PDOMBinding pdomBinding = cppBinding == null ? null : (PDOMBinding) cppBinding.getAdapter(PDOMBinding.class);
		attributes.add(new QtPDOMProperty.Attribute(attr, value, pdomBinding));
	}

	@Override
	public QtPDOMBinding createPDOMBinding(QtPDOMLinkage linkage) throws CoreException {
		QtPDOMProperty pdom = new QtPDOMProperty(linkage, getOwner(linkage), this);
		pdom.setAttributes(attributes.toArray(new QtPDOMProperty.Attribute[attributes.size()]));
		return pdom;
	}
}

Back to the top